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

Resolved 💬 3 comments Opened Jan 24, 2026 by kenfdev 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 ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗