No way to kill running agent tasks (Task tool)
Resolved 💬 2 comments Opened Feb 28, 2026 by karthic-kikoff Closed Mar 28, 2026
Problem
When an agent is launched via the Task tool with run_in_background: true, there is no way to terminate it. KillShell only works on background bash processes — it errors with "Task X is not a local bash task" when given an agent task ID.
Why this matters
- Stale instructions — If you update project rules (e.g., CLAUDE.md) mid-session, running agents don't pick up the changes. You're forced to launch a new agent, but the old one keeps running with outdated behavior.
- Conflicting agents — Two agents can end up operating on the same branch/PR simultaneously (e.g., two pr-watchers pushing to the same branch), causing conflicts or duplicate work.
- No control — The user has no mechanism to stop a misbehaving or no-longer-needed agent. You just have to wait for it to finish on its own.
Expected behavior
KillShell should work on agent tasks, or there should be a dedicated KillTask / KillAgent tool that can terminate any background task by ID.
Reproduction
- Launch an agent in the background:
Taskwithrun_in_background: true - Try to kill it:
KillShellwith the agent ID - Get error: "Task X is not a local bash task"
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗