[BUG] API Error: Connection error followed by invalid_request_error on resume

Resolved 💬 3 comments Opened Nov 8, 2025 by PastorEmma19 Closed Nov 12, 2025

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:

  1. Initial "API Error: Connection error" during active development
  2. 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"

  1. Unable to recover - clicking Resume again produces the same error
  2. 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

  1. Start working on a coding task in VSCode with Claude Code
  2. During active development (making tool calls), experience a "Connection error"
  3. Click the "Resume" button that appears
  4. Observe the 400 invalid_request_error
  5. 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.

View original on GitHub ↗

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