Guard empty Bedrock Converse tool results against empty text blocks - #55093
Guard empty Bedrock Converse tool results against empty text blocks#55093MaxFreedomPollard wants to merge 1 commit into
Conversation
|
Clean fix. Empty text blocks are a known Bedrock Converse constraint -- the existing One note: |
|
Thanks for the focused Bedrock fix. The premise remains valid on current The regression test is targeted and exercises the affected converter path. The current-main file blobs equal the PR diff preimages, so this should be salvageable as a clean cherry-pick. Automated hermes-sweeper review. |
d45a11c to
59d8596
Compare
convert_messages_to_converse built the toolResult text block straight from
the raw tool content, with no empty-content guard. A tool returning an empty
string produced a {"text": ""} block, which Bedrock Converse rejects with
"text content blocks must be non-empty". The empty block is baked into the
persisted history, so every replay and retry 400s identically and the
conversation wedges.
Apply the same empty-content substitution the user/assistant path already
uses in _convert_content_to_converse (issue NousResearch#9486) to the tool-result text.
59d8596 to
deb169c
Compare
Fixes #55092
convert_messages_to_conversebuilt thetoolResulttext block directly from the raw tool content with no empty-content guard:When a tool returns an empty string, this is a
{"text": ""}block. Bedrock Converse rejects empty text blocks (ValidationException: ... text content blocks must be non-empty). Because the block is part of the persisted history, every replay and retry fails identically, wedging the conversation._convert_content_to_conversealready guards this for user and assistant content (issue #9486), but the tool-result branch does not go through that helper and was left unguarded.Change
Test
test_empty_tool_result_gets_placeholderconverts a tool message with empty content and asserts the resultingtoolResulttext block is non-empty. It fails on the current code (the block is{"text": ""}) and passes with this change. The rest oftests/agent/test_bedrock_adapter.pycontinues to pass.