API Error 400: tool_use ids must be unique - occurs consistently

Status Closed — not planned
Maintainer reply None cached
Activity 13 comments · opened Jan 27, 2026 · closed Apr 10, 2026

Description

When using Claude Code CLI with --print --output-format json, the API consistently returns a 400 error indicating duplicate tool_use IDs are being sent in the request.

Environment

  • Platform: macOS (Darwin 25.2.0)
  • Model: claude-opus-4-5-20251101

Error

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.1: `tool_use` ids must be unique"},"request_id":"req_011CXYMdu1vaiqC69uftUr9D"}

Observed Behavior

  • The CLI exits with code 0 (success)
  • JSON response has is_error: true but subtype: "success"
  • The error occurs consistently, not just occasionally
  • num_turns: 2 suggests it fails early in the conversation

Expected Behavior

  1. Tool use IDs should be unique in all API requests
  2. CLI should exit with non-zero code when API returns an error
  3. subtype should reflect the error state

Additional Context

The error messages.1.content.1: tool_use ids must be unique suggests tool_use blocks are being duplicated with the same ID somewhere in conversation serialization.

View original on GitHub ↗

13 Comments

sash · 7 months ago

Claude Code version: 2.1.20

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/21094
  2. https://github.com/anthropics/claude-code/issues/20751
  3. https://github.com/anthropics/claude-code/issues/20583

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

sash · 7 months ago

II don't think its either of those reports - might have the same root cause, but in my case im not using multi-turn and im not using stream-json -- my use case is a simple --print with --output-format=json (or even in interactive mode with no --print or --output-format at all)

sash · 7 months ago

one more thing I might add - the tool use actually goes though - the action in the tool use is performed and then the 400 happens

sash · 7 months ago

<img width="617" height="251" alt="Image" src="https://github.com/user-attachments/assets/d2ec1815-6e2a-49a6-ac65-b68af18c4efe" /> - this literally happened when I was reporting this very but and the comment was indeed posted ;)

sash · 7 months ago

FYI - it's not related to the VSCode extension - this happens both in CLI and in the VSCode plugin ( I saw some issues regarding the VSCode extension )

yusefhaddad · 6 months ago

Having the same Issue 2 weeks ago in my code sessions in web, app, and desktop, i cant find a solution, even claude say it is a bug when asked. I reduced the size of files like claude.md and PRD files, but this is consistent.

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.13.content.3: tool_use ids must be unique"},"request_id":"req_011CYLadytJmjDoyKkbJh8rD"}

joelbarmettlerUZH · 6 months ago

I have the same issue in claude code online. Did anyone find a way to recover from this error?

Indexed-Apogrypha · 6 months ago

Still experiencing this on v2.1.50 in interactive desktop mode on Windows 11.

Error

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.9.content.1: tool_use ids must be unique"}}

The error repeats on every retry (6+ times observed), creating an infinite loop since the corrupted message history is resent each time.

Trigger

  • Parallel tool calls where some fail with "Sibling tool call errored"
  • Specifically triggered by an Explore subagent performing broad filesystem searches from C:\ root
  • Multiple parallel Glob/Grep/Read calls are launched, several fail, and the resulting message construction produces duplicate tool_use IDs

Note on the v2.1.21 fix

The fix described as "Fixed API errors when resuming sessions that were interrupted during tool execution" appears to have only resolved the --print mode variant (confirmed by @waihaiwai in #20751). The interactive/desktop mode variant with parallel tool call failures is still present through v2.1.50.

Workaround

/clear or start a new session. The corrupted conversation history is what causes the retry loop — once cleared, the error stops. Setting the working directory to the actual project folder (not C:\) reduces the likelihood of triggering it.

BenjaminCes · 6 months ago

running /clear on Claude Web/Android doesn't work, endless loop.

ubidev · 5 months ago

As soon as I installed/started using claude desktop on windows, I started getting these random "API Error 400: tool_use ids must be unique" errors via remote-control to a claude-code tui install that never generates those errors

github-actions[bot] · 4 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 4 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.