[BUG] API Error 400 "tool use concurrency issues" occurs only in print mode (-p), not in interactive mode

Status Open
Reported on v2.1.7
Maintainer reply None cached
Activity 5 comments · opened Jan 14, 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?

When running Claude Code in print mode (-p flag), even simple commands like echo hello fail with "API Error: 400 due to tool use concurrency issues."

This error does NOT occur in interactive mode - only in print/pipeable mode.

I'm aware that #11421 is still open for the same error message, but that issue describes a different scenario:

  • #11421: Occurs in interactive mode during parallel tool execution (3 Bash commands running simultaneously)
  • This issue: Occurs in print mode (-p) with simple prompts like echo hello, with NO parallel tool execution involved

Since this appears to be a print-mode-specific manifestation of the underlying issue (and print mode was not covered in #11421 or the many closed duplicates like #8763, #9433, #9103, #9002, #15261), I'm filing a new issue to track this specific case.

What Should Happen?

Claude Code should execute simple commands in print mode without API errors, just as it does in interactive mode.

Error Messages/Logs

~ via 🥟 v1.3.6
❯ claude -p --dangerously-skip-permissions "echo hello"
API Error: 400 due to tool use concurrency issues.

~ via 🥟 v1.3.6 took 9s
❯ claude -p "echo hello"
API Error: 400 due to tool use concurrency issues.

Steps to Reproduce

  1. Open terminal
  2. Run claude -p "echo hello" or claude -p --dangerously-skip-permissions "echo hello"
  3. Observe the 400 error

Note: The same prompt works fine in interactive mode (claude without -p).

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.7

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

  • This appears to be a print-mode-specific issue, as interactive mode works without problems
  • Multiple MCP servers are configured, but the error occurs even with minimal prompts
  • Related open issue: #11421 (different scenario - interactive mode with parallel tools)
  • Related closed issues: #8763, #9433, #9103, #9002, #15261

View original on GitHub ↗

5 Comments

ccolas · 7 months ago

Same issue here with v2.1.19.

Reproduction command

  claude -p "List the files in the current directory using Glob" \                                                                                                                 
    --output-format stream-json \                                                                                                                                                  
    --verbose \                                                                                                                                                                    
    --dangerously-skip-permissions \                                                                                                                                               
    --allowedTools Glob,Read

Error: "messages.1.content.1: tool_use ids must be unique"
Note: High cache_read_input_tokens values suggest prompt caching may be involved. Error occurs on first message of brand new sessions.
Env: Claude Code version (2.1.19), macOS

matchpoint-ai-bot · 7 months ago

Adding another repro + environment for print mode failure.

Environment

  • Claude Code: 2.1.19 (regression)
  • OS: Ubuntu 22.04.5 LTS (GNU/Linux 6.8.0-90-generic x86_64)
  • Node: v22.22.0

Behavior

  • Print mode (-p) tool use fails with: API 400 "tool_use ids must be unique"

Repro
claude --dangerously-skip-permissions -p "Use Read tool to read ./README.md" --output-format stream-json --verbose

Workaround

  • Downgraded to 2.1.17: print-mode tool use works again

Extra

  • Non-interactive claude doctor hangs at "Checking installation status..." here.
elpinguinofrio · 7 months ago

Same issue, but it seems related to calling our Claude instance with the -p flag while in planning mode.

vaughngit · 7 months ago

Still experiencing this on v2.1.19 (Jan 25, 2026). Error: messages.1.content.2: tool_use ids must be unique

Confirmed workaround: downgrade to v2.1.17 via npm install -g @anthropic-ai/claude-code@2.1.17 --force

Note: Homebrew installation overrides npm global, so brew uninstall claude-code may be needed first.

adamavenir · 7 months ago

Same issue. Thanks for filing.

I'm seeing this error in an orchestrator that programmatically spawns claude -p sessions in parallel (up to 20 concurrent processes). The workflow has two phases:

  • Phase 1: Launches ~20 parallel claude -p --session-id <uuid> processes
  • Phase 2: Resumes those sessions with claude -p --resume <session-id> (up to 10 parallel)

This worked reliably until the last few days. What changed:

  • Phase 1 sessions started hanging (not exiting after completion) due to another bug I encountered (just filed in #21099)
  • After those hung processes were killed, Phase 2 kicked off and immediately hit the 400 tool use concurrency error.
  • The --resume path may be reconstructing conversation histories from sessions that didn't terminate cleanly, which could produce the malformed tool_use without tool_result sequences the API rejects.

This is a different reproduction pattern from single-session usage — high parallelism + session resumption after unclean exits.