Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crates/goose/src/providers/formats/bedrock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ pub fn to_bedrock_tool_config(tools: &[Tool]) -> Result<bedrock::ToolConfigurati
}

pub fn to_bedrock_tool(tool: &Tool) -> Result<bedrock::Tool> {
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()));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure this is needed, but it doesn't seem to me like this is in the right place. if the todo tool somehow managed to declare itself without a type in the input schema, we should add a check to extension_manager to make sure all tools have that and make sure that whatever way we setup tools, does the right thing here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the exact same implementation here for the anthropic provider.

if input_schema.is_empty() {


Ok(bedrock::Tool::ToolSpec(
bedrock::ToolSpecification::builder()
.name(tool.name.to_string())
Expand All @@ -198,7 +206,7 @@ pub fn to_bedrock_tool(tool: &Tool) -> Result<bedrock::Tool> {
.unwrap_or_default(),
)
.input_schema(bedrock::ToolInputSchema::Json(to_bedrock_json(
&Value::Object(tool.input_schema.as_ref().clone()),
&Value::Object(input_schema),
)))
.build()?,
))
Expand Down
Loading