[BUG] Remote Control sessions need auto-compaction to prevent duplicate tool_use ID crash
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?
Remote Control sessions are particularly susceptible to the duplicate tool_use ID error (messages.N.content.1: tool_use ids must be unique) because they encourage long-running, often unattended sessions. Once this error occurs, the session is unrecoverable — every retry hits the same 400 error in a loop, and the user must abandon the session entirely.
The problem:
Remote Control's core use case is kicking off long tasks and monitoring from another device
Long conversations eventually trigger duplicate tool_use IDs in the message history
The API rejects these with a 400 error that loops infinitely
/compact exists but requires manual invocation — easy to forget, especially when working from a phone
There is no auto-recovery or way to salvage the session
What Should Happen?
Requested fix (any of these would help):
Auto-compact — automatically compress conversation history when approaching a message/token threshold, especially in Remote Control mode
Fix duplicate ID generation — ensure tool_use IDs are always unique regardless of conversation length
Auto-recovery — if a duplicate ID error is detected, automatically compact/truncate the history and retry instead of looping
Warning — at minimum, warn the user when the conversation is getting long and suggest running /compact
Environment:
macOS
Claude Code latest
Remote Control session via claude.ai/code
Error Messages/Logs
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.183.content.1: tool_use ids must be unique"},"request_id":"req_011CYbxH8hQvMT4PgFEK45AJ"}
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.183.content.1: tool_use ids must be unique"},"request_id":"req_011CYbxH9eDRswAVybwCaviQ"}
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.183.content.1: tool_use ids must be unique"},"request_id":"req_011CYbxHAUKuPmnDDXDjwANv"}
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.183.content.1: tool_use ids must be unique"},"request_id":"req_011CYbxHBPdsUNcqDPbjwFuG"}
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.183.content.1: tool_use ids must be unique"},"request_id":"req_011CYbxHCDzP8WQ6aT5CW3gU"}
Steps to Reproduce
Start claude remote-control
Connect from phone/browser and work through a long session (~100+ messages with many tool calls)
Eventually a tool call generates a duplicate ID
Session enters an unrecoverable 400 error loop
User input (e.g., typing "yes") also fails with the same error
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.63 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗