[BUG] Background agents/teammates never terminate: shutdown_request unanswered, TaskStop reports success while process survives

Open 💬 1 comment Opened Jul 6, 2026 by tomc98

Environment

  • Claude Code v2.1.201 (latest at time of filing), macOS (Darwin 25.5.0), agent teams enabled (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), in-process teammate mode

Summary

Finished background agents / teammates park as live claude --agent-id <name>@session-<id> OS processes indefinitely. Every in-band termination mechanism fails to kill the process, so orchestrator sessions leak agents until the user kills PIDs manually. Over time the leaked processes exhaust the fork/pane budget (respawn pane failed: fork failed, no space for new pane).

Repro (all verified live in one session today)

  1. Spawn a trivial background agent via the Agent tool (name: shutdown-test-dummy, prompt "reply DONE"). It completes and goes idle. pgrep -fl -- "--agent-id" shows its process.
  2. Send it a shutdown_request via SendMessage. Observed: the agent wakes (emits idle_notifications) but never sends shutdown_response and never terminates. Process still alive 3+ minutes later. Across 3 earlier orchestrator sessions (Opus and Fable): 86 shutdown_requests sent, 0 responses, 0 terminations.
  3. Call TaskStop(task_id="shutdown-test-dummy"). Observed: returns Successfully stopped task ... in_process_teammate — but the OS process (same PID) is still alive afterward.
  4. For agents that finished ~1h earlier, TaskStop returns No task found with ID: <name> while their processes are still running — the registry ages out finished agents but their processes persist.
  5. Only kill <pid> works.

Expected

Some in-band mechanism (TaskStop, shutdown protocol, or automatic reaping on completion/timeout) actually terminates the agent process. TaskStop in particular should not report success while the process survives.

Notes

  • Timeline correlation: TeamCreate/TeamDelete-era sessions (pre ~v2.1.19x) cleaned up via TeamDelete; after the move to the single-implicit-team model there is no working replacement.
  • Likely related: #28552 (closed as duplicate), #33043 (no force-kill for agents ignoring shutdown_request), #29271 (idle-vs-dead indistinguishable), #24385 (panes not closed).

View original on GitHub ↗

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