[BUG] API Error: "Connection lost mid-response" — server_error on tool-call emission
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?
<html>
<body>
<!--StartFragment--><html><head></head><body><h1>API Error: "Connection lost mid-response" — server_error on tool-call emission</h1>
<h2>Summary</h2>
<p>Turns fail intermittently with <code>API Error: Connection lost mid-response. The response above may be incomplete.</code> The failure occurs at the transition from assistant text to the first tool call — no <code>tool_use</code> block is ever emitted. Text-only turns are unaffected.</p>
<p><code>--output-format stream-json</code> shows the error is <strong>server-side</strong> (<code>"error":"server_error"</code>, <code>"terminal_reason":"api_error"</code>), not a dropped client connection. The user-facing message ("Check your internet connection, VPN, or proxy") is misleading and sent us several hours down the wrong diagnostic path.</p>
<h2>Environment</h2>
|
-- | --
Claude Code | 2.1.229
Claude Desktop | 1.30096.5 (Electron, win32 x64, Node 24.18.0)
OS | Windows
Model | claude-opus-5[1m] (1M context variant)
Reproduces in | CLI headless (-p) with desktop app closed, and desktop app
<h2>Suggested fixes</h2>
<ol>
<li><strong>Root cause:</strong> investigate the <code>server_error</code> at tool-call emission. The <code>[1m]</code> context variant may be relevant — worth checking whether this reproduces on the standard-context model.</li>
<li><strong>Error message:</strong> <code>server_error</code> should not surface to users as "Check your internet connection, VPN, or proxy." That wording caused hours of misdirected client-side debugging. Surfacing the request ID in the UI would also help enormously.</li>
<li><strong>Billing:</strong> failed turns are currently charged.</li>
</ol></body></html><!--EndFragment-->
</body>
</html>
What Should Happen?
fix the problem. intermitendt disconnect/connection failure
Error Messages/Logs
Steps to Reproduce
all is in the bug report
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
in the bug report
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗