[BUG] API Error: Connection error followed by invalid_request_error on resume
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?
While working on building features, I experienced:
- Initial "API Error: Connection error" during active development
- After clicking "Resume", got repeated 400 errors with message:
"unexpected tool_use_id found in tool_result blocks: Each tool_result block must have a corresponding tool_use block in the previous message"
- Unable to recover - clicking Resume again produces the same error
- Conversation state appears corrupted and unusable
What Should Happen?
After a connection error, the Resume button should properly restore the conversation state and allow work to continue.
Error Messages/Logs
API Error: Connection error.
API Error: 400 {"type":"error","error":
{"type":"invalid_request_error","message":"messages.72.content.0: unexpected tool_use_id found in tool_result blocks: toolu_012aKnqYeft5qqEeNri9LXmu. Each tool_result block must have a corresponding tool_use block in the previous message."},"request_id":"req_011CUw42u1QBZ48HLXDDXzwFp"}
Steps to Reproduce
- Start working on a coding task in VSCode with Claude Code
- During active development (making tool calls), experience a "Connection error"
- Click the "Resume" button that appears
- Observe the 400 invalid_request_error
- Clicking "Resume" again produces the same error - conversation is unrecoverable
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
VSCode Extension (latest version as of 2025-11-08)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
Platform details: Darwin 25.1.0
Working in git repository at the time of error
The issue appears to be that after a connection error interrupts the conversation, the resume mechanism doesn't properly synchronize the tool_use and tool_result blocks, causing a protocol mismatch with the API.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗