Background task chips persist as 'Running' after subagent exits; Stop button no-ops
Summary
Background Bash tasks (run_in_background: true) started inside a delegated subagent persist in the parent session's "Background tasks → Running" panel after the subagent exits. The underlying processes are gone (ps confirms), but the chips remain, and the Stop button silently does nothing — presumably because there's no process to signal.
The only way to clear them is to restart Claude Code.
Environment
- Claude Code version: 2.1.141
- Platform: macOS (Darwin 25.3.0)
- Shell: zsh
- Model: claude-opus-4-7 (1M context)
Reproduction
- From the parent session, delegate work to a subagent via the
Agenttool (e.g.subagent_type: reviewer). - Inside that subagent, run one or more
Bashcalls withrun_in_background: true(e.g. polling a long-running command while it waits to complete). - Let the subagent complete and return its result to the parent.
- Open the "Background tasks" panel in the parent session.
Expected: background tasks scoped to the subagent are reaped when the subagent exits, or at minimum the chips reflect a terminal state (completed/cancelled).
Actual: the chips remain pinned to "Running" indefinitely. ps -ef shows no matching processes — they're already gone. Clicking "Stop" on the chip does nothing visible (no state change, no log entry, no error). Restart clears them.
Why this matters
- Misleading UX: looks like work is still happening when nothing is.
- The parent agent has no way to introspect or clean these up either —
TaskStoprequires atask_idthat the parent never received (the ID was returned inside the subagent's context, not the parent's). There's no "list background tasks" tool surfaced to the parent. - Users can't tell genuinely stuck tasks from stale chips.
Suggested fixes (any one would help)
- Reap background tasks at subagent exit — same boundary that bounds the subagent's tool context.
- Promote chip state on process death — if the PID is gone, mark the chip Completed/Failed instead of Running.
- Make Stop force-clear the chip when no process matches, even if it can't signal anything.
- Surface a
BackgroundTaskListtool to the parent agent so it can enumerate and clean up tasks left behind by subagents.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗