Background task chips persist as 'Running' after subagent exits; Stop button no-ops

Open 💬 6 comments Opened May 18, 2026 by gmcdowell

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

  1. From the parent session, delegate work to a subagent via the Agent tool (e.g. subagent_type: reviewer).
  2. Inside that subagent, run one or more Bash calls with run_in_background: true (e.g. polling a long-running command while it waits to complete).
  3. Let the subagent complete and return its result to the parent.
  4. 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 — TaskStop requires a task_id that 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)

  1. Reap background tasks at subagent exit — same boundary that bounds the subagent's tool context.
  2. Promote chip state on process death — if the PID is gone, mark the chip Completed/Failed instead of Running.
  3. Make Stop force-clear the chip when no process matches, even if it can't signal anything.
  4. Surface a BackgroundTaskList tool to the parent agent so it can enumerate and clean up tasks left behind by subagents.

View original on GitHub ↗

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