[BUG] `API Error 400: tool_use ids must be unique` on second prompt after fresh login

Status Fixed / completed
Reported on v2.1.19
Maintainer reply None cached
Activity 3 comments · opened Jan 24, 2026 · closed Jan 24, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

After a fresh login (deleting ~/.claude.json), the first prompt to claude -p works correctly, but any subsequent prompt fails with an API error about duplicate tool_use IDs. Simple prompts like claude -p "hello" work.

What Should Happen?

Subsequent prompts should work without errors.

Error Messages/Logs

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

Steps to Reproduce

  1. Delete ~/.claude.json to reset state
  2. Run claude and complete login
  3. Run a prompt: claude -p "check what tasks you have" - works
  4. Run the same or any other prompt again: claude -p "check what tasks you have" - fails

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.19 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

  • The error indicates messages.1.content.3, suggesting the third tool_use block in the second message has a duplicate ID
  • This is 100% reproducible with the steps above
  • The issue persists across different prompt content

https://github.com/anthropics/claude-code/issues/20555 seems similar but the steps differ.

View original on GitHub ↗

3 Comments

github-actions[bot] · 8 months ago

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/20508
  2. https://github.com/anthropics/claude-code/issues/16340

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

kenfdev · 8 months ago
github-actions[bot] · 8 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.