[BUG] Stream idle timeout / partial response during long tool-use turns on Claude Code Web (Opus 4.7, 1M and non-1M)

Status Open
Maintainer reply None cached
Activity 12 comments · opened Apr 17, 2026

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?

Environment

  • Platform: Claude Code Web (claude.ai/code)
  • Model(s) affected:
  • claude-opus-4-7[1m] (1M context) — reproducible
  • claude-opus-4-7 (standard context) — also reproducible after switching
  • OS: Linux sandbox (provided by the web harness)
  • Session type: long-running conversation with multiple tool calls

(Read / Bash / Grep), working in a git repo

  • Approx. transcript length when error first appeared: mid-session,

after several dozen tool calls and a few long assistant messages

Summary

During turns where the assistant is about to produce a long text output
(e.g. drafting a ~400-line markdown design doc after a few Read/Bash
tool calls), the stream terminates with:

API Error: Stream idle timeout - partial response received

The error is not triggered by the tool calls themselves — tool results
arrive normally. It consistently fires in the window between the last
tool result and the start (or middle) of the long text reply.

Reproduction

  1. Open a Claude Code Web session with Opus 4.7 (1M) on a non-trivial

repo (mine: ~several hundred markdown/py files, custom CLAUDE.md).

  1. Hold a long design discussion (tens of turns, many Read/Grep/Bash

calls, several multi-paragraph replies).

  1. Ask the assistant to draft a long markdown document (~400+ lines)

into a file, preceded by 1–2 exploratory tool calls.

  1. Observe Stream idle timeout - partial response received fire

after the tool calls complete but before / during the long write.

Retry attempts (even after slimming CLAUDE.md and switching from
claude-opus-4-7[1m] to plain claude-opus-4-7) reproduce the same error.

Actual behavior

Stream aborts mid-turn with an idle timeout; partial response is
discarded from the user's perspective and the Write tool call never
executes. The session is usable afterwards, but the same turn cannot
be completed — it fails repeatedly at roughly the same point.

Impact

  • Blocks any workflow that involves drafting a long file in a single

turn (design docs, protocol revisions, report packs).

  • Forces the user to manually split work into smaller chunks, losing

the model's ability to produce a coherent document in one pass.

  • Switching to the non-1M model does not resolve it, so it does not

appear to be strictly a 1M-context issue.

Workarounds tried (none fully effective)

  • Slimmed CLAUDE.md to reduce per-turn context overhead — still fails.
  • Switched claude-opus-4-7[1m]claude-opus-4-7 — still fails.
  • Starting a fresh session helps temporarily, but the error returns

after the session grows.

Additional context

  • The moments when errors occur most frequently are always during the combination of “multi‑turn conversations + about to generate long markdown.”
  • The web version cannot call /help, and there is no way to report issues directly from the client, so I am submitting this issue manually.
  • Session ID : https://claude.ai/code/session_014AtytC2zxPcAqaoj9LwcGi

Ask

  1. Is the idle timeout threshold tunable (e.g. via a server-side

setting or client flag)?

  1. Can the stream be kept alive with heartbeats during long

text generation so long Write tool calls don't get cut off?

  1. Is there a known interaction between 1M context and long

tail-end text streaming that we should avoid?

What Should Happen?

Expected behavior

The assistant should finish streaming the long reply, or at minimum
fail with a retriable error that preserves the in-progress Write/Edit
tool call.

Error Messages/Logs

API Error: Stream idle timeout - partial response received

Steps to Reproduce

  1. Open a Claude Code Web session with Opus 4.7 (1M) on a non-trivial

repo (mine: ~several hundred markdown/py files, custom CLAUDE.md).

  1. Hold a long design discussion (tens of turns, many Read/Grep/Bash

calls, several multi-paragraph replies).

  1. Ask the assistant to draft a long markdown document (~400+ lines)

into a file, preceded by 1–2 exploratory tool calls.

  1. Observe Stream idle timeout - partial response received fire

after the tool calls complete but before / during the long write.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Web (claude.ai/code), encountered on 2026-04-17

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

Additional observation (session 014AtytC2zxPcAqaoj9LwcGi, 2026-04-17):
Stream timeout fired during a ~210-line Edit call. The file write
itself completed successfully (verified via git status post-timeout);
only the client-side stream terminated. This suggests the issue is in
keep-alive / heartbeat between tool-result-accepted and next-assistant-
token, not in the tool execution itself.

View original on GitHub ↗

12 Comments

github-actions[bot] · 4 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/48974
  2. https://github.com/anthropics/claude-code/issues/48901
  3. https://github.com/anthropics/claude-code/issues/47555

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

trex0092 · 4 months ago

I am getting the same !!!

guillaume-defer · 4 months ago

Same here

MrVolcano · 4 months ago

Me too. Multiple times today

MrVolcano · 4 months ago

Why have all of the possible duplicated been closed as duplicates?

Where's the master bug record?

efecetinkaya21 · 4 months ago

Same failure mode:

  • Multi-turn planning session on a non-trivial private repo with a

custom CLAUDE.md, context at roughly 33% of the window.

  • Asked the assistant to rewrite a long markdown planning document

from scratch as a handoff for a new session.

  • Model performed 1–2 exploratory tool calls (file read, scan),

then began the Write call.

  • Stream terminated with `API Error: Stream idle timeout - partial

response received` before the write completed in the UI.

  • Retried 4 times across 2 separate sessions on the same repository

over 2 consecutive days. All failed at roughly the same point.
Reducing the scope of the write did not help.

  • Sessions remained alive, but the same turn could not be

completed — consistent with this being a keep-alive / heartbeat
gap between tool-result-accepted and the next assistant token,
not a model or tool-execution issue.

Workarounds suggested by support (manual chunking of the write,
raising CLAUDE_STREAM_IDLE_TIMEOUT_MS) do not apply to the Cloud
/ browser surface. Confirmation that a fix is in progress for this
specific surface would be appreciated.

cmungall · 4 months ago

I encounter this frequently, and it makes cc on the web almost unusable for me, as my workflow frequently involves large yaml file edits.

In case it's not obvious from the OP, attempting to coax it along by saying "try again" or similar is a great way to burn tokens to no avail. When this does happen, I say:

"Commit and push what you have so far. Do not create more yaml. No more writes. I don’t care if it doesn’t validate. Commit and push NOW"

Then create a PR so I have the option of taking over in a terminal session. After that I might try asking it it break down its edits into smaller units, which is often successful.

kainashville · 4 months ago

Having the same issues - it's driving me crazy. Sadly no one is actively trying to fix it and we have to find complex workarounds

AutumnsGrove · 4 months ago

Chiming in, this happens to me pretty much every single time I use Claude.ai/code. Makes the product pretty much unusable.

I have noticed that is a 4.7 opus thing though, as sonnet 4.6 and haiku 4.5 have no such issues. Truly, opus 4.7 is the regression king.

filipradetic-afk · 4 months ago

+1 — Same issue on Windows native Claude Code (npm-global, v2.1.121, Node v22 LTS, web login auth).

Reproducible on a large monorepo:

  • ~240 markdown files in docs/, 22 Docker microservices
  • Initially had 53k char CLAUDE.md → slimmed to 9.7k chars + split into 10 docs/ files
  • Slimming helped with simple queries (now work in seconds ✅)
  • BUT complex multi-tool tasks still fail with "API Error: Stream idle timeout - partial response received"

Specific pattern observed:

  • Simple read/search tasks: work fine
  • Complex tasks involving multiple file searches + analysis + extended thinking: fail consistently
  • Failure point: between tool result delivery and next assistant token (matches Pattern 2 from #25979)
  • Extended thinking ("xhigh effort") seems to amplify the issue
  • Task example that fails: "Failed to load preflight report" debugging across UI + agent code

Workarounds tested:

  • Slim CLAUDE.md ✅ helps simple tasks, ❌ doesn't fix complex
  • Reinstall Claude Code with Node v22 LTS ✅ helps initial connection, ❌ same timeout on long tasks
  • Antivirus disabled (Defender) ❌ no change
  • Network verified clean (Test-NetConnection OK, no SSL inspection)
  • Splitting tasks into smaller steps ✅ works as workaround

Question for maintainers:
Is CLAUDE_STREAM_IDLE_TIMEOUT_MS effective in practice for this scenario, or does the issue lie deeper in keep-alive between tool-result and next-token?

Happy to provide more session details if helpful.

SM2000 · 3 months ago

Adding data to this issue — we're seeing the same pattern via the Anthropic MCP Connector (mcp-client-2025-11-20 beta, not Claude Code, but the same streaming-stall signature).

Environment

  • Model: claude-opus-4-7 via Messages API with mcp_servers parameter
  • Beta header: mcp-client-2025-11-20
  • max_tokens: 2000, no extended thinking, stream=True
  • SDK: anthropic==0.96.0
  • Remote MCP server: HTTPS-exposed, OAuth-authenticated, backed by Snowflake
  • Network confirmed healthy (TCP/SSE pings flow throughout the stall)

Symptom

On approximately 4 out of 5 events in a controlled test harness, the streaming response stalls for ~300 seconds between content_block_stop type=mcp_tool_use and content_block_start type=mcp_tool_result. The pattern is reproducible and consistently ~300s ± 15s — strongly suggesting a fixed-duration timeout-and-recover rather than genuine processing time.

During the stall:

  • The TCP/SSE connection stays alive — ping events arrive at metronomic 30.000s ± 0.030s intervals for the entire gap (typically 10 pings)
  • thinking_delta_count = 0 (extended thinking is not enabled)
  • message_start_count = 1 (no silent reconnect)
  • Single tool calls on the same session, before and after the stalled batch, complete in 4.6–9.0 seconds — so the session itself is not degraded

What's different about the stalled calls

The stall reproduces specifically on parallel tool-call batches. When the model emits two or more mcp_tool_use blocks back-to-back (idx=4 and idx=5 in our trace, emitted 0.776s apart), the gateway holds all results and then flushes them in a single batch — both mcp_tool_result blocks (idx=6 and idx=7) arrive within 2ms of each other after the 300s stall.

Single-tool calls in the same stream complete normally:

  • idx=1 (single get_database_metadata): 9.0s round-trip ✓
  • idx=4 + idx=5 (parallel batch of 2 sql_exec): 301.9s round-trip
  • idx=9 (single sql_exec after the gap): 4.6s ✓
  • idx=12 (single sql_exec): 4.8s ✓

This matches the regression behavior reported in #14353, and the "proxy holds tool_results" pattern in #38437.

Three-source correlation isolates the stall upstream of the MCP server

We instrumented and cross-correlated three independent log sources for one stalled event (gap: 2026-05-20T17:26:41.464Z → 17:31:43.370Z, 301.9 seconds):

| Source | Activity during the 301.9s gap |
|--------|--------------------------------|
| Harness stream-event log | 10 pings, no content blocks, no errors |
| Snowflake ACCOUNT_USAGE.QUERY_HISTORY | 0.949s of actual query execution; idle for the remaining 298s |
| MCP server (assistant_tool_invocations) | Tool calls logged with normal duration_ms values [confirm fast durations before posting] |

The MCP server returned its responses promptly. Snowflake idled for 298 of the 302 seconds. The Anthropic gateway then held the batched results for the remaining time before streaming them back. The latency is unambiguously upstream of the MCP server.

Related issues

This appears to be the same root behavior described in:

  • #18028 — streaming stalls of 59–138s, network healthy, no errors
  • #44 (claude-agent-sdk-typescript) — 3+ minute pauses, no events, no pings during gap (we do see pings, but the stall mechanism looks similar)
  • #38437 — MCP proxy silently holding tool_results that the upstream MCP server has already returned
  • #49619 — author's diagnosis: "the issue is in keep-alive / heartbeat between tool-result-accepted and next-assistant-token, not in the tool execution itself" — matches our finding
  • #25979 — no client-side read timeout on streaming, so stalls can run to inactivity timeout
  • #14353 — parallel MCP tool calls regressed to sequential in v2.0.71

Reproduction

Anyone can repro with the MCP Connector beta:

  1. Configure mcp_servers to point to a remote MCP server that exposes 2+ fast tools
  2. Send a prompt that induces the model to issue 2+ parallel tool calls (e.g. "Look up X and Y at the same time")
  3. Stream the response and log content_block_start / content_block_stop events with timestamps
  4. Observe: in a fraction of runs (in our experiment ~80% of events on condition_b_snowflake and condition_c_semantic), the parallel batch stalls for ~300s before results arrive together

Happy to file this as a fresh issue if the maintainers prefer to keep #18028 scoped to the Claude Code CLI case rather than the MCP Connector API case — but they look like the same underlying mechanism.

befreak-info · 3 months ago

Workaround that worked for me:

Switching from Opus to Sonnet resolved the frequent hang/freeze issues I was experiencing.

Environment:

  • Platform: Claude Code CLI (desktop app on macOS)
  • Model before: claude-opus-4-7 (Max plan — auto-upgraded to claude-opus-4-7[1m])
  • Model after: claude-sonnet-4-6
  • Result: Hangs stopped completely after switching to Sonnet

Note:
On Max/Team plans, selecting Opus automatically upgrades to the 1M context version, which cannot be avoided through the /model picker alone. Setting CLAUDE_CODE_DISABLE_1M_CONTEXT=1 in ~/.claude/settings.json disables the auto-upgrade if you want to stay on Opus.

Hope this helps others experiencing similar issues.