From 34a222e3f2b95d8b4a43482b53c2cc957ecce26d Mon Sep 17 00:00:00 2001 From: Abhijay Jain Date: Sun, 18 Oct 2026 08:01:18 +0000 Subject: [PATCH] fix(bedrock): drop ActionRequired and ToolConfirmationRequest blocks instead of sending blank text (#12843) --- crates/goose/src/providers/formats/bedrock.rs | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/crates/goose/src/providers/formats/bedrock.rs b/crates/goose/src/providers/formats/bedrock.rs index 611ecf1b3..7abe5880c 100644 --- a/crates/goose/src/providers/formats/bedrock.rs +++ b/crates/goose/src/providers/formats/bedrock.rs @@ -165,6 +165,12 @@ pub fn to_bedrock_message_with_caching( .content .iter() .filter(|content| { + if matches!( + content, + MessageContent::ActionRequired(_) | MessageContent::ToolConfirmationRequest(_) + ) { + return false; + } if !thinking_is_stale { return true; } @@ -196,11 +202,11 @@ pub fn to_bedrock_message_with_caching( pub fn to_bedrock_message_content(content: &MessageContent) -> Result { Ok(match content { MessageContent::Text(text) => bedrock::ContentBlock::Text(text.text.to_string()), - MessageContent::ToolConfirmationRequest(_tool_confirmation_request) => { - bedrock::ContentBlock::Text("".to_string()) + MessageContent::ToolConfirmationRequest(_) => { + bail!("ToolConfirmationRequest should be filtered before Bedrock conversion") } - MessageContent::ActionRequired(_action_required) => { - bedrock::ContentBlock::Text("".to_string()) + MessageContent::ActionRequired(_) => { + bail!("ActionRequired should be filtered before Bedrock conversion") } MessageContent::Image(image) => { bedrock::ContentBlock::Image(to_bedrock_image(&image.data, &image.mime_type)?) @@ -1666,4 +1672,42 @@ mod tests { assert!(!bedrock_model_supports_temperature(&config)); assert_eq!(inference_config.temperature(), None); } + + #[test] + fn test_elicitation_message_becomes_empty() { + use crate::conversation::message::{ActionRequired, ActionRequiredData}; + use rmcp::model::Role; + + let elicitation_request = Message::new( + Role::Assistant, + Utc::now().timestamp(), + vec![MessageContent::ActionRequired(ActionRequired { + data: ActionRequiredData::Elicitation { + id: "elicit-1".to_string(), + message: "Choose something".to_string(), + requested_schema: serde_json::json!({}), + }, + })], + ); + + let elicitation_response = Message::new( + Role::User, + Utc::now().timestamp(), + vec![MessageContent::ActionRequired(ActionRequired { + data: ActionRequiredData::ElicitationResponse { + id: "elicit-1".to_string(), + user_data: serde_json::json!({"choice": "yes"}), + action: rmcp::model::ElicitationAction::Accept, + }, + })], + ); + + let request_result = + to_bedrock_message_with_caching(&elicitation_request, false, None).unwrap(); + let response_result = + to_bedrock_message_with_caching(&elicitation_response, false, None).unwrap(); + + assert!(request_result.content().is_empty()); + assert!(response_result.content().is_empty()); + } }