bedrock: Fix empty tool input on project diagnostic in bedrock (#33369)
Bedrock [do not accept][1] `null` as a JSON value input for the tool call when called back. Instead of passing null, we will pass back an empty object, which is accepted by API Closes #33204 Release Notes: - Fixed project diagnostic tool call for bedrock [1]: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ToolUseBlock.html
This commit is contained in:
parent
1c6b4712a3
commit
c6ff58675f
1 changed files with 16 additions and 8 deletions
|
@ -648,14 +648,22 @@ pub fn into_bedrock(
|
||||||
|
|
||||||
Some(BedrockInnerContent::ReasoningContent(redacted))
|
Some(BedrockInnerContent::ReasoningContent(redacted))
|
||||||
}
|
}
|
||||||
MessageContent::ToolUse(tool_use) => BedrockToolUseBlock::builder()
|
MessageContent::ToolUse(tool_use) => {
|
||||||
.name(tool_use.name.to_string())
|
let input = if tool_use.input.is_null() {
|
||||||
.tool_use_id(tool_use.id.to_string())
|
// Bedrock API requires valid JsonValue, not null, for tool use input
|
||||||
.input(value_to_aws_document(&tool_use.input))
|
value_to_aws_document(&serde_json::json!({}))
|
||||||
.build()
|
} else {
|
||||||
.context("failed to build Bedrock tool use block")
|
value_to_aws_document(&tool_use.input)
|
||||||
.log_err()
|
};
|
||||||
.map(BedrockInnerContent::ToolUse),
|
BedrockToolUseBlock::builder()
|
||||||
|
.name(tool_use.name.to_string())
|
||||||
|
.tool_use_id(tool_use.id.to_string())
|
||||||
|
.input(input)
|
||||||
|
.build()
|
||||||
|
.context("failed to build Bedrock tool use block")
|
||||||
|
.log_err()
|
||||||
|
.map(BedrockInnerContent::ToolUse)
|
||||||
|
},
|
||||||
MessageContent::ToolResult(tool_result) => {
|
MessageContent::ToolResult(tool_result) => {
|
||||||
BedrockToolResultBlock::builder()
|
BedrockToolResultBlock::builder()
|
||||||
.tool_use_id(tool_result.tool_use_id.to_string())
|
.tool_use_id(tool_result.tool_use_id.to_string())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue