claude-code - 💡(How to fix) Fix Background task chips persist as 'Running' after subagent exits; Stop button no-ops

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Error Message

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.

Root Cause

  • 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.
RAW_BUFFERClick to expand / collapse

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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING