[BUG] Stream stall ~15-30s at start of new session with AskUserQuestion tool (claude-opus-4-7[1m], VS Code extension)

Resolved 💬 3 comments Opened May 14, 2026 by gkitayama Closed May 15, 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?

The stream freezes immediately at the start of a brand-new session (message_count: 2, no resume) whenever the model decides to invoke the AskUserQuestion tool. A stream_idle_partial warning fires after 15s with only bytesTotal=669 received — the response had barely started. The stall lasts 30.9s and resolves exactly when executePermissionRequestHooks called for tool: AskUserQuestion is logged.
In the meantime, the webview gives up at the 30s mark and emits sdk_stream_ended_no_result with had_error: true, marking the session as failed even though the assistant does eventually present the clarifying question to the user ~20s later.
This points to a missing keep-alive / heartbeat between "model decided to invoke AskUserQuestion" and "client received the tool invocation", rather than a real network or model-latency problem. The streaming watchdog appears to be too aggressive for this specific tool-use code path on claude-opus-4-7[1m].
It is not related to long sessions or large outputs — fully reproducible on a fresh session with message_count: 2 and bytesTotal=669.

What Should Happen?

The stream should remain alive during the transition between the model deciding to invoke AskUserQuestion and the question being presented in the UI. Specifically:

No stream_idle_partial warning should fire when the only thing happening is the internal switch from "model output" to "tool invocation" (in this case AskUserQuestion). The 15-second idle threshold is being tripped by what appears to be a missing keep-alive between tool_use_start and the next assistant token, not by actual model latency.
The webview should not receive sdk_stream_ended_no_result with had_error: true for what is effectively a normal tool-use flow. From the user's perspective, the assistant simply needed to ask a clarifying question — there was no error to report.
When the model chooses AskUserQuestion immediately after the first chunk (i.e. before producing visible content), the UI should transition smoothly to the question prompt without flagging the session as failed and without the 30+ second visible "freeze".

In short: the streaming watchdog appears to be too aggressive for the AskUserQuestion code path on claude-opus-4-7[1m]. Either the server should send heartbeats during that transition, or the client should not treat a pending tool-use of AskUserQuestion as an idle stream.

Error Messages/Logs

# New session launched (no resume)
14:07:36.832 [info] Launching Claude on channel: <channel-id>
14:07:36.833 [info] Spawning Claude with SDK query function - cwd: <home>,
                   permission mode: acceptEdits, version: 2.1.141

# User sends first real prompt (message_count: 2)
14:13:32.451 [DEBUG] [API REQUEST] /v1/messages
                    x-client-request-id=<request-id> source=sdk

# Stream starts normally
14:13:33.563 [DEBUG] Stream started - received first chunk

# 15 seconds later — stall warning, only 669 bytes received total
14:13:50.343 [WARN] [Stall] stream_idle_partial
                    lastChunkAgeMs=15000 bytesTotal=669 idleDeadlineMs=300000

# ~30 seconds after stream start — webview gives up and marks the session as errored
14:14:05.350 [info] sdk_stream_ended_no_result
                    {"had_error":true,"subagent_count":0,"message_count":2}
14:14:05.351 [info] update_session_state -> idle

# Stall is formally recorded
14:14:06.269 [WARN] Streaming stall detected: 30.9s gap between events (stall #1)

# The pending tool invocation finally fires — exactly when the stall ends
14:14:25.459 [DEBUG] executePermissionRequestHooks called for tool: AskUserQuestion
14:14:25.513 [WARN] Streaming completed with 1 stall(s), total stall time: 30.9s

Key correlations:

- The stall fires with bytesTotal=669. The response had barely started; this is not a long-output stall.
- The 30.9s gap ends exactly when executePermissionRequestHooks is called for AskUserQuestion. The gap matches the window between "model decided to invoke the tool" and "client received the tool invocation".
- sdk_stream_ended_no_result reports had_error: true for what is in fact a normal AskUserQuestion flow — the question is eventually rendered to the user ~20s after the session has already been marked as failed.
- message_count: 2 rules out long-session degradation.
- Network is healthy: [Bootstrap] Fetch ok, OAuth checks succeed, the API request is sent and the first chunk arrives within ~1s.
- Active model: claude-opus-4-7[1m]. Have not yet tested whether claude-opus-4-7 (non-1M) or Sonnet variants exhibit the same behavior on this code path.

Steps to Reproduce

  1. Open Claude Code in VS Code (extension v2.1.141, macOS).
  2. Make sure the active model is claude-opus-4-7[1m] and permission mode is acceptEdits.
  3. Start a new session (no resume).
  4. Send a prompt that is likely to make the model want to clarify before answering — e.g. paste two non-trivial pieces of input and ask for help "organizing" or "combining" them without specifying the exact desired output format. In my case: pasting two SQL queries with overlapping columns and asking the assistant to "help me order them so I can get the result".
  5. Observe the output channel:
  • Stream started - received first chunk fires at ~1s.
  • After 15s of idle: [WARN] [Stall] stream_idle_partial lastChunkAgeMs=15000 bytesTotal=669.
  • At ~30s: sdk_stream_ended_no_result {"had_error":true,"message_count":2}. UI marks the session as idle/errored.
  • At ~50s from prompt: executePermissionRequestHooks called for tool: AskUserQuestion. The clarifying question finally appears in the UI.
  • Final: [WARN] Streaming completed with 1 stall(s), total stall time: 30.9s.

Reproducible across new sessions on the same machine. Network is stable, no VPN/proxy, Claude Code is up to date.

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.131 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗