Background sub-agents spawned by a subagent stay "Running" forever after the parent completes; TaskStop can't reach them

Open 💬 2 comments Opened Jul 3, 2026 by princeradebe

Summary

When a background agent (spawned from the main session via the Agent tool with run_in_background: true) itself spawns children with run_in_background: true and then ends its turn, the children finish their work but remain listed as "Running" in the Background tasks panel indefinitely. The main session cannot stop them — TaskStop with their agent IDs returns No task found (they are registered to the completed parent's context). The only way to remove them is the panel's per-row stop button or "Clear".

Environment

  • Claude Code 2.1.170, macOS (Darwin 25.5.0), desktop app UI
  • Model: claude-fable-5

Steps to reproduce

  1. From the main conversation, spawn an agent with run_in_background: true.
  2. That agent spawns two of its own children with run_in_background: true, then ends its turn ("I'll wait for the two background subagents to finish") — i.e. it stops while its children are still alive.
  3. The parent's task-notification fires in the main session; resume the parent via SendMessage; it verifies the children's output and completes normally.
  4. Watch the Background tasks panel.

Expected

Children of a completed subagent are reaped or re-parented once they finish; the panel reflects a terminal state; the main session can address them by ID.

Actual

  • The children's transcripts (subagents/agent-<id>.jsonl) stop growing — mtimes frozen at 18:35:46 and 18:37:14 — confirming their work finished.
  • The panel still showed both as "Running" 15+ minutes later, elapsed timers ticking (12m+), token counters frozen.
  • TaskStop from the main session with either child's agent ID → No task found with ID: <id>.
  • No programmatic way to clear them; they persist until manual panel stop/Clear.

Possibly related: #68992 (stale background-task bookkeeping for shell commands / stuck "running" badge). This report is specifically about nested Agent children orphaned by parent completion, which additionally breaks TaskStop addressing from the main session.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗