Background agents cannot be killed and run indefinitely, burning tokens
Resolved 💬 3 comments Opened Mar 21, 2026 by mably Closed Mar 21, 2026
What' + chr(39) + 's Wrong?
Background agents launched via the Agent tool with run_in_background: true cannot be stopped once launched. There is no kill mechanism. Agents that get stuck in loops or fail to make progress continue running for hours, consuming tokens with zero useful output.
What Should Happen?
There should be a way to kill background agents — either via a /kill command, a TaskStop tool, or automatic timeout after a configurable period.
Steps to Reproduce
- Launch a background agent with a complex task
- Agent gets stuck (e.g. repeatedly reading API logs, failing to push code)
- Agent output grows to 1MB+ over hours
- No way to stop it — it runs until hitting the context limit
Impact
In our case, 4 zombie agents ran for 4+ hours, producing 1.2MB of output each with zero useful results. This is significant token waste on a Max subscription.
Suggested Fix
- Add a
TaskStoptool or/kill <agent_id>command - Add configurable timeout for background agents (default 30 minutes?)
- Auto-kill agents that have not produced a tool call in >5 minutes
Environment
- Claude Code version: 2.1.81
- Model: claude-opus-4-6
- OS: macOS Darwin 24.6.0
- Terminal: iTerm2
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗