[BUG] API connection drops mid-response during long tool-use sessions
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?
During an extended Claude Code session involving multiple sequential tool calls (file edits, background shell commands, subagent orchestration), the connection to the Claude API dropped mid-response, cutting off the response with no visible error detail beyond "Connection closed mid-response." This has happened more than once during similar longer-running sessions.
Questions:
Is there a way to get more diagnostic detail when this occurs (e.g., a request ID or error code)?
Does Claude Code retry automatically on this class of error, or does it always require manual resume? If automatic retry isn't happening, why not — is it to avoid re-executing tool calls that may have already run?
How does token/usage billing handle a response that streamed partial output before the drop — is that output counted toward usage even though the user didn't get the completed result?
What Should Happen?
Automatic number of retries, detailed msg if all retries fail, discount any token/model usage before failure.
Error Messages/Logs
Steps to Reproduce
start a longer workflow (e.g. development, testing, feedback cycle)
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.204 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_