[Bug] Frequent mid-stream disconnections in subagent streaming responses (44% failure rate)
Bug Description
Report: frequent mid-stream disconnections of Claude Code subagents
Prepared for Anthropic support · 28 July 2026 · account: jim@blockstack.ing
Environment
- Claude Code CLI on macOS (Darwin 25.5.0), Apple Silicon
- One long-running interactive session driving a fleet of background subagents
(Agent tool) on a single project — typically 5–12 in flight at once
- Main agent model:
claude-fable-5; subagents mostly Opus - Session ID:
session_01Kc4fKzebCZJwdEQkV1Ep1q
(project dir -Users-jim-dev-landOfGoodPlaces,
session 6a345fce-78f2-4acc-baa9-954a8dc31bfa)
The numbers (from this session's subagent transcripts, 26–28 July)
Counted directly from the 205 subagent transcript files under the session'stasks/ directory:
| Metric | Count |
| --- | --- |
| Subagent runs total (26–28 July) | 205 |
| Runs with ≥1 mid-stream failure | 90 (44%) |
| — of which "Response stalled mid-stream" | 61 files, 117 events |
| — of which "Connection closed mid-response" | 48 files, 81 events |
| "529 Overloaded" errors | 2 files, 4 events |
| "Internal server error" | 7 events |
The two dominant failure strings, verbatim from the transcripts:
API Error: Response stalled mid-stream. The response above may be incomplete.
API Error: Connection closed mid-response. The response above may be incomplete.
Roughly 198 mid-stream failure events across 2½ days — an average of nearly
one per subagent run. Failures occur at all hours (runs span 104 on the 26th,
83 on the 27th, 18 so far on the 28th) and are not correlated with any local
resource pressure we can see (the machine also runs vite dev servers and a
browser, but failures happen equally with those idle).
Terminal failures (agent killed, not recovered)
Most events are retried by the harness, but some are terminal. Example from
the task ledger, 27 July 07:52 local:
Task a010d5dc35b3511a9 (status: failed)
Delta: Agent stalled: no progress for 600s (stream watchdog did not recover)
i.e. the stream watchdog detected a stall, attempted recovery, and gave up
after 600 s, killing the agent mid-task. A long-running implementation agent
(the "selection system" build) also stalled once and had to be manually
resumed with SendMessage.
Operational impact
- Work in a subagent dies with it: we have repeatedly found agents that had a
feature finished and building green but the run died before it was pushed.
We now run an hourly cron sweep specifically to harvest stranded work.
- We adopted project rules purely as mitigation: commit as soon as anything
compiles (never one big commit at the end), and every agent maintains a
HANDOFF-<task>.md so a replacement can take over at zero warning.
- Multi-step tool sequences (e.g. browser QA via MCP) are the most costly
place to die — a replacement agent has to redo the whole verification.
What would help
- Any known cause/remediation for the high rate of `Response stalled
mid-stream / Connection closed mid-response` on long streaming
responses — 44% of runs affected feels network- or gateway-shaped, not
model-shaped.
- A stream watchdog that resumes rather than fails terminally after 600 s
(or a configurable retry-on-stall for background agents).
- If useful, we can supply specific timestamps and transcript excerpts —
all 205 transcripts are retained locally under the session's
subagents/ directory.
Environment Info
- Platform: darwin
- Terminal: tmux
- Version: 2.1.220
- Feedback ID: 717d6f5d-9512-435a-9981-9f38af8e53ac
Errors
[{"error":"Error: EINVAL: invalid argument, open '/private/tmp/claude-501/-Users-jim-dev-landOfGoodPlaces/6a345fce-78f2-4acc-baa9-954a8dc31bfa/tasks/a647f5e7be3768d80.output'\n at async <anonymous> (node:fs/promises:173:56)\n at async ztt (/$bunfs/root/src/entrypoints/cli.js:85:5264)\n at async HZi (/$bunfs/root/src/entrypoints/cli.js:625:1427)\n at async Edd (/$bunfs/root/src/entrypoints/cli.js:3861:5146)\n at async uFy (/$bunfs/root/src/entrypoints/cli.js:19878:4688)\n at async Ky (/$bunfs/root/src/entrypoints/cli.js:19870:5594)","timestamp":"2026-07-26T10:25:14.013Z"},{"error":"Error: EINVAL: invalid argument, open '/private/tmp/claude-501/-Users-jim-dev-landOfGoodPlaces/6a345fce-78f2-4acc-baa9-954a8dc31bfa/tasks/a00e2edb12f9452fd.output'\n at async <anonymous> (node:fs/promises:173:56)\n at async ztt (/$bunfs/root/src/entrypoints/cli.js:85:5264)\n at async HZi (/$bunfs/root/src/entrypoints/cli.js:625:1427)\n at async Edd (/$bunfs/root/src/entrypoints/cli.js:3861:5146)\n at async uFy (/$bunfs/root/src/entrypoints/cli.js:19878:4688)\n at async Ky (/$bunfs/root/src/entrypoints/cli.js:19870:5594)","timestamp":"2026-07-27T20:28:58.925Z"}]