Skip to content

Claude agent host (1.146): a turn's response is silently dropped when the session is rebuilt twice before the turn, and the chat hangs on "This is taking a little longer than usual" #347909

Open

Agent suggestions

Public preview

Description

@GNeras

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.146.0 (6904719), x64
  • OS Version: Ubuntu 25.10 (Linux 6.17)
  • Harness: Claude agent host (Agents window), Claude Code SDK 2.1.304, model claude-opus-5-5
  • Worked in 1.145.2 on the same machine and in the same kind of work

Disclosure: I investigated this with an AI coding agent (Claude Code). It went through my local agenthost.log files and Claude transcripts, and compared the 1.145.2 and 1.146.0 source. The log excerpts and counts come from my machine. The "Likely cause" section is the agent's reading of the source, and it hasn't been checked with a debugger.

What happens

Since updating to 1.146.0, Claude turns in the agent host sometimes never finish. The chat shows only "This is taking a little longer than usual". The Claude transcript shows the model answered and ended the turn (stop_reason: end_turn), but VS Code never shows the answer and never logs result for sdkUuid=… for that turn. If I stop the turn and ask, the agent says it already replied.

Pattern: two rebuilds before the turn

Every lost turn started with two rebuild isResume=true lines before queue yielded:

14:03:58.057 [Claude] session 89ac…: rebinding before turn request_ec2a… for changed client customizations
14:03:58.150 [error] [ClaudeSdkPipeline:89ac…] _processMessages crashed: Error: Claude SDK stream ended without a result message
14:03:59.599 [Claude] session 89ac…: rebuild isResume=true agent=(none)
14:04:09.551 [Claude] session 89ac…: rebuild isResume=true agent=(none)      ← second rebuild, same turn
14:04:11.255 [Claude:89ac…] queue yielded sdkUuid=request_ec2a… turnId=request_ec2a…
                                                                             ← no "result for sdkUuid=request_ec2a…", ever

The transcript for the same conversation has the user prompt at 14:04:11 and the assistant's end_turn reply at 14:04:20.

I classified every turn in my agenthost.log files by how many rebuilds came before its queue yielded:

Version Turns with 0 / 1 rebuild Turns with 2 rebuilds Of those, never got a result
1.145.2 (3 VS Code sessions, Nov 9–10) 61 6 0
1.146.0 (Nov 11–12) 50 4 2

The rebuilds themselves aren't new. They happen at about the same rate in 1.145.2. They just weren't attributed in the log before #346442. Neither is the stream ended without a result message error: 43 times in 1.145.2 across those three sessions. What's new is that a turn after a double rebuild can lose its response.

Likely cause (from reading the 1.146.0 source)

#345929 (agentHost: harden Claude cancellation and lifecycle recovery, 599658f) changed ClaudeSdkPipeline._processMessages to ignore messages from a query that is no longer the current one:

for await (const message of query) {
    if (signal.aborted || this._needsRebind || this._query !== query) {
        continue;                                   // previously: only `if (aborted) throw`
    }
    …
    if (message.type === 'result' && !signal.aborted && !this._needsRebind && this._query === query) {
        const completed = this._queue.settleHead();  // previously: any `result` settled the head

A sequence that seems to fit the logs:

  1. send() sees a rebind reason and calls _rebindForSyncedState() → _rebindQuery('restart'), which awaits a ~10 s rematerialize.
  2. The old query's stream ends first, while it is still this._query. The post-loop guard throws stream ended without a result message, and the catch sets _needsRebind = true.
  3. While the restart rebuild is still starting up, another caller goes through _ensureQueryBound(), sees _needsRebind and starts a second _rebindQuery('recover') concurrently. Candidates: snapshotResolvedCustomizations, reconcileMcpServerEnablement, start/stopMcpServer, reloadPlugins.
  4. Both rebuilds bind a query on the same prompt-queue iterable. The send continues after the first one and enqueues the prompt. The first query consumes it, but the second rebuild finishes later and becomes this._query.
  5. The first query's assistant messages and result now hit this._query !== query and are dropped. Its consumer pass ends quietly (if (this._query !== query) return;). The new query never receives the prompt, so the turn's deferred never settles.

In 1.145.2, step 5 didn't drop anything. The loop processed every message until abort, which would explain why the same double-rebuild sequence completed every time there.

I haven't confirmed step 3 with a debugger. The logs only show two rebuild lines about 10 s apart. Separately, _rebindQuery has no guard against running concurrently with itself.

A second hang, possibly related

In the same session, a turn hung after only one rebuild. Claude made two parallel client tool calls: mcp__client__runPlaywrightCode (toolu_01GPmE…) and mcp__client__screenshotPage (toolu_01MVPa…). The agent host logged the client completion for both (Forwarding client tool completion: source=client-dispatch). Only toolu_01MVPa… reached the transcript as a tool_result, so the SDK waits forever for the other one. I don't have an explanation for this one from the source.

14:59:05.873 [AgentSideEffects] Forwarding client tool completion: source=client-dispatch, … toolCallId=toolu_01GPmE…
14:59:06.006 [AgentSideEffects] Forwarding client tool completion: source=client-dispatch, … toolCallId=toolu_01MVPa…
14:59:06.026 [AgentSideEffects] Forwarding client tool completion: source=server-envelope, … toolCallId=toolu_01MVPa…

Expected

  • A rebuild before a turn shouldn't drop the turn's response.
  • If a turn's prompt was consumed by a query that is then discarded, the turn should fail or be retried, not hang indefinitely.

Notes

Activity

  1. jhulford commented on Nov 12, 2026

    @jhulford

    I'm having similar issues and they're happening very frequently since updating to the latest version - enough that I'm going to have to revert because the lost messages and work tracking in the session stream are killing my productivity. I set an opus agent free to try and help add to this issue to help resolve it.

    Start agent report:

    Same symptoms here on macOS (1.146.0, Agents window). On Nov 12, 22 "rebinding before turn … for changed client customizations" lines appeared across 5 Claude sessions between 08:42 and 12:27. Most of them were followed by _processMessages crashed: Error: Claude SDK stream ended without a result message and often a second rebuild. Nothing in the synced customization bundle changed after 09:16 (same pluginDir, same nonce), and no user, workspace or ~/.claude customization file changed either.

    Where "client customizations" comes from

    This answers the question in the Notes section. It's neither the synced list nor SessionMcpDiscovery. It's any root/configChanged action. Every Claude session subscribes to the root config change event and marks its customizations diff dirty, without looking at what changed:

    // session constructor
    this._register(this._configurationService.onDidRootConfigChange(() => this.markMcpConfigurationDirty())),
    …
    markMcpConfigurationDirty() { this._pipeline && this.clientCustomizationsDiff.markDirty() }
    
    // config service
    onDidEmitEnvelope(g => { if (g.action.type === "root/configChanged") { …; this._onDidRootConfigChange.fire() } })

    hasDifferenceFrom() is this._dirty || !samePaths(...), so _getRebindReason() reports "client customizations" and the next turn on every live session rebuilds.

    What sends root/configChanged when nothing changed

    1. The Codex continuation service in the sessions window (verified in code). On window focus and on any settings change, rate-limited to once per 5 minutes, it dispatches a fresh random value. The value is new every time, so the root-config equality short-circuit never catches it:
      refresh() {
        !this._host.hasFocus || !this._enabled() || Date.now() - this._lastRefresh < _Qt ||
        (this._lastRefresh = Date.now(),
         this._agentHost.dispatch(yc, { type: "root/configChanged", config: { ["vscode.codexAccount.refreshRequest"]: He() } }))
      }   // _Qt = 300*1e3
      The host then clears the key, which emits a second root/configChanged. This runs with chat.agentHost.codexAgent.enabled at its default (true), even when Codex is never used. Switching back to the Agents window is therefore enough to make every Claude session rebuild on its next turn.
    2. The host's periodic Claude model refresh, about every 30 minutes (inferred). It ends with _sdkSetupChannel.refresh() → publishRootTransientValues(...) → root/configChanged. About 7 of my 22 rebinds came on the first turn after a "Models refreshed" log line.
    3. The hourly experiment refetch (inferred). It sends root/configChanged with the assignment context and is gated by workbench.enableExperiments.

    Two more lost-turn variants

    The response was lost from the conversation history, in two ways:

    • With a synthetic entry:
      • When the rebuild crashed, the transcript got a synthetic assistant entry "No response requested." (timestamped about 1 s after the user message). It has the same parentUuid as the real turn.
      • The real turn then ran to completion (19 minutes of tool calls and a final reply, all present in the .jsonl), but the UI never showed it.
      • The next user message was parented on the synthetic entry, which orphaned the whole real turn: neither the user nor the model saw it in later context. That happened three times in one session.
    • Without a synthetic entry: after another crashed rebuild, the turn completed and was shown. But the next user message was parented on the message before that turn, which orphaned both the request and the reply.

    Suggested fixes

    • In markMcpConfigurationDirty, mark dirty only when MCP-relevant root keys actually change. Ignore transient keys such as vscode.codexAccount.refreshRequest and the SDK setup status.
    • Have SessionClientCustomizationsDiff compare against what was last applied, as the tools diff does, rather than a sticky _dirty flag.
    • Don't fire the Codex refreshRequest when the Codex agent isn't in use.

    Workaround I've just applied (not yet confirmed): "chat.agentHost.codexAgent.enabled": false. It should remove the focus-triggered rebinds. The 30-minute refresh would still trigger some.

  2. jay-lu-simplisafe commented on Nov 13, 2026

    @jay-lu-simplisafe

    Same symptom on macOS (Apple silicon), with a comparison between 1.146.0 and 1.145.0 on one machine.

    • VS Code 1.146.0 (6904719…) and 1.145.0 (a717861…), macOS 26.7.1, arm64
    • Claude agent host, claude-opus-5-5. The Claude Code SDK also differed between the two runs (2.1.308 on 1.145.0; 2.1.304 or newer on 1.146.0), so this isn't a single-variable comparison.
    • "No result" below means no result for sdkUuid=… line in agenthost.log for that turn. I haven't checked each turn against its transcript.
    Version Turns Turns with 2 rebuilds before queue yielded Of those, no result
    1.146.0 (9 sessions, Nov 12) 25 11 9
    1.145.0 (1 session, Nov 13) 5 2 0

    The 1.145.0 sample is small (2 double-rebuild turns, both delivered). Together with the 1.145.2 numbers in the description (0 of 6), that is 0 of 8 on 1.145.x against 9 of 11 on 1.146.0 here, though the two 1.145 samples come from different machines.

    A third rebind reason. One turn logged rebinding before turn … for changed resume point (all the others say changed client customizations). It had two rebuilds, no _processMessages crashed line, and its reply was delivered.

    History fork on 1.145.0. After a double rebuild on 1.145.0 (rebuild → _processMessages crashed → rebuild), the reply was shown. The next message, sent about 2 minutes after that reply with no rebuild before it, then forked the session history:

    • The transcript has a user message at 12:40:22 and its reply (22 records). The next user message, at 12:44:09, has the same parentUuid as the 12:40:22 message.
    • None of the 22 records from the 12:40 exchange are in the 12:44:09 message's ancestry.
    • The assistant's first words in reply to the 12:44 message were that there was an earlier exchange in the transcript that it didn't have in context.

    This is the same orphaning that jhulford describes above, but on 1.145.0, where the reply itself was delivered. I have seen it once, not as a pattern.

    Not tested: --disable-extensions, Insiders.

    I investigated this with an AI coding agent (Claude Code). It read my local agenthost.log files and Claude transcripts. The counts come from my machine, and session IDs are shortened.

  3. zhaojiale2021 commented on Nov 17, 2026

    @zhaojiale2021

    Same loss confirmed on Windows with a non-Anthropic relay model (1.147.0-insider)

    Adding a data point from a Windows machine, since the report and the other comments are mostly macOS/Linux.

    Environment

    • VS Code 1.147.0-insider, Windows 10 Pro 19045
    • Harness: Claude agent host (local harness, not the Copilot harness)
    • Model: custom alias routed through an Anthropic-compatible relay (ccs-claude-…--deepseek-flash[1m]). The SDK logs [claude-code:unrecognized_model] for this alias, but turns do run and stream normally otherwise.
    • Also reproduces for remote (SSH) sessions in the same window.

    Symptom

    After a turn finishes, the session never leaves the "Working" group in the agent sessions sidebar, and the chat pane keeps showing "This is taking a little longer than usual".

    Log evidence (agenthost.log, local time UTC+8, session 697e0d33…)

    Turn 1 — trigger changed client customizations:

    09:32:09.197 [info]  [Claude] session 697e0d33…: rebinding before turn request_a7c76474… for changed client customizations
    09:32:27.309 [warning] [Claude:697e0d33…] snapshotResolvedCustomizations failed Query closed before response received
    09:32:27.310 [error] [ClaudeSdkPipeline:697e0d33…] _processMessages crashed: Error: Claude SDK stream ended without a result message
    09:32:27.383 [info]  [Claude] session 697e0d33…: rebuild isResume=true agent=(none)
    09:32:29.589 [info]  [Claude:697e0d33…] queue yielded sdkUuid=request_a7c76474… turnId=request_a7c76474…
                          ← no "result for sdkUuid=request_a7c76474…" ever
    

    Turn 2 — trigger changed client tools (no customization files were edited between these turns):

    09:56:20.583 [info]  [Claude] session 697e0d33…: rebinding before turn request_fbd23645… for changed client tools
    09:56:39.515 [warning] [Claude:697e0d33…] snapshotResolvedCustomizations failed Query closed before response received
    09:56:39.516 [error] [ClaudeSdkPipeline:697e0d33…] _processMessages crashed: Error: Claude SDK stream ended without a result message
    09:56:39.610 [info]  [Claude] session 697e0d33…: rebuild isResume=true agent=(none)
    09:56:42.500 [info]  [Claude:697e0d33…] queue yielded sdkUuid=request_fbd23645… turnId=request_fbd23645…
                          ← again no "result for sdkUuid"
    

    Across this window there were 19 queue yielded lines and 16 result for sdkUuid lines, with the two misses above.

    Both turns did complete on disk. From ~/.claude/projects/d--<redacted>/697e0d33….jsonl:

    • assistant message with "stop_reason":"end_turn" at 01:33:46Z (09:33:46 local) — ~77 s after the first queue yielded
    • assistant message with "stop_reason":"end_turn" at 01:58:48Z (09:58:48 local) — ~126 s after the second queue yielded

    So both rebind reasons named in this issue reproduce on Windows/1.147.0-insider. In this log the _processMessages crashed … stream ended without a result message line is always immediately preceded by a failing snapshotResolvedCustomizations, in case that is a useful extra signal for the rebuild race.

    Related: #333799 (turn completes, UI stays in progress) and #327639 (per-session status in the sidebar freezes and never flips to done).

  4. zhaojiale2021 commented on Nov 17, 2026

    @zhaojiale2021

    Update: the lost turn becomes the permanent queue head — every later message is sent into it as steering

    Follow-up on my earlier comment, same machine and same session (697e0d33…, VS Code 1.147.0-insider, Windows).

    The turn that loses its result in the rebind race does not only hang itself. It stays open at the head of the prompt queue for the lifetime of the agent-host process, and every subsequent user message is enqueued as a steering message on that dead turn instead of starting a new turn:

    09:56:42.500  queue yielded sdkUuid=request_fbd23645… turnId=request_fbd23645…
                  ← no "result for sdkUuid=request_fbd23645" ever
    
    10:24:19.801  queue yielded sdkUuid=request_d4855939… turnId=request_fbd23645… steeringPendingId=request_d4855939…
    10:25:32.617  result for sdkUuid=request_d4855939…
    10:39:17.402  queue yielded sdkUuid=request_1d633646… turnId=request_fbd23645… steeringPendingId=request_1d633646…
    10:41:15.154  queue yielded sdkUuid=request_d85fb0ac… turnId=request_fbd23645…
    11:55:57.388  queue yielded sdkUuid=request_13e2da8f… turnId=request_fbd23645…
    13:02:00.202  … turnId=request_fbd23645…
    13:33:31.219  … turnId=request_fbd23645…
    13:47:01.859  … turnId=request_fbd23645…
    14:05:14.038  … turnId=request_fbd23645…
    14:08:22.925  … turnId=request_fbd23645…
    14:15:29.370  … turnId=request_fbd23645…
    14:48:36.674  … turnId=request_fbd23645…
    15:05:03.803  … turnId=request_fbd23645…
    

    That is 12 user messages over about five hours. Every one of them was answered — each steering id gets its own result for sdkUuid — but turnId never changes back to a fresh turn. The session-level status therefore never leaves "working": the session stays in the Working group of the sidebar and the chat pane keeps showing the working indicator indefinitely, even though the visible last answer is complete. Nothing in the UI clears it.

    Two details that may help the investigation:

    1. The wedge is scoped to the agent-host process. A lost turn from before a host restart did not wedge later turns: 09:32:29 turn request_a7c76474 lost its result, the host process was restarted (hostProcessAgeMs≈21506066 at 15:45 → process started around 09:45), and 09:47:58 turn request_4f10273f then ran as a normal new turn and completed. The 09:56 loss in the new process wedged everything after it. This is consistent with the reports that Developer: Reload Window does not clear the state but a full app restart does.

    2. A client-side truncate can reset the queue head. In a second session (b11477e8…) I saw the same loss (15:53:47 request_5869dca3, no result), then a steering message (15:55:26), then truncateChat kept [0..request_b2a5d1fd…] at 15:56:24, after which a fresh turn started normally. If that truncate/retry path can be exposed as a recovery action in the UI, it would be a much cheaper workaround than restarting the whole app.

    Still present on 1.147.0-insider; the two turns in this session that lost their result are the same rebind-triggered ones from my previous comment (changed client customizations and changed client tools).

  5. zhaojiale2021 commented on Nov 17, 2026

    @zhaojiale2021

    Recovery: Restart Local Agent Host works, but there is no equivalent for remote agent hosts

    Following up on the queue-head finding. Confirmed on the same setup (VS Code 1.147.0-insider, Windows client):

    • Developer: Restart Local Agent Host recovers a wedged local session. It restarts the agent-host process, the lost turn is dropped, and the session comes back from the transcript showing as finished. That is consistent with the wedge being process-scoped, and it is a much better workaround than restarting the whole app.
    • Remote agent hosts have no equivalent. I checked the command registry in the installed build — the only command is workbench.action.chat.restartLocalAgentHost ("Restart Local Agent Host"). For remote hosts there is only "Reconnect"/"Trigger Reconnect", which re-attaches to the same host process and therefore does not clear the stuck queue head. The session stays in "working" forever.

    Manual workaround for remote today:

    • SSH / WSL / Dev Container agents share the remote server process, so the only practical reset is Remote-SSH: Kill VS Code Server on Host (or killing the remote agent-host process directly, agentHostMain / --type=agentHost) and reconnecting. That kills remote terminals and background tasks as collateral.
    • This also means a remote session that hits the bug is unrecoverable from the UI without that heavy step.

    Suggestions for whoever picks this up:

    1. Expose the same restart action for remote/dev-container/WSL agent hosts (the command label already has to be disambiguated — e.g. a Restart Agent Host action on the host entry in the environments list, in addition to the developer command).
    2. Alternatively, make the queue-head recovery the UI already does after a client truncateChat reachable as a "retry turn" action — that would repair the session without touching the host process.

    I can provide remote agenthost.log excerpts from an SSH target if useful.

  6. zhaojiale2021 commented on Nov 17, 2026

    @zhaojiale2021

    Filed a feature request for the remote side: #348798 — allow restarting a remote agent host (SSH/WSL/Dev Container) from the UI, mirroring Developer: Restart Local Agent Host.

  7. MaximVoloshinUA commented on Nov 18, 2026

    @MaximVoloshinUA

    Same loss on Windows 11, stable 1.146.0, triggered by changed client tools

    Another data point, from the stable build on Windows 11.

    • VS Code 1.146.0 (6904719), x64, Windows 11 Enterprise (10.0.26200)
    • Claude agent host (Agents window), claude-opus-5-5
    • Trigger: rebinding before turn … for changed client tools (not customizations). Several active client … tools=[…] re-registrations for the session came just before each lost turn.

    Disclosure: I gathered this with an AI agent (Claude), reading my local agenthost.log and the Claude transcript. Times are local (UTC+2).

    Two turns in one chat were lost the same way. Both had the double-rebuild shape described above:

    02:11:21.158  [Claude] session 09d1978c…: rebinding before turn request_bb63ff92… for changed client tools
    02:11:21.263  [error] [ClaudeSdkPipeline:09d1978c…] _processMessages crashed: Error: Claude SDK stream ended without a result message
    02:11:21.794  [Claude] session 09d1978c…: rebuild isResume=true agent=(none)
    02:11:22.905  [Claude] session 09d1978c…: rebuild isResume=true agent=(none)
    02:11:24.628  [Claude:09d1978c…] queue yielded sdkUuid=request_bb63ff92… turnId=request_bb63ff92…
                  ← no "result for sdkUuid=request_bb63ff92…"
    

    The transcript has the assistant's end_turn reply at 02:11:58. The chat kept showing "This is taking a little longer than usual".

    The earlier lost turn (01:41) also confirms the queue-head behaviour that Alan Zhao (@zhaojiale2021) described. It had the same rebind, crash and two rebuilds. My next two messages were not started as new turns but enqueued into the stuck one:

    01:41:37.890  queue yielded sdkUuid=request_b738b735… turnId=request_b738b735…
    01:52:05.284  queue yielded sdkUuid=request_0b5fffb2… turnId=request_b738b735…   ← next user message
    01:52:08.338  [AgentHostFirstProgress] turnId=request_b738b735… timeToFirstProgress=635017
    01:54:05.187  queue yielded sdkUuid=request_b024c7e9… turnId=request_b738b735…   ← and the one after
    

    A side effect: after the resume, the agent's own context no longer contained the lost turn. So when I asked "status?", it replied as if the lost question had never been asked, which made the failure more confusing.

    Turns in the same chat with zero or one rebuild delivered their result normally.

  8. GNeras commented on Nov 27, 2026

    @GNeras
    Author

    Still happening on 1.148.0: captured end to end with breakpoints in the agent host (root cause, repro and a fix tested in daily use)

    • VS Code 1.148.0 (661626d), x64, Ubuntu 25.10
    • Claude agent host (Agents window), bundled SDK 0.3.304 (Claude Code 2.1.304), claude-opus-5-5
    • Agent plugins installed in VS Code (client plugins synced to the session), and one plugin also installed natively in Claude Code

    Disclosure: I investigated this with an AI coding agent (Claude Code). To stop guessing from logs, it attached to the agent host with the built-in --inspect-agenthost=5878 flag and set breakpoints at about 40 points of the turn lifecycle. Each breakpoint records its arguments and, where useful, the full async call stack, then resumes immediately. Queries are numbered as they are bound (q1, q2…) so we can see which one consumes each prompt. No VS Code files were modified. Line numbers refer to the 1.148.0 sources.

    Summary

    The turn's prompt is consumed by the query bound by one rebind, and a second, concurrent rebind replaces that query a moment later. From then on, _processMessages drops every message of the turn, including the reply and its result, because they come from a query that is no longer this._query. The second rebind exists because of three things together:

    1. A rebind before the turn ends the live query's prompt stream itself, and that is reported as a crash that sets _needsRebind = true while the new query is still being built.
    2. During that window, a republish of session customizations reaches snapshotResolvedCustomizations() → _ensureQueryBound(), sees _needsRebind and starts _rebindQuery('recover'). Nothing prevents two _rebindQuery calls from running at once.
    3. Republishes are very frequent around a turn: after the client plugin sync and whenever the Claude CLI touches ~/.claude/plugins, which happens on every process start and exit.

    Repro

    1. Have at least one agent plugin installed. Restart VS Code, or run Developer: Restart Local Agent Host.
    2. In an existing Claude chat, send a message. It works.
    3. Send a second message. It always starts with rebinding before turn … for changed client customizations, and some of the time the reply is lost.

    In my agenthost.log files from Nov 24–26, by the turn's position since the session materialized:

    Turn after materialize Turns Rebind Two rebuilds Lost
    1st 14 0 0 0
    2nd 8 7 4 4
    3rd and later 50 35 2 2

    Most 3rd+ rebinds came from root config changes, such as the Codex account refresh jhulford described. It's a timing race: in short test chats I needed several attempts. In long real sessions it happens much more often.

    Capture 1: second turn of a test chat, reply "dos" dropped (session 3c89fb6b…, Nov 26)

    Time Event (recorded at the breakpoint)
    12:43:40.6 adoptClientCustomizations(…): the client plugin sync lands, right after turn 1 ended. A cascade of customization republishes follows
    12:43:43.0 ClaudeAgentSession.send: rebindReason = "client customizations". hasDifferenceFrom → {dirty: true, applied: [], desired: [<abap plugin dir>, <VS Code Synced Data dir>, …]}
    12:43:44.128 _rebindQuery("restart"). Current query: q2
    12:43:44.754 q2's prompt iterator ends with signalChanged: true: bindAbortSignal(placeholder) in _rebindQuery closed it
    12:43:45.202 q2's stream ends while it is still this._query → consumerError: "Claude SDK stream ended without a result message" → _needsRebind = true
    12:43:45.450 A pending republish reaches snapshotResolvedCustomizations with needsRebind: true
    12:43:45.713 _rebindQuery("recover") ← _ensureQueryBound ← snapshotResolvedCustomizations ← getSessionCustomizations ← AgentSideEffects._publishSessionCustomizations, concurrent with the restart
    12:43:47.477 The restart finishes: _bindWarmQuery → q3
    12:43:49.231 queue yielded sdkUuid=request_9e2359c6…: the prompt is consumed by q3
    12:43:50.464 The recover finishes: q4 replaces q3. Its rematerialize took 4.6 s, which is why its rebuild log line comes after queue yielded
    12:43:50.722 Dropped (this._query !== query): assistant from q3, text "dos", user_message_uuids: ["request_9e2359c6…"]
    12:43:50.972 Dropped: result success / end_turn from q3 for request_9e2359c6…
    12:45:43 I stopped the turn. Until then the chat showed "This is taking a little longer than usual"

    Capture 2: the same race in a long real session (session 97bbd017…, 12:02)

    Same chain, but here the recover was triggered by the file-watcher republish, and the second rebuild came before queue yielded:

    Time Event
    12:02:11.449 adoptClientCustomizations (right after turn 1)
    12:02:41.621 Turn 2: hasDifferenceFrom → applied: [], desired: [abap plugin, …]
    12:02:42.003 _rebindQuery("restart")
    12:02:42.302 stream ended without a result message → _needsRebind = true
    12:02:42.972 _ensureQueryBound() with needsRebind: true ← snapshotResolvedCustomizations ← getSessionCustomizations ← getChatCustomizations ← _publishSessionCustomizations ← _publishSessionCustomizationsSoon ← _publishSessionCustomizationsForAgent ← agent onDidCustomizationsChange
    12:02:43.160 _rebindQuery("recover")
    12:02:43.572 queue yielded sdkUuid=request_4441078f…
    12:02:45.8 → Every message of the turn dropped: system/init, system/status (user_message_uuids: ["request_4441078f…"]), the stream events and the assistant message

    Root causes, with code references

    1. The first turn after materialize runs without the client plugins, so turn 2 always rebinds. At materialize, the SDK options were plugins: [] in every capture (synced: 0). _syncClientCustomizations queues adoptClientCustomizations on the session sequencer (claudeAgent.ts:2632), which sendMessage holds for the whole turn (claudeAgent.ts:2399). So the sync only lands after turn 1 has finished, and turn 2 sees client customizations changed. As far as I can tell, turn 1 never gets the client-synced plugins.

    2. A restart rebind ends the live query and reports it as a crash. _rebindQuery calls this._queue.bindAbortSignal(placeholder.signal) (claudeSdkPipeline.ts:638), which ends the old query's prompt iterator (claudePromptQueue.ts:74). The old stream then ends while it is still this._query, so the post-loop guard throws stream ended without a result message and sets _needsRebind = true (claudeSdkPipeline.ts:761-770). That's why this error follows almost every rebind (39 of 40 in my logs). For the rest of the rematerialize, the pipeline looks dead to everyone else.

    3. Anything that calls _ensureQueryBound() during that window starts a concurrent rebind (claudeSdkPipeline.ts:174-176). _rebindQuery has no in-flight guard. The caller in both captures was the customization republish, which AgentSideEffects fans out to every session of the agent (agentSideEffects.ts:699, subscribed at :745).

    4. The republish is fired by the customizations file watcher on every Claude CLI start and exit. ClaudeCustomizationWatcher watches ~/.claude recursively and triggers on the plugins subpath (CLAUDE_CUSTOMIZATION_SUBPATHS, claudeSessionCustomizationDiscovery.ts:443). The CLI writes there on every start and exit. Recorded file changes:

      • start: added ~/.claude/plugins/cache/<marketplace>/<plugin>/<version>/.in_use/<pid> (a natively installed plugin), plus ~/.claude/plugins/known_marketplaces.json.lock, added and then deleted;
      • exit: deleted …/.in_use/<pid>.

      So every rebuild republishes customizations for every session, right in the window from cause 2.

    5. Messages from a superseded query are dropped and the turn is never settled. The checks at claudeSdkPipeline.ts:704 and :729 drop everything, including the result. Nothing fails or retries the turn whose prompt that query consumed, so it hangs until the user stops it.

    Fix, tested in daily use

    Serializing _rebindQuery is enough to break the chain. A caller that arrives while a rebind is in flight waits for it, and a recover that is no longer needed afterwards (!_needsRebind) returns without rebuilding:

    async _rebindQuery(reason) {
    	while (this._rebindInFlight) {
    		try { await this._rebindInFlight; } catch { }
    		if (reason === 'recover' && !this._needsRebind) {
    			return; // the in-flight rebind already produced a healthy query
    		}
    	}
    	const p = this._doRebindQuery(reason); // the current body
    	this._rebindInFlight = p;
    	try { return await p; } finally { if (this._rebindInFlight === p) { this._rebindInFlight = undefined; } }
    }

    I've been running exactly this guard in my own agent host since yesterday. It's applied at runtime: open the agent host's inspector with process._debugProcess, find ClaudeSdkPipeline in the heap with Runtime.queryObjects, wrap _rebindQuery on its prototype and close the inspector again. No VS Code files are changed.

    • In normal work it has caught the race 5 times so far, all in the same long session: 4 yesterday afternoon and 1 this morning. Each time a recover arrived while the restart was in flight, it waited instead of starting a second rebind, and the turn completed. Without the guard, each of those 5 turns would have been lost.
    • I also checked it against a model that replays the timings of capture 1. Without the guard, the reply from q2 is dropped; with it, the recover joins the restart and the reply is delivered.

    Other changes that would remove the window or the trigger:

    • Don't treat the restart rebind's own shutdown of the old query as a crash, for example by not setting _needsRebind when the old query was ended by _rebindQuery.
    • Apply the client plugin sync before turn 1's send, instead of queueing it behind the turn.
    • Don't let the customizations watcher trigger on the CLI's runtime files under ~/.claude/plugins (.in_use/, *.lock).
    • If a turn's prompt was consumed by a query that is then discarded, fail or retry the turn instead of leaving it pending.

    Other hangs with the same symptom (different root causes)

    While capturing this, I found three more ways a Claude turn in the agent host never finishes, or its reply is never shown. They have nothing to do with rebinds, but they look the same from the chat, so some reports here may be one of them. Each has a deterministic repro, a capture and a workaround I've tested:

    I can share the inspector script and the raw captures (JSONL with arguments and async stacks) if useful.

  9. hojland commented on Nov 27, 2026

    @hojland

    Same on macOS arm64 (27.2.1), VS Code 1.148.0 (661626d), Claude agent host with claude-opus-5-5 on Amazon Bedrock. Several natively installed Claude Code plugins have .in_use/<pid> markers under ~/.claude/plugins/cache, which fits the watcher trigger described above.

    In one agent-host process (Nov 26 13:09 to Nov 27 15:26), every turn preceded by two rebuild isResume=true lines lost its reply: 7 of 7, across 5 sessions. Of 9 turns with a rebind and a single rebuild, 1 lost its reply.

    The changed client tools rebinds don't need a real change. Only one client is attached, and after startup its tool list is identical in all 256 active client … tools=[…] lines. Still, 8 turns logged rebinding before turn … for changed client tools. The latest (request_34717d99…, Nov 27 15:01:50) went rebind, rebuild, stream ended without a result message, then a second rebuild 0.5 s later, and its reply never reached the chat, although the transcript shows the turn finishing normally at 15:04:21.

    One more effect we haven't seen reported here: the superseded process doesn't stop. In session 08c06c13… the first turn's reply (request_91c9cb2b…) was dropped, so the chat showed nothing, and I sent the message again 3 minutes later (request_334a2fb2…). The host rebuilt twice more. From then on, two processes worked on the same session for about 4 minutes. The transcript has two prompt ids interleaving and forks at 5 points. Both processes made changes on GitHub. One posted that a PR shouldn't be marked ready, and two seconds later the other marked it ready. One of them also ran a tool call immediately after an AskUserQuestion, without waiting for the answer. Neither process's output reached the chat. So this race can also duplicate real side effects (pushes, PR edits), not only hide output.

    Logs: https://gist.github.com/hojland/df165fa7fc6e79d26a957720c5d9b4ac

    • agenthost-claude-lifecycle.log: the agenthost.log for that process, filtered to the Claude lifecycle lines (home paths shortened, nothing else edited).
    • transcript-structure.jsonl: the Claude Code transcript of 08c06c13… from 12:30 to 12:43 UTC, reduced to ids, parent ids, prompt ids, timestamps and block types, with message content removed.

    The README in the gist lists the lost turn ids and the fork points.

    I found this with an AI coding agent (Claude Code), working from my agenthost.log and Claude transcripts. I haven't used a debugger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions