fix(bedrock): omit empty content for tool call responses

This commit is contained in:
milo 2026-05-22 22:09:23 +08:00
parent 8e21611702
commit c04d5e5ea9
2 changed files with 3 additions and 0 deletions

View file

@ -2250,6 +2250,8 @@ class AmazonConverseConfig(BaseConfig):
)
if filtered_tools:
chat_completion_message["tool_calls"] = filtered_tools
if chat_completion_message.get("content") == "":
chat_completion_message["content"] = None
## CALCULATING USAGE - bedrock returns usage in the headers
usage = self._transform_usage(

View file

@ -781,6 +781,7 @@ def test_transform_response_with_computer_use_tool():
encoding=None,
)
# Check that the tool call is present in the returned message
assert result.choices[0].message.content is None
assert result.choices[0].message.tool_calls is not None
assert len(result.choices[0].message.tool_calls) == 1
tool_call = result.choices[0].message.tool_calls[0]