From 01e3959990b9a4a7c53dd178ebb6ea48d7c2b47a Mon Sep 17 00:00:00 2001 From: "alexyao2019@gmail.com" Date: Wed, 8 Oct 2025 11:53:02 +0000 Subject: [PATCH] Fix bedrock tool input schema The todo extension added in https://github.com/block/goose/pull/4868 causes errors with bedrock because bedrock expects an input schema. Without this fix, bedrock tool calls fail with Error: Server error: Failed to call Bedrock: ValidationException(ValidationException { message: Some("The value at toolConfig.tools.3.toolSpec.inputSchema.json.type must be one of the following: object."), meta: ErrorMetadata { code: Some("ValidationException"), message: Some("The value at toolConfig.tools.3.toolSpec.inputSchema.json.type must be one of the following: object."), extras: Some({"aws_request_id": "9813e4c5-607f-47fc-8a6a-4387ef28acb7"}) } }) Signed-off-by: alexyao2015 --- crates/goose/src/providers/formats/bedrock.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/goose/src/providers/formats/bedrock.rs b/crates/goose/src/providers/formats/bedrock.rs index bff8ff33c61d..8521ec514e72 100644 --- a/crates/goose/src/providers/formats/bedrock.rs +++ b/crates/goose/src/providers/formats/bedrock.rs @@ -188,6 +188,14 @@ pub fn to_bedrock_tool_config(tools: &[Tool]) -> Result Result { + let mut input_schema = tool.input_schema.as_ref().clone(); + + // If the schema doesn't have a "type" field, add it + // This is required by Bedrock + if !input_schema.contains_key("type") { + input_schema.insert("type".to_string(), Value::String("object".to_string())); + } + Ok(bedrock::Tool::ToolSpec( bedrock::ToolSpecification::builder() .name(tool.name.to_string()) @@ -198,7 +206,7 @@ pub fn to_bedrock_tool(tool: &Tool) -> Result { .unwrap_or_default(), ) .input_schema(bedrock::ToolInputSchema::Json(to_bedrock_json( - &Value::Object(tool.input_schema.as_ref().clone()), + &Value::Object(input_schema), ))) .build()?, ))