[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)
- 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. - Send it a
shutdown_requestvia SendMessage. Observed: the agent wakes (emitsidle_notifications) but never sendsshutdown_responseand never terminates. Process still alive 3+ minutes later. Across 3 earlier orchestrator sessions (Opus and Fable): 86shutdown_requests sent, 0 responses, 0 terminations. - Call
TaskStop(task_id="shutdown-test-dummy"). Observed: returnsSuccessfully stopped task ... in_process_teammate— but the OS process (same PID) is still alive afterward. - For agents that finished ~1h earlier,
TaskStopreturnsNo task found with ID: <name>while their processes are still running — the registry ages out finished agents but their processes persist. - 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).
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗