Bedrock improvements. Getting back conversations, but losing context after tool calls

This commit is contained in:
Ryan Ward
2026-05-08 15:24:14 -05:00
parent 9e0af95953
commit fe105e0369
11 changed files with 117 additions and 24 deletions
+8
View File
@@ -1688,6 +1688,14 @@ impl AIBlock {
let status = self.model.status(ctx);
let is_udi_enabled = InputSettings::as_ref(ctx).is_universal_developer_input_enabled(ctx);
log::info!("[bedrock-debug] on_output_status_update: status={}", match &status {
AIBlockOutputStatus::Pending => "Pending".to_string(),
AIBlockOutputStatus::PartiallyReceived { output } => format!("PartiallyReceived(messages={})", output.get().messages.len()),
AIBlockOutputStatus::Complete { output } => format!("Complete(messages={})", output.get().messages.len()),
AIBlockOutputStatus::Cancelled { .. } => "Cancelled".to_string(),
AIBlockOutputStatus::Failed { .. } => "Failed".to_string(),
});
match status {
AIBlockOutputStatus::Pending => {
self.requested_action_ids.clear();
@@ -203,6 +203,7 @@ where
let exchange_id = self.exchange_id;
let conversation_id = self.conversation_id;
let history_model = BlocklistAIHistoryModel::handle(ctx);
log::info!("[bedrock-debug] on_updated_output: subscribing for exchange_id={:?}", exchange_id);
ctx.subscribe_to_model(&history_model, move |me, _, event, ctx| {
let BlocklistAIHistoryEvent::UpdatedStreamingExchange {
exchange_id: event_exchange_id,
@@ -213,6 +214,7 @@ where
return;
};
if *event_exchange_id == exchange_id {
log::info!("[bedrock-debug] on_updated_output: callback fired for matching exchange_id={:?}", exchange_id);
callback(me, ctx);
} else if *event_conversation_id == conversation_id {
ctx.notify();
+1
View File
@@ -826,6 +826,7 @@ impl View for AIBlock {
}
fn render(&self, app: &AppContext) -> Box<dyn Element> {
log::info!("[bedrock-debug] AIBlock::render() called");
// When the AI block is hidden, we don't need to render anything.
if self.is_hidden(app) {
return ConstrainedBox::new(Empty::new().finish())
+10 -1
View File
@@ -220,8 +220,17 @@ pub(super) fn render(props: Props, app: &AppContext) -> Box<dyn Element> {
| AIBlockOutputStatus::Complete { .. }
| AIBlockOutputStatus::Cancelled { .. }
| AIBlockOutputStatus::Failed { .. } => {
if let Some(output) = status.output_to_render() {
if let Some(output) = status.output_to_render() {
let output = output.get();
let total_text_len: usize = output.messages.iter().map(|m| match &m.message {
AIAgentOutputMessageType::Text(t) => t.sections.iter().map(|s| match s {
AIAgentTextSection::PlainText { text } => text.text().len(),
AIAgentTextSection::Code { code, .. } => code.len(),
_ => 0,
}).sum::<usize>(),
_ => 0,
}).sum();
log::info!("[bedrock-debug] render output: messages={}, total_text_len={}", output.messages.len(), total_text_len);
let is_complete = matches!(status, AIBlockOutputStatus::Complete { .. });
let is_output_for_static_prompt_suggestions =
props.model.contains_static_prompt_suggestion_input(app);
@@ -255,12 +255,26 @@ impl ResponseStream {
ctx: &mut ModelContext<Self>,
) {
if self.current_request_id.is_none_or(|id| id != request_id) {
log::info!("[bedrock-debug] handle_response_stream_event: stale request_id, dropping event");
return;
}
self.time_to_latest_event = Local::now().signed_duration_since(self.start_time);
match &event {
Ok(response_event) => {
let event_type_name = match &response_event.r#type {
Some(warp_multi_agent_api::response_event::Type::Init(_)) => "Init",
Some(warp_multi_agent_api::response_event::Type::ClientActions(a)) => {
log::info!("[bedrock-debug] ResponseStream received ClientActions with {} actions", a.actions.len());
"ClientActions"
}
Some(warp_multi_agent_api::response_event::Type::Finished(f)) => {
log::info!("[bedrock-debug] ResponseStream received Finished (reason={:?})", f.reason.as_ref().map(|r| format!("{r:?}")).unwrap_or("None".into()));
"Finished"
}
None => "None",
};
log::info!("[bedrock-debug] ResponseStream emitting event type={event_type_name}");
if let Some(event_type) = &response_event.r#type {
match event_type {
warp_multi_agent_api::response_event::Type::Init(init_event) => {
@@ -300,6 +314,7 @@ impl ResponseStream {
ctx.emit(ResponseStreamEvent::ReceivedEvent(Consumable::new(event)));
}
Err(e) => {
log::info!("[bedrock-debug] ResponseStream received ERROR: {e:?}");
// Store original error if this is the first error
if self.retry_count == 0 {
self.original_error = Some(format!("{e:?}"));
@@ -378,7 +393,9 @@ impl ResponseStream {
}
fn on_response_stream_complete(&mut self, request_id: Uuid, ctx: &mut ModelContext<Self>) {
log::info!("[bedrock-debug] on_response_stream_complete called (request_id={request_id})");
if self.current_request_id.is_none_or(|id| id != request_id) {
log::info!("[bedrock-debug] on_response_stream_complete: stale request_id, ignoring");
return;
}
ctx.emit(ResponseStreamEvent::AfterStreamFinished { cancellation: None });