Background subagent never re-woken when its tracked background Bash child exits (child survives, wake event lost)
Environment
- Claude Code v2.1.209 (CLI), macOS (Darwin 24.6.0)
- Model: claude-fable-5 (main session), subagent spawned via Agent tool (
subagent_type: general-purpose,model: opus) - Main session itself runs as a background job session
Summary
A background subagent that launches a tracked background Bash command (run_in_background: true) and then ends its turn is immediately reported to the parent as stopped/completed — the task-notification note says it fires when the agent stops "with no live background children of its own" — even though the child was just launched and is alive. The subagent also disappears from the TUI's agent view at that moment. When the child later exits (even ~90 seconds later), the subagent is never re-invoked. The child process itself is fine: it keeps running, and on exit its tasks/<id>.output file contains the expected final output. Only the wake event is lost. The subagent stays dormant until manually resumed via SendMessage, which responds "Agent … had no active task; resumed from transcript".
Repro pattern
- Main session spawns a subagent via the Agent tool.
- The subagent starts a remote job (detached tmux over ssh) and then launches a tracked waiter as its wake signal:
Bash(run_in_background: true): ssh host 'while tmux has-session -t <job> 2>/dev/null; do sleep 30; done'.
- The subagent ends its turn, expecting re-invocation when the waiter exits (the documented contract for tracked background children).
- The parent immediately receives a task-notification for the subagent with
status: completed, despite the live child; the subagent simultaneously disappears from the TUI. - Minutes later the waiter exits cleanly; its output file is written with the expected content.
- The subagent is never re-invoked. SendMessage to it returns "had no active task; resumed from transcript".
Measured timeline (three reproductions in one session, same day; file birth/mtime of the waiter output files)
| repro | waiter child born | child exited | child lifetime | subagent re-woken? |
|---|---|---|---|---|
| 1 | 17:30:04 | 17:31:35 | 91 s | no |
| 2 | 17:35:41 | 17:40:42 | ~5 min | no |
In both cases the parent's completed notification for the subagent arrived within seconds of the subagent ending its turn — i.e. while the child was demonstrably alive (it later wrote its completion output).
Two earlier sessions (Jul 10) hit the same symptom with coordinator-measured phase lengths of 9 min and 14 min. So this is not a long-timeout/expiry issue — children lasting 1.5–15 minutes all fail to re-wake their subagent. It appears deterministic for this pattern.
Expected
A subagent with a live tracked background child should not be treated as "stopped with no live background children" (nor removed from the TUI), and the child's exit should re-invoke the subagent.
Control
The main session's own background children with identical command shape (same ssh waiter against the same host) wake the main session reliably — same session, same day, every time. The loss appears specific to background children of subagents: either the child is disowned from the subagent's task tracking the moment the subagent's turn ends, or the child-exit event is not routed to re-invoke an already-completed subagent.
Impact / workaround
Remote jobs orchestrated by subagents complete silently and the pipeline stalls until a human notices. Workaround: the parent session duplicates every watcher (coordinator-side backstop) and SendMessage-nudges the subagent when the real completion is observed — doubling the monitoring plumbing.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗