Skip to content

Agent host: a Claude session shows nothing more once the parent resumes after a background subagent #332073

Agent suggestions

Public preview

Description

@RyanEwen

When a Claude agent-host turn spawns a background subagent, the parent finishes its own turn. Once the subagent settles and the parent resumes producing output, every SDK message is discarded, so the chat shows nothing further for the rest of the work. The transcript on disk records all of it, so restarting the agent host makes the whole response appear at once.

Steps to reproduce

  1. In a Claude agent-host session, send a prompt that makes the agent spawn background subagents, for example "use subagents to audit these two directories in parallel, read-only".
  2. Watch the chat while it works.

Expected: the parent's output keeps appearing as the subagents report back.

Actual: the response stops at whatever the parent said before spawning, typically one or two lines, and nothing more ever renders. No error appears in any log, at any log level.

Restart the agent host and reopen the session: the complete response appears, rebuilt from the transcript.

Root cause

ClaudeSdkPipeline._processMessages derives the turn from the prompt queue head:

const parent = this._queue.peekParent();
const turnId = parent?.turnId;

A parent that spawns background subagents ends its own turn, so the queue drains and turnId becomes undefined for everything that follows.

ClaudeSdkMessageRouter.handle then drops the message outright:

if (turnId === undefined) {
	return;
}

That early return is silent at every log level, which is why the failure leaves no trace anywhere.

Evidence

Captured on a live host with AgentHostStateManager's envelope logging temporarily raised to info:

Host's last emitted envelope 9:15:13 p.m.
Parent produced 4 assistant messages transcript, 9:15:17 to 9:15:21 p.m.
Envelopes emitted for those messages none

The three AgentSideEffects drop paths (Dropping stale ..., Dropping completion for cancelled turn ...) were also raised to info for the same run and never fired, confirming the message dies earlier, in the router.

Replaying that session's transcript offline through mapSessionMessagesToTurns produces the turn with all 35 response parts (3 markdown, 23 tool calls, 9 reasoning). The data is intact; only the live path loses it.

Related

PR #331872 hooks this same early return for system / task_notification, so a background subagent's chip completes. That is a narrower case of the same gap: once a turn id is available, claudeSubagentSignals already maps task_notification normally, so a general fix here supersedes it.

Version

Visual Studio Code 1.1.3 (stable), server commit 110a328ea54b42367b803ec53ee0bf52ef26b419, dev container on linux-arm64. Root cause confirmed against main.

AI disclosure: this issue and the related code were written with the assistance of AI.

Public patches and patcher scripts

Public patch catalog and patcher scripts · Source patch index. The public collection includes the maintained patchers, rollback instructions, regression scripts, and historical snapshots. Build restrictions and exact installer coverage are documented there.

Activity

  1. RyanEwen commented on Aug 31, 2026

    @RyanEwen
    ContributorAuthor

    Another way into this, which the fix in #332075 cannot cover: closing the window while background subagents are running.

    Closing the window tears down the agent host, and with it every subagent that was mid-flight. When the window reopens, the SDK resumes and the parent's remaining output arrives, but there is no turn left to attach it to. Observed in a dev container today:

    20:13:08 [info] [Claude:77fedef1-...] result for sdkUuid=undefined
    20:19:36 [info] [Claude:77fedef1-...] result for sdkUuid=undefined
    20:21:40 [info] [Claude:77fedef1-...] result for sdkUuid=undefined
    20:24:09 [info] [Claude:77fedef1-...] result for sdkUuid=undefined
    

    Four results, all with no turn, spread over eleven minutes after the window came back. In the same session's AHP log, chat/turnStarted appears 10 times and chat/turnComplete twice, so eight turns were left open and never closed. The chat shows nothing further for any of them.

    Why the pending fix does not help here

    I am running #332075 as a local patch, and I verified it was live in the process that produced the log above: the resume-anchor marker is present in the running agentHostMain.js, and the bundle was patched three days before that host started.

    It still cannot help, because the anchor is in-memory. The turn is recorded on the subagent registry when a background subagent starts, and that registry lives in the agent host process:

    • the host dies with the window
    • the registry, and every anchor in it, dies with the host
    • the SDK later replays or resumes, the output arrives with turnId === undefined, and there is no anchor left to route it to

    So #332075 fixes the case where the parent's turn ends while the host keeps running, which is the common one, but not the case where the host itself restarts. Both produce the same user-visible symptom, which is why I am adding it here rather than filing separately.

    What this suggests

    The anchor needs to survive a host restart to cover this, which means deriving it rather than remembering it. The transcript already records which turn a subagent was spawned in, so on reconnect the host could recover the mapping from the transcript instead of relying on state it happened to be holding when the window closed.

    Closing a window while agents are working is an ordinary thing to do, and today it silently strands whatever they produce afterwards, with the turns left open in the UI.

    AI disclosure: this comment and the related investigation were written with the assistance of AI.

  2. RyanEwen commented on Sep 2, 2026

    @RyanEwen
    ContributorAuthor

    I can now reproduce this ratio on demand, from a different trigger, which I think strengthens the case that the missing terminal path is a defect in its own right rather than only a consequence of the window closing.

    Driving a real window through a scripted scenario, with a prompt that causes several subagents to be spawned:

    chat/turnStarted   x10
    chat/turnComplete  x4
    

    Seven subagent turns opened, two completed, five left open, plus the parent's follow-up turn. No window was closed and no host restarted; everything stayed up throughout. The chat shows nothing further for any of the open turns, and waiting does not change it.

    The mechanism is the one I have filed separately as #333931: the subagent's tool call is announced and then never executed, so the spawning tool never produces a tool_result, so subagent_completed never fires, and completeSubagentSession is the only thing that can close a subagent turn.

    The reason I think this matters here: the two triggers differ, but the end state is identical, and in both cases nothing in the product can recover it. A turn whose producing work is gone stays open forever, because the only thing resembling a watchdog reports a hang reason to telemetry and dispatches no action. Whatever fixes the underlying stall, a terminal path for an abandoned turn looks worth having on its own.

    Reproduced on 1.135.0 (08d4889f9ec4a1685d257b9b95de036c8e1ce1e5), and separately against a fully stock reverted bundle to rule out my local patches.

    AI disclosure: this comment and the related investigation were written with the assistance of AI.

  3. RyanEwen commented on Sep 3, 2026

    @RyanEwen
    ContributorAuthor

    Adding the host-side mechanism, observed live rather than derived from source.

    A background subagent's signals are dropped wholesale once its own chat has no active turn. In AgentSideEffects, a signal carrying a parentToolCallId resolves the subagent chat and then gates on that chat's active turn:

    let sub = this._subagentChats.get(chatKey, parentToolCallId);
    if (sub) {
        const turn = this._stateManager.getActiveTurnId(sub.chatUri);
        turn
            ? /* recordModelCallCompleted | dispatchActionForSession, remapped onto the subagent chat */
            : (this._logService.error(`[AgentSideEffects] Dropping ${this._describeSignal(t)} for inactive subagent ${chatKey}/${parentToolCallId}`), ...);
        return;
    }

    The return is unconditional, so with no active turn the signal is neither dispatched nor buffered. The sibling _pendingSubagentSignals path immediately below covers only the case where the subagent chat does not exist yet, not the case where it exists without a turn.

    From a single session today:

    • the subagent's turn started, and 5 minutes 45 seconds later the drops began
    • 92 signals dropped, across model_call_completed, chat/responsePart, chat/toolCallStart, chat/toolCallReady and chat/toolCallComplete
    • the subagent kept working for a further 4 minutes after the first drop, with its client tool completions still being forwarded normally the whole time
    • 8 subagent turns were started in that session and there were 0 subagent_completed signals
    • the last event before the first drop was a completion on the parent chat

    The user-visible result is this issue's title exactly: the parent appears to just end, and nothing further ever renders. It does not self-heal when the subagent eventually finishes, because subagent_completed is dropped by the same gate, so the chip never resolves either.

    I recovered the subagent's full output afterwards from the SDK transcript on disk, which is unaffected by this gate. So the work is being done and recorded; only the path to the UI is lost.

    Worth separating this from #334072, which fixes the client-side observation lifetime. This gate is host-side and would still drop the signals regardless of that change.

    AI disclosure: this comment and the related investigation were written with the assistance of AI.

  4. RyanEwen commented on Sep 4, 2026

    @RyanEwen
    ContributorAuthor

    Confirmed live on 1.136.1, with four things that change the shape of this issue.

    1. The lost traffic is mostly the parent's own turn, not subagent chatter.

    When background subagents finish, the SDK injects a task-notification user prompt and starts a new top-level turn. That prompt never passes through ClaudePromptQueue: the whole 3065-line host log for the run contains exactly two queue yielded lines, both from before the drain. So peekParent() returns undefined and claudeSdkMessageRouter.ts:74 drops everything.

    In the run I captured, the discarded output was three assistant text blocks, five Bash calls, a Read and an AskUserQuestion, over six minutes. That reframes the fix: it is not "recover a turn id", it is "open a turn the host did not start". The replay path already does exactly this, ReplayBuilder opens a turn per user envelope, which is why restarting the host makes the missing content appear.

    2. AskUserQuestion is silently auto-denied by the same empty queue.

    claudeAgentSession.ts:1326 resolves Cancel whenever !hasActiveTurn, and hasActiveTurn is !this._queue.isEmpty. The model asked the user a question; the tool result came back 7 ms later as The user cancelled the question with toolDenialKind: permission-rule. The user was never shown anything. This is a second, independent casualty on the canUseTool control path, not the message stream.

    3. Every drop path in AgentSideEffects logs at trace, so absence of drops proves nothing.

    agentSideEffects.ts:704, :734, :901 and :648 are all trace. A host running at info produces a log with zero evidence of the discarding. I twice treated "0 dropped signals" as meaningful before checking the level.

    4. "The host log goes silent" is the wrong framing.

    The for await loop keeps running for the entire silent period. The tell is:

    result for sdkUuid=undefined
    

    emitted from inside the loop body when settleHead() pops nothing. Messages keep arriving; there is simply no queue entry to attach them to. Anyone debugging this by looking for a stalled loop will not find one.

    For completeness, claudeToolCallRegistry.clearPending wipes cross-message tool attribution on every result, including in-flight tool calls belonging to background subagents. drainForegroundSpawns deliberately spares background spawns from its equivalent wipe; clearPending has no such exemption. That is a separate defect in the same moment, not a cause of this one.

    AI disclosure: this comment and the related investigation were written with the assistance of AI.

  5. mmontagnana commented on Sep 29, 2026

    @mmontagnana

    Still reproducing on VS Code 1.139.1 (stable, macOS arm64), model claude-opus-5-5. Note: the agent host runs Claude Agent SDK 0.3.282, swapped in manually because the bundled 0.3.258 doesn't support Opus 5.5 (#338638). The bug itself predates that: it was confirmed here on 1.136.1 with the stock SDK.

    The parent spawned two background subagents and ended its turn. From the session transcript on disk:

    Time Event
    16:51 Parent spawns 2 background subagents, keeps working briefly, ends its turn
    16:59 / 17:02 Both subagents finish; task-notification with <status>completed</status> delivered to the parent
    16:59–17:07 Parent resumes: verifies findings, edits code, runs tests, commits, writes a long final report with open questions for the user
    17:19 User asks whether the subagents are still running

    None of the 16:59–17:07 output was rendered. The chat stopped at the parent's last message before the subagents finished ("waiting for the two agents…"). Both subagent chips still showed a spinner and "Working for 37m 8s" long after they had finished.

    This is worse than a cosmetic glitch. Believing the agents were still running, I waited for 17 minutes. When the agent then referred to "the fixes", I had no idea what it meant, and I approved the next step (opening PRs) without having seen the report, which included an unresolved issue and a required merge order. Nothing in the UI hinted that output was missing.

    Reload Window does not recover. The agent host runs as a utility process owned by the main process (here, up since 09:51), so it survives a window reload. The session and all three subagent chips (including one from a turn two hours earlier) stay "in progress" with a tool call shown as Running, even though every tool_use in the subagent transcripts has its tool_result. Only a full quit restarts the host. There is no "Restart Agent Host" command, and one would be a useful stopgap.

    A full quit recovers, as described above. On quit, VS Code warned "A session is in progress. Are you sure you want to quit?", because of the phantom state. The session looked like it was doing work, although nothing was running. After restarting, the session is idle and the missing turn is rebuilt from the transcript. The same goes for all three subagent chats: they are no longer stuck on Running and now end with their final report (SubagentHandback). So the subagents' output had been dropped live too, not only the parent's. The replay has three cosmetic differences:

    • the parent's recovered turn is headed by the raw <task-notification><task-id>…</task-id><tool-use-id>… XML, shown as if it were a user message;
    • each subagent chat is headed by a raw <system-reminder> Your final report is delivered through SubagentHandback… block, again rendered as a user message;
    • the subagent tabs lost their descriptions and are all titled "Run subagent task".

    +1 for landing #331872 / #332075.

    AI disclosure: the timeline was reconstructed from the session transcript with the assistance of AI.

  6. counterfactual5 commented on Oct 13, 2026

    @counterfactual5

    Another path to result for sdkUuid=undefined: a queued prompt settled by a task-notification turn, and a retry loop that re-announces the same agent

    VS Code 1.141.0, agent host with Claude Agent SDK 0.3.281. This is a different trigger from the empty-queue case described above.

    1. The notification turn's empty result settles the queued user prompt

    On resume, the CLI reported a background agent from the previous process as stopped. My prompt was queued at that point. The notification turn ran first, and its result had no user_message_uuid and no text. settleHead() still popped my prompt on that result, so my turn completed empty. The real answer arrived 12 s later with an empty queue:

    16:57:10.052  queue yielded sdkUuid=request_ff43…
    16:57:12.014  result for sdkUuid=request_ff43…   <- notification turn's empty result
    16:57:24.385  result for sdkUuid=undefined       <- the actual answer, never rendered
    

    The answer is in the session transcript at 16:57:24. I replayed the same sequence through the real ClaudeSdkPipeline (task_notification → result without UMU → answer whose user_message_uuid is my prompt) and got the same log and no rendered text.

    2. Re-sending re-announces the same agent, which repeats step 1

    Before every re-send the host logged truncateChat kept [0..request_b045…] (anchor=3dc2b215…). That anchor is the last assistant message before the dropped turn, so resumeSessionAt cuts the notification and the answer out of the resumed chain. The CLI then reports the same agent as stopped again, apparently because "already reported" is derived from the <task-notification> entries in the loaded chain. In this session the same agent was reported 5 times (once legitimately, then after each of 4 re-sends). All 5 entries share the same parentUuid (the anchor). Each time, the empty result settled the new prompt within ~2 s, and 4 answers ended up as sdkUuid=undefined.

    SDK-only reproduction, without VS Code: start a background agent and exit the CLI while it runs. Then:

    • plain resume + prompt → 1 "stopped" notification (expected)
    • resume with resumeSessionAt = last assistant message before that notification → the same notification again, as a sibling of the first
    • plain resume → none

    3. The SDK already guards this truncation

    With resumeDropsTurn set to the discarded prompt's UUID, the truncating resume is refused:

    Resume rejected by --resume-drops-turn: resuming at <anchor> would discard entries not attributable to turn <prompt>: range does not start with the declared turn prompt; first discarded entry 0 [type=user, ...]
    

    The first discarded entry is the <task-notification>. The agent host passes resumeSessionAt but never resumeDropsTurn. The guard also requires a UUID-shaped turn id, and it rejects request_<uuid>, which the host currently uses as the SDK user-message uuid.

    Suggested direction

    • Attribute by user_message_uuid instead of queue position. Nothing under platform/agentHost reads it today. A turn's owner is the UMU on its first top-level frame and on its result. A turn that starts without one is SDK-initiated, and its result should not settle a user prompt.
    • Pass resumeDropsTurn when truncating, and fall back to a plain resume when it is refused.

    On #336753

    From reading the diff (not run end-to-end): _adoptSdkTurn only adopts when the queue is empty, so in step 1 the answer would show up as a separate turn after an empty reply. A second prompt queued at that point would still be credited with the answer. The anchor change only applies to adopted turns, and a notification turn with no assistant output is never adopted, so I'd expect the loop in step 2 to persist.

    I can share the replay harness and the SDK scripts.

  7. gogetenk commented on Oct 27, 2026

    @gogetenk

    Still reproducing on VS Code 1.143.1 (Windows 11, Anthropic account, Sonnet), fresh --user-data-dir, with a minimal prompt:

    Use the Agent tool to launch two subagents in the background (run_in_background: true), in one message. Subagent A runs one shell command that writes the text a to the file a.txt in the current folder, then replies done. Subagent B does the same with b and b.txt. Do not wait for them: right after launching both, end your turn with the single word launched.
    

    Both files are written and the transcript gets <status>completed</status> for both. The chat stops at "launched", the "Write a.txt" chip stays on "Working" with its command shown as Running, and "Write b.txt" never gets a chip at all: only one Starting subagent turn is logged, for the first tool call.

    08:09:21.409 [AgentSideEffects] Starting subagent turn: ahp-chat:/a2179e1d-… (parent=ahp-chat:/cb9446a2-…, toolCallId=toolu_015sPDjK…)
    08:09:21.477 [Claude:b95926f3-…] result for sdkUuid=request_de10ba81-…
    08:09:24.222 [Claude:b95926f3-…] result for sdkUuid=undefined
    08:09:26.472 [Claude:b95926f3-…] result for sdkUuid=undefined
    

    No user message and no resume rebuild during the run. Details in #344508, closed as a duplicate of this one.

  8. not-happy commented on Nov 2, 2026

    @not-happy

    Independent confirmation on VS Code 1.144.0 (commit 2c33b50b, Windows Server 2022 x64, anthropic.claude-code 2.1.312). Two data points that broaden the scope:

    1. Provider/model-agnostic. This environment routes the Claude harness through a custom ANTHROPIC_BASE_URL proxy with a non-official model ID. The drop behaves exactly as described here, so it is not tied to first-party Anthropic models or accounts.

    2. Plain run_in_background shell tasks trigger it too — not only Agent subagents. The session ran long Maven builds as background Bash tasks; the parent ended its turn while they were still running.

    Timeline from agenthost.log + the on-disk session transcript (2026-11-02, local time):

    10:51:54 [Claude] session 9dd8b31d…: rebuild isResume=true
    10:51:54 [Claude:9dd8b31d…] queue yielded sdkUuid=request_4df77aea…
    10:58:38 [Claude:9dd8b31d…] result for sdkUuid=request_4df77aea…      ← parent turn ends, queue drained
    10:59:01 (transcript) queue-operation enqueue <task-notification bege0ouos …>
    10:59:01 (transcript) queue-operation dequeue → injected as a user message; the model kept working on disk
    11:00:05 [Claude:9dd8b31d…] result for sdkUuid=undefined               ← SDK-initiated turn, no host queue entry
    

    Everything the model produced during the SDK-initiated turn (10:59:01–11:00:05) is present in the transcript but nothing rendered in the chat — consistent with peekParent() returning undefined after the queue drains and the silent early return in claudeSdkMessageRouter.ts (still present on current main):

    if (turnId === undefined) {
    	return;
    }

    A fresh user prompt at 11:00:53 (next queue yielded) was required to make the session visibly respond again.

    Also observed, for contrast: <task-notification> entries arriving mid-turn show enqueue → remove in the transcript (consumed by the in-flight turn) and are handled correctly. Only the idle-wake path is dropped, matching the analysis above.

    Watching #336753.

  9. g27182818 commented on Nov 4, 2026

    @g27182818

    Another symptom of the same cause, reproduced on server build a717861c07586a53d83b80d742cd3f59b20a6273, Linux remote, Claude Code agent host.

    Repro: in an agent-host session, spawn one background subagent whose only job is date -u; sleep 240; date -u, and end the parent turn straight away. Send a few messages while it runs.

    Observed: the subagent finishes; the parent receives its report and a completed task-notification. In the UI:

    • the parent's Agent tool card stays at "Working for Nm" with its child Bash call "Running", indefinitely;
    • the subagent's own pane stops at the Bash call ("Running", then "Reasoning"); the tool result and the subagent's final reply never render.

    Host log (agenthost.log): every user turn appears as a queue yielded … turnId=X / result for sdkUuid=X pair. The parent turn that ran once the subagent finished has no turn attached:

    19:11:56.606 [Claude:<session>] result for sdkUuid=request_f2864ae0-…   # last user turn
    19:12:12      (subagent finishes — no log line)
    19:12:27.360 [Claude:<session>] result for sdkUuid=undefined
    

    This matches the root cause above: once the parent's turn has closed, turnId comes from the queue head, which is empty, so the messages are dropped. Here that includes the subagent's later tool results and the parent's toolCallComplete for the Agent call, so the card can never finish. I saw the same sdkUuid=undefined result in an earlier occurrence (2026-10-14, VS Code 1.141.0).

    No resume rebuild occurred in this run (pid unchanged), so this is independent of #339309.

  10. not-happy commented on Nov 5, 2026

    @not-happy

    A coverage-gap note tying #345986 to this issue, in case it helps triage.

    #345986 (which fixes #339309) is now cross-referenced here, but the core drop path reported in this issue survives that PR. Its changes are confined to claudeAgentSession.ts, claudePromptQueue.ts and claudeSdkPipeline.ts: deferring deferrable rebuilds while background tasks are live, and settling queued prompts by user_message_uuid so an SDK-initiated turn's result can no longer masquerade as the reply to a pending user prompt. It does not touch claudeSdkMessageRouter.ts and does not open a turn for SDK-initiated output arriving on an empty queue. The silent early return is still on current main (claudeSdkMessageRouter.ts, lines 82-84 as of today):

    if (turnId === undefined) {
    	return;
    }

    So the exact scenario I confirmed above (VS Code 1.144.0, custom ANTHROPIC_BASE_URL with a non-official model ID, plain run_in_background Bash tasks — no Agent subagents involved) still loses the whole idle-wake turn:

    10:58:38 result for sdkUuid=request_4df77aea…   ← parent turn ends, queue drained
    10:59:01 (transcript) queue-operation dequeue → task-notification injected as a user message
    11:00:05 result for sdkUuid=undefined            ← SDK-initiated turn, nothing rendered
    

    #345986 removes one aggravating factor — a follow-up send while tasks are live no longer rebuilds the session and SIGKILLs them — but for a session that is simply idle when a background task settles, the continuation output is still dropped wholesale, at every log level, and the chat stays dead until the next user prompt.

    On the PR that does target this issue, #336753: last commit Sep 18, last activity Sep 21, currently conflicting with main, and no human review so far. Note also that #345986 touches the same two files (claudePromptQueue.ts, claudeSdkPipeline.ts), so whichever lands second will need another rebase — the two fixes are complementary (keep tasks alive + match results to prompts, vs. render SDK-initiated turns) rather than alternatives.

    TylerLeonhardt since both community PRs are stalled, is there an internal fix planned for rendering SDK-initiated reply turns (the idle-wake task-notification continuation)? If a narrower scope than #336753 would be preferable, I can help with verification — I have a reliable log-based repro on Windows Server 2022 with a proxied endpoint.

  11. the-corp-mark commented on Nov 10, 2026

    @the-corp-mark

    Still reproducing on VS Code 1.145.2 (commit c4453f8e, macOS arm64), model claude-opus-5-5, with eight background subagents launched in parallel.

    The parent's own turn completes normally, then every turn the SDK starts afterwards arrives with no turn id:

    10:21:18–10:21:22  [AgentSideEffects] Starting subagent turn ×8 (all chips render)
    10:21:25.115  result for sdkUuid=request_7f253314-…   ← user turn ends
    10:21:38.366  result for sdkUuid=undefined            ← first subagent report
    … 13 more, in pairs as each subagent reports …
    10:22:25.745  result for sdkUuid=undefined            ← parent's final answer, never rendered
    

    No Dropping … line is logged, which matches the silent return in claudeSdkMessageRouter.ts. All eight subagent transcripts end with a successful hand-back between 10:21:34 and 10:21:38, yet all eight chips stay on "Working", each frozen on an earlier step: either a shell call still shown as Running, or "Working on it…". The parent's seven progress updates and its final reply are all in the transcript on disk, but none of them render.

    Is #336753 still the intended fix? It has been waiting for review since September, and this now reproduces with every background-subagent prompt.

    Image
  12. GNeras commented on Nov 27, 2026

    @GNeras

    Still reproduces on 1.148.0 (661626d), Ubuntu 25.10, local window, bundled SDK 0.3.304. The early return is now at claudeSdkMessageRouter.ts:82.

    Disclosure: I investigated this with an AI coding agent (Claude Code), attached to the agent host's inspector with a breakpoint on that early return, recording each message it drops. No VS Code files were modified.

    Repro (my prompt was in Spanish, hence "lanzado" and "hecho" below): "Launch a background subagent (with run_in_background) that runs sleep 20 and then replies "hecho" (done). Don't wait for it: end your turn right away saying "lanzado" (launched). When the subagent finishes, tell me in one sentence what it replied." The turn ends with "lanzado". The subagent's box never appears, and the reply when it finishes is never shown.

    What the router dropped (Nov 26, one chat):

    Time Dropped message
    15:05:27.696 assistant from the subagent (parent_tool_use_id = the Agent call), tool_use: Bash
    15:05:27.822 / 31.040 system/task_progress, system/task_started
    15:05:48.052 system/task_notification
    15:05:48.176 / 48.909 the subagent's tool_result and its final assistant text ("hecho")
    15:05:49.034 – 49.281 system/task_updated, system/task_notification, system/background_tasks_changed
    15:05:49.405 / 49.530 system/init, system/status of the turn the CLI starts on its own
    15:05:50.123 that turn's assistant reply ("The subagent has finished and replied «hecho».")
    15:05:50.248 its result success / end_turn, with origin: {kind: "task-notification", producer: "session-task"}

    About #348923: it maps only type: 'system' messages when there's no turn. In this capture that would complete the subagent's box, but the subagent's own messages (its tool calls and final text) and the CLI's whole turn (reply and result) would still be dropped.

    A direction that works for me. The agent host already supports provider-started turns (ChatTurnStarted from the provider, AgentSideEffects._trackProviderStartedTurn, agentSideEffects.ts:940), and the protocol has MessageKind.SystemNotification, which the Copilot session already uses. I've been running this at runtime since yesterday, wrapping ClaudeSdkMessageRouter.handle:

    • Messages of a background subagent, and task_* system messages, go through the last turn of the chat, so the subagent's box appears, shows its progress and completes.
    • When an assistant / user / stream_event arrives with no turn, it fires chat/turnStarted with a new turn id and message: {text: "Background task completed: <summary>", origin: {kind: "systemNotification"}}, routes the CLI's turn through it, and completes it on its result (or when a real user turn starts).

    With it, the repro shows the subagent and then a Background task completed turn with Claude's reply. The agent host logged it 3 times on the first day. Known gap: a message the user sends while that CLI-started turn is running can still be lost.

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