mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-15 22:22:12 +00:00
When the Responses API converts function_call and message output items into chat completion messages, they can become two consecutive assistant messages. The Bedrock Converse transformer merges these into one, but the merge preserves input order — so if function_call came first, the toolUse block ends up before the text block. Claude models (Sonnet 4, Haiku 3.5+) reject this ordering with: "tool_use ids were found without tool_result blocks immediately after" Add _sort_bedrock_assistant_content_blocks() that reorders content blocks within assistant messages: reasoningContent → text → toolUse. Applied in both sync and async Bedrock Converse transformation paths. Fixes #24361