tool_call_duplicationTier 1 · 70% confidence

ai-agents-tool-call-duplicatio-when-using-litellm-v1-responses-with-bedrock-claud-9c497c8b

agent: ai_agents

When does this happen?

IF When using LiteLLM /v1/responses with Bedrock Claude, sending the assistant tool call block (with the same toolUseId) together with the tool result causes a ValidationException due to duplicate toolUseId.

How others solved it

THEN In the response transformation logic, before reattaching cached tool calls from TOOL_CALLS_CACHE, check if the incoming payload already contains an assistant block with a matching tool_call_id. If found, skip the cache reattachment to avoid duplication. This prevents the Bedrock rejection.

# In litellm/responses/litellm_completion_transformation/transformation.py
# Before attaching cached tool calls:
for msg in messages:
    if msg.get('role') == 'assistant' and 'tool_calls' in msg:
        for tc in msg['tool_calls']:
            if tc['id'] in tool_call_cache:
                # Already present, skip caching
                continue

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics