Subagents' background Bash tasks outlive the subagent; orphaned polling loops run for an hour with no way for the parent to stop them

Status Open
Reported on v2.1.260
Maintainer reply None cached
Activity 1 comment · opened Sep 12, 2026

Environment: Claude Code 2.1.260 in the Claude Desktop app (macOS, Code tab), desktop app 1.52386.3. Related: #93880.

What happens: When a subagent (Agent tool, run_in_background: true) starts a Bash command with run_in_background: true and then finishes or is told to stop, those Bash tasks keep running. Today several subagents left behind polling loops (until ... do sleep 3; done, while ps ... | grep ...; do sleep 15; done). They ran for 45 to 60 minutes after their agents had reported completion, showed in the user's Background tasks panel, and could only be found and killed by the orchestrator via ps and kill. Some of the loops matched their own command line and could never exit on their own.

Why it matters: the user sees a growing list of hour-old tasks they did not start; the loops consume shells and, in the tsc-waiter case, block the very typecheck they wait for; and the orchestrating session has no tool to enumerate or stop a subagent's background tasks (TaskStop covers its own tasks, not a child agent's).

Expected:

  1. A subagent's background Bash tasks are terminated (or at least surfaced to the parent with their ids) when the subagent's turn ends, unless it explicitly hands them off.
  2. The parent session can list and stop background tasks started by its subagents.
  3. The Background tasks panel offers a "stop all from finished agents" action.

Repro: spawn a background agent whose brief makes it run until false; do sleep 3; done with run_in_background: true and then return a report. The loop outlives the agent indefinitely and appears in the user's Background tasks panel with no owner.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗