claude-code - 💡(How to fix) Fix [BUG] API Error: Stream idle timeout — fires during long-running MCP tool calls [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#54616Fetched 2026-04-30 06:40:45
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
0
Timeline (top)
labeled ×5commented ×2subscribed ×1

API Error: Stream idle timeout - partial response received reliably triggers during autonomous agent runs that orchestrate many MCP tool calls, particularly when individual MCP calls take noticeable time to return. The stream goes idle while the model is waiting on an MCP response, the connection is killed mid-turn, and the partial output is unrecoverable.

Error Message

API Error: Stream idle timeout - partial response received reliably triggers during autonomous agent runs that orchestrate many MCP tool calls, particularly when individual MCP calls take noticeable time to return. The stream goes idle while the model is waiting on an MCP response, the connection is killed mid-turn, and the partial output is unrecoverable.

  • Error: API Error: Stream idle timeout - partial response received The error tends to fire when one MCP call is slow enough that the SSE stream sits silent past the idle threshold — even though the overall run is still making progress and the tool eventually returns.

Root Cause

API Error: Stream idle timeout - partial response received reliably triggers during autonomous agent runs that orchestrate many MCP tool calls, particularly when individual MCP calls take noticeable time to return. The stream goes idle while the model is waiting on an MCP response, the connection is killed mid-turn, and the partial output is unrecoverable.

RAW_BUFFERClick to expand / collapse

Summary

API Error: Stream idle timeout - partial response received reliably triggers during autonomous agent runs that orchestrate many MCP tool calls, particularly when individual MCP calls take noticeable time to return. The stream goes idle while the model is waiting on an MCP response, the connection is killed mid-turn, and the partial output is unrecoverable.

Symptoms

  • Error: API Error: Stream idle timeout - partial response received
  • Fires mid-run, after several successful tool batches have already completed
  • Most common during sequences that hit MCP servers with non-trivial response times (large file reads, transcript fetches, paginated listings across spaces, write-then-verify flows)
  • "Try again" sometimes resumes, but often the agent restarts earlier work and hits the same wall again
  • Anything in-flight at the time of the timeout (uncommitted edits, queued writes, follow-up reasoning) is lost

Workflow shape that triggers it

A long autonomous routine that:

  • Dynamically loads MCP tool schemas via ToolSearch
  • Issues parallel MCP read batches (vault/list/read, transcript fetches, community post listings, Slack lookups)
  • Interleaves writes with read-back verification
  • Runs for several minutes across a single turn

The error tends to fire when one MCP call is slow enough that the SSE stream sits silent past the idle threshold — even though the overall run is still making progress and the tool eventually returns.

Expected behavior

Either:

  • The idle timeout should not treat a stream as "idle" while a tool call is in flight, OR
  • The client should be able to recover/resume the partial response instead of aborting the entire turn and discarding work

Environment

  • Claude Code (CLI + Web both reproduce)
  • Model: Opus 4.7 (1M context)
  • Workload: autonomous routine driving multiple MCP servers in parallel

Related

Likely related / duplicate of: #46987, #47252, #47385, #47698, #47763, #47841, #52507. Filing as a fresh signal that the bug is still actively reproducing and is specifically correlated with slow MCP tool execution rather than long generation.

extent analysis

TL;DR

Increase the idle timeout threshold to accommodate slow MCP tool responses and prevent premature stream termination.

Guidance

  • Review the current idle timeout configuration and consider increasing the threshold to a value that allows for slower MCP tool responses.
  • Investigate the possibility of implementing a retry mechanism for partial responses, allowing the client to recover from timeouts without discarding work.
  • Analyze the workflow shape and MCP tool calls to identify opportunities for optimization, reducing the likelihood of slow responses and subsequent timeouts.
  • Consider implementing a queueing system for MCP tool calls, allowing the client to continue processing other tasks while waiting for slow responses.

Example

No code snippet is provided as the issue does not specify a particular codebase or implementation details.

Notes

The ideal idle timeout threshold will depend on the specific use case and performance characteristics of the MCP tools. Increasing the threshold may introduce additional latency, but can help prevent premature timeouts and work loss.

Recommendation

Apply a workaround by increasing the idle timeout threshold, as this is a more immediate and feasible solution than modifying the underlying client or server implementation. This change can help mitigate the issue until a more permanent fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Either:

  • The idle timeout should not treat a stream as "idle" while a tool call is in flight, OR
  • The client should be able to recover/resume the partial response instead of aborting the entire turn and discarding work

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING