mirror of
https://github.com/tiennm99/litellm.git
synced 2026-06-23 11:37:24 +00:00
07bffddbfa
Bedrock rejects requests when toolResult or toolUse blocks within a single message contain duplicate IDs. The Converse message transformer merges consecutive tool/assistant messages without checking for duplicate toolUseId values, causing BedrockException errors. Add _deduplicate_bedrock_content_blocks() — a generalized helper that removes duplicate blocks by ID, logs a warning for each dropped duplicate via verbose_logger, and preserves non-tool blocks (e.g. cachePoint). Apply it at all four merge sites (sync/async × toolResult/ toolUse). The Anthropic /messages path was fixed in PR #19324; this applies the equivalent fix to the Bedrock Converse path. Fixes #20048 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>