Nested subagents remain stuck as "Running" in Background tasks panel after parent subagent completes
Bug description
When a subagent (dispatched via the Agent tool) spawns its own nested subagents, those grandchild agents remain listed as Running in the Background tasks panel indefinitely after the parent subagent completes — in my case for 11+ hours (see screenshot).
The work itself finished: the parent subagents (code reviewers in a subagent-driven workflow) returned their reports containing the results of these nested verification agents. Only the panel state is stale — token counts and tool-use counts are frozen.
What I observed
- 5 nested agents stuck as "Running" for 11h+ (e.g. "Check parseReaisToCents impl", "Verify subcategoryId zod validation") — all spawned by reviewer subagents, not by the main session.
- Their token/tool counters never advance (frozen at 25–61k tokens).
- Calling
TaskStopfrom the main session returns "No task found with ID: <id>" for these agents — the main session's task registry doesn't know them, so there is no way to stop/dismiss them programmatically. - The parent subagents completed normally and their final reports include the nested agents' findings, so this appears to be a lifecycle/registration issue: nested-agent completion is never propagated to the Background tasks panel once the parent context is gone.
Repro sketch
- Main session dispatches subagent A (Agent tool, e.g. a code-reviewer prompt).
- Subagent A itself dispatches one or more nested agents to verify specific claims.
- Subagent A completes and returns its report.
- Open the Background tasks panel: the nested agents from step 2 remain under "Running" forever;
TaskStopwith their ids fails with "No task found".
Environment
- Claude Code (desktop app, macOS Darwin 25.3.0)
- Model: claude-fable-5
- Multi-subagent flow (implementer/reviewer pattern), reviewers on sonnet
Screenshot
<img width="804" height="1066" alt="Image" src="https://github.com/user-attachments/assets/441a6186-5010-4eaa-83a5-2148f65d83cf" />
Issue co-authored by Claude Fable 5 - Interestingly enough I the human had to come in and type this part
Showing cached comments. Read the full discussion on GitHub ↗
4 Comments
Confirmed reproducing a similar pattern here -- nested agents getting stuck as "Running" after the parent completes is a lifecycle registration gap that bites you specifically in reviewer/implementer flows where the parent is short-lived but the nested validators keep running.
The TaskStop failure ("No task found with ID") points to the core issue: the main session's task registry only tracks agents it directly dispatched. Grandchild agents registered against the intermediate parent's task context, and when the parent exited, that context was torn down -- but the Background tasks panel never got the tombstone event.
A few things that reduce the blast radius while waiting for a fix:
The underlying fix needs to be propagating task lifecycle events through the full agent tree, not just one level deep.
Same root cause as the flat task registry problem in #74133 -- nested subagents spawned by an intermediate agent don't propagate their IDs up the chain, so the main session's TaskStop has nothing to call against them.
The "stuck as Running for 11 hours" behavior makes sense given how the state machine works: the nested agents completed their work and sent their results, but the lifecycle notification that should flip the UI state never traveled up through the intermediate agent to the parent session. The parent never knew to mark them done.
Workaround that helps: in the intermediate subagent's system prompt, add an explicit instruction to collect all child task IDs it spawns and echo them in its final report. The main session can then attempt TaskStop on those IDs directly. It doesn't always work because the IDs aren't in the main session's namespace, but sometimes it does.
The better fix is what you're asking for: automatic propagation of terminal state through the delegation tree, or a TaskList that shows all descendants regardless of dispatch depth.
Confirming this also reproduces on Windows Desktop app (not just macOS reported above), with an additional data point: even the parent agent itself, when resumed via SendMessage and explicitly asked to stop the 4 nested children it had spawned, called
TaskStopon their IDs and gotNo task foundfor all 4 — same result as callingTaskStopdirectly from the main session. So the "no owner context to route the stop through" issue holds even when you go through the original spawning agent, not just the top-level session.Environment: Claude Code Desktop, Windows
Repro: Main session dispatches an agent for a research task (4 independent verification sub-tasks: CVE lookup, GitHub repo stats, third-party source check, npm/PyPI data). The agent spawns 4 nested children via the Agent tool to parallelize this, then returns a consolidated report and completes. The Background tasks panel continued showing all 4 nested children as "Running" for 3h49m+ (token counters: ~65k/73k/63k/104k, frozen). Restarting the app did not clear the display.
TaskStopon the 4 children's IDs →No task found(from main session).Resuming the parent agent via SendMessage and asking it to stop its own children → it also got
No task foundon all 4 IDs when tryingTaskStopitself.No apparent ongoing token cost (consistent with the work having actually finished), but the panel display never clears — purely a UI/lifecycle-tracking bug, matching the root cause theory already discussed in this thread (nested-agent completion never propagated once the intermediate parent's context tears down).
Thanks for the tips! I never thought to put a timeout on subagent fan-out, that seems like a good suggestion for a default instruction for agents.