Significant progress. Performing cleanup now

This commit is contained in:
Ryan Ward
2026-05-11 14:31:02 -05:00
parent fe105e0369
commit 140da74f99
37 changed files with 843 additions and 1220 deletions
+9
View File
@@ -131,6 +131,13 @@ pub struct RequestParams {
pub parent_agent_id: Option<String>,
/// The display name for this agent (e.g. "Agent 1"), assigned by the orchestrator.
pub agent_name: Option<String>,
/// Full Bedrock conversation history for direct Bedrock calls.
/// When present, the Bedrock path uses this instead of extracting from task_context.
pub bedrock_message_history: Vec<crate::ai::bedrock::convert::ConversationMessage>,
/// Populated by the Bedrock path after building the message list.
/// Contains the full messages sent (old history + new input) so the controller
/// can store them back into the conversation for the next request cycle.
pub bedrock_messages_sent: std::sync::Arc<std::sync::Mutex<Vec<crate::ai::bedrock::convert::ConversationMessage>>>,
}
pub type Event = Result<warp_multi_agent_api::ResponseEvent, Arc<AIApiError>>;
@@ -317,6 +324,8 @@ impl RequestParams {
.map(|id| id.to_string()),
parent_agent_id: None,
agent_name: None,
bedrock_message_history: Vec::new(),
bedrock_messages_sent: std::sync::Arc::new(std::sync::Mutex::new(Vec::new())),
}
}
}
+24 -4
View File
@@ -59,7 +59,7 @@ pub async fn generate_multi_agent_output(
api_keys.allow_use_of_warp_credits = params.allow_use_of_warp_credits_with_byok;
}
let request = api::Request {
let mut request = api::Request {
task_context: Some(api::request::TaskContext {
tasks: params.tasks,
}),
@@ -183,8 +183,22 @@ pub async fn generate_multi_agent_output(
logger.log_protobuf_input(&request);
}
let messages =
crate::ai::bedrock::convert_request::extract_messages_from_request(&request);
// Build message list from bedrock_message_history + new input messages.
// The history contains all prior messages. We extract only NEW messages
// from the current request input and append them.
let new_input_messages =
crate::ai::bedrock::convert_request::extract_new_input_messages(&request);
let mut messages = params.bedrock_message_history.clone();
if !new_input_messages.is_empty() {
log::info!(
"[bedrock] Appending {} new input messages to history of {}",
new_input_messages.len(),
messages.len()
);
messages.extend(new_input_messages);
}
let system_prompt =
crate::ai::bedrock::convert_request::extract_system_prompt(&request);
let tools = crate::ai::bedrock::convert_request::extract_tools(&request);
@@ -249,17 +263,23 @@ pub async fn generate_multi_agent_output(
&model_id,
&task_id,
needs_create_task,
messages,
messages.clone(),
system_prompt,
tools,
64000,
None,
true,
diagnostic_logger,
params.bedrock_messages_sent.clone(),
)
.await
{
Ok(stream) => {
// Store the input messages we sent so the controller can
// persist them. The stream will append the assistant response.
if let Ok(mut sent) = params.bedrock_messages_sent.lock() {
*sent = messages;
}
let output_stream = stream.take_until(cancellation_rx);
return Ok(Box::pin(output_stream));
}
+2
View File
@@ -40,6 +40,8 @@ fn request_params_with_ask_user_question_enabled(ask_user_question_enabled: bool
root_task_id: None,
parent_agent_id: None,
agent_name: None,
bedrock_message_history: Vec::new(),
bedrock_messages_sent: std::sync::Arc::new(std::sync::Mutex::new(Vec::new())),
}
}
+20
View File
@@ -228,6 +228,12 @@ pub struct AIConversation {
/// event log. Used on restore to resume event delivery without
/// re-delivering already-processed events.
last_event_sequence: Option<i64>,
/// Accumulated message history for direct Bedrock conversations.
/// Contains the full ordered sequence of user messages, assistant responses,
/// tool calls, and tool results sent to/received from Bedrock across all
/// request cycles. This is the source of truth for what Bedrock sees.
bedrock_message_history: Vec<crate::ai::bedrock::convert::ConversationMessage>,
}
pub(crate) fn artifact_from_fork_proto(
@@ -278,6 +284,7 @@ impl AIConversation {
parent_conversation_id: None,
is_remote_child: false,
last_event_sequence: None,
bedrock_message_history: Vec::new(),
}
}
@@ -459,6 +466,7 @@ impl AIConversation {
parent_conversation_id,
is_remote_child: false,
last_event_sequence,
bedrock_message_history: Vec::new(),
})
}
@@ -466,6 +474,18 @@ impl AIConversation {
self.id
}
pub fn bedrock_message_history(&self) -> &[crate::ai::bedrock::convert::ConversationMessage] {
&self.bedrock_message_history
}
pub fn bedrock_message_history_mut(&mut self) -> &mut Vec<crate::ai::bedrock::convert::ConversationMessage> {
&mut self.bedrock_message_history
}
pub fn append_to_bedrock_history(&mut self, messages: Vec<crate::ai::bedrock::convert::ConversationMessage>) {
self.bedrock_message_history.extend(messages);
}
/// Assigns fresh exchange IDs to all exchanges in this conversation.
/// Used when forking conversations to avoid ID collisions with persisted blocks.
pub fn reassign_exchange_ids(&mut self) {