Skip to content

Claude agent host: between-turn 'resume rebuild' kills subagents and drops replies #339309

Agent suggestions

Public preview

Description

@jmeickle

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):

  1. Seven running background subagents died and reported on the next turn as "didn't finish before the previous session ended".
  2. Their stopped-notices ran as their own tiny turn (queue yielded → result 23 ms later), which closed the pending user turn; the assistant's actual reply then logged as result for sdkUuid=undefined and was never rendered to the user.
  3. 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 first result, 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

  1. jmeickle commented on Oct 2, 2026

    @jmeickle
    Author

    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")

  2. changed the title [-]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[/+] on Oct 2, 2026
  3. passee commented on Oct 14, 2026

    @passee

    Additional consequence of the same between-turn rebuild: every resume rebuild respawns 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-*:

    Turn start resume rebuild? New MCP log Preceded by
    13:55:46 fresh session 13:55:47 –
    13:58:37 yes 13:58:39 active client … tools=[…] at 13:58:36
    14:00:31 no – –
    14:40:10 yes 14:40:11 active client … tools=[…] at 14:06:34 (after switching to another session at 14:04 and back)
    14:43:56 no – –
    14:47:54 no – –
    14:53:38 yes 14:53:39 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 under agentPlugins/ 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 the send() drift checks fired.

    A cancelled turn also forces a rebuild (sendMessage failed … Canceled at 13:58:28 → resume rebuild at 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.

  4. gogetenk commented on Oct 27, 2026

    @gogetenk

    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 a SessionStart event in the Claude transcript. Phase 9 of src/vs/platform/agentHost/node/claude/smoke.md expects 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.

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