API Error: duplicate tool_use IDs in print mode (-p)
Resolved 💬 3 comments Opened Jan 24, 2026 by lalmeida Closed Jan 29, 2026
Description
Using claude -p (print/non-interactive mode) with prompts that may trigger internal tool planning results in API errors about duplicate tool IDs.
Environment
- Version: 2.1.19 (Claude Code)
- OS: macOS (Darwin 24.6.0)
- Shell: zsh
Steps to Reproduce
- Create a prompt file that references actions like "fetch" or "study" (which might trigger tool planning):
```
- study the document docs/ralph-loop-research.md
- Pick 1 reference that has not been marked as "STUDIED" yet and fetch it and study it
- Fix/enhance/augment the document as needed based on the reference.
...
```
- Run with print mode:
``bash``
claude -p < PROMPT.md
Expected Behavior
Command executes and returns output like interactive mode does.
Actual Behavior
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.1: `tool_use` ids must be unique"},"request_id":"req_011CXSemoH4u4kiKqUJDfKcW"}
Additional Context
- Simple prompts work fine (e.g., "Tell me a joke")
- The error occurs before any actual tool execution
- Disabling tools with
--tools ""gives a similar error:API Error: 400 due to tool use concurrency issues - Using
--mcp-config '{}'or--strict-mcp-configdoes not help - Interactive mode works fine with the same prompt content
This suggests the bug is in how -p mode constructs the API request when the prompt content might trigger tool-use planning, not in the MCP server initialization.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗