Repository navigation
Agent suggestions
Public previewDescription
Summary. The agent host sometimes discards a healthy, live Claude SDK session between turns and rebuilds it from transcript on the next turn. Any in-process background subagents (Agent tool tasks) are killed mid-flight by the rebuild, and the assistant's reply is sent but not rendered to the Agents Window.
Mechanism (read from the minified out/vs/platform/agentHost/node/agentHostMain.js): ClaudeSdkPipeline attaches a "rematerializer" which _rebindQuery(reason) invokes whenever desired state drifts from applied state — rebindForRestart(), rebindForClientTools() (client tool-set changes mark toolDiff.markDirty()), MCP launch-enablement revision changes, additional-directory changes, and transport switches. The rematerializer starts a fresh SDK session with isResume: true and the live one is discarded, logging [Claude] session <uuid>: resume rebuild agent=(none).
Consequences observed (agenthost.log, 2026-10-02, hostProcessAgeMs continuous across the event — i.e. no host restart):
- Seven running background subagents died and reported on the next turn as "didn't finish before the previous session ended".
- Their stopped-notices ran as their own tiny turn (
queue yielded→result23 ms later), which closed the pending user turn; the assistant's actual reply then logged asresult for sdkUuid=undefinedand was never rendered to the user. - Related variant: a user message sent mid-turn is folded in as steering (
injectSteering: enqueued id=…,queue yielded … steeringPendingId=…); the turn again closes on the firstresult, dropping the reply to the second message.
Log signature sequence for one occurrence:
11:03:42 [Claude:<session>] result for sdkUuid=request_49dfe40f-… ← turn ends normally, 7 subagents still running
11:06:01 [Claude] session <session>: resume rebuild agent=(none) ← between turns; kills the subagents
11:06:03 [Claude:<session>] queue yielded sdkUuid=request_26892093-…
11:06:03 [Claude:<session>] result for sdkUuid=request_26892093-… ← 23 ms stopped-notice turn
11:08:56 [Claude:<session>] result for sdkUuid=undefined ← the real reply, never rendered
Expected behavior. A between-turn rebind should be deferred while background subagents are running (or hand them off to the new session), and an SDK-initiated notice turn must never consume the pending user turn's result slot.
Environment. VS Code 1.139.1, Linux; anthropic.claude-code 2.1.284. The 1.140 release notes mention no fix, and no chat.agentHost.* setting governs rebind behavior.
Related, but distinct: #332073 (replies lost after background subagents complete — analyzed there as a turnId === undefined discard), #337904 (mid-turn steering messages never shown), PR #326270 (removes the rematerializer pattern; does not claim to preserve running subagents across a rebuild), PR #336753 (renders SDK-initiated turns when the prompt queue is empty).
Activity
jmeickle commentedon Oct 2, 2026
The above is primarily agent-written. However I have seen this on multiple occasions since switching from using the Claude extension's chat, to using the Claude within the Agents Window specifically. It's a major degradation in functionality to both have subagents sometimes accidentally terminated, and to sometimes lose visible agent replies on turns (the apparent behavior is that it just replies with "nothing")
[-]Claude agent host: between-turn 'resume rebuild' kills in-flight background subagents and drops the next assistant reply (result for sdkUuid=undefined)[/-][+]Claude agent host: between-turn 'resume rebuild' kills subagents and drops replies[/+]passee commentedon Oct 14, 2026
Additional consequence of the same between-turn rebuild: every
resume rebuildrespawns all stdio MCP servers configured for the Claude session (user config + plugins), so the cost is paid on a large share of prompts, not just the first one.Environment: VS Code 1.141.0 (2a59476), Windows 11, Claude agent in the Agents window, 7 stdio MCP servers (azure-devops, playwright, mssql, obsidian, angular-cli, microsoftdocs, markitdown).
Evidence — one session, 2026-10-14 (local time). MCP start = new file in
%LOCALAPPDATA%\claude-cli-nodejs\Cache\<project>\mcp-logs-*:resume rebuild?active client … tools=[…]at 13:58:36active client … tools=[…]at 14:06:34 (after switching to another session at 14:04 and back)active client … tools=[…]×2 at 14:48 / 14:52 (default chat + subagent chat while a subagent ran)MCP restarts map 1:1 to
resume rebuild; turns without a rebuild start no MCP servers.Trigger: every rebuild was preceded by the client re-announcing itself (
getOrCreateActiveClient→setClientTools+_syncClientCustomizations). This happens just by switching between sessions in the Agents window or when a subagent chat starts. The announced tool list was identical every time (same 15 browser/automation tools), and no new plugin revision was synced underagentPlugins/at those times — so neither the tool set nor the customization content actually changed, yet the session was still marked dirty. The log doesn't show which of thesend()drift checks fired.A cancelled turn also forces a rebuild (
sendMessage failed … Canceledat 13:58:28 →resume rebuildat 13:58:36).Expected: a client re-subscribe with unchanged tools/customizations should not mark the session dirty, so the warm SDK query (and its MCP servers) survives session switches.
gogetenk commentedon Oct 27, 2026
Still present on VS Code 1.143.1 (e646868), Windows 11, Claude Code 2.1.281.
Here the rebuild happens on most turns: one agenthost.log has 23
[Claude] session <id>: resume rebuild agent=(none)lines for 36 turn results, with no Abort clicked. Each one matches aSessionStartevent in the Claude transcript. Phase 9 ofsrc/vs/platform/agentHost/node/claude/smoke.mdexpects a single extra rebuild, after Abort or after the SDK subprocess is killed.Same effect: three background tasks (two agents, one shell) killed in one morning, each reported at the next message as "didn't finish before the previous session ended". One that finished inside its own turn came back normally.
Likely repro, not yet run on a clean profile: a background agent that waits 3 minutes then writes a file, end the turn, send any message within the 3 minutes.