[BUG] Agents continue working after multiple interruptions and /clears
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Version: 2.1.42
Login method: Claude Max Account
Model: Default Opus 4.6 · Most capable for complex work
MCP servers: trello ✔
Memory: project (CLAUDE.md)
Setting sources: User settings, Project local settings
Background agents launched via Task tool with run_in_background: true survive multiple user interrupts (Escape), /clear commands, and manual kills via the task
manager UI (k key). The main agent resurrects and delivers output long after the user has explicitly stopped all work.
### Sequence of events:
- Claude (Opus 4.6) launched 3 background investigation agents via
Taskwithrun_in_background: true - I interrupted the main agent (Escape) and ran
/clear - The 3 background agents were still visibly running in the task manager — I navigated to each (arrow down) and killed them with
k - Status bar confirmed no background processes remaining
- Despite this, the main agent resurrected and stopped responding to Escape — I had to type "Claude stop" and "stop" as text input to get it to acknowledge
- I ran
/cleara second time - ~30 seconds later, a full multi-page response appeared in the terminal as if Claude was actively responding — with zero indication anything was still running
### Key details:
- The
kkill in task manager did not actually terminate the agents (or something downstream survived) - The main agent became unresponsive to Escape after resurrecting
- The status bar showed no background work, but execution was clearly still happening
- Two
/clearcommands, multiple Escape presses, manualkkills, and typed "stop" commands were all insufficient to halt execution
What Should Happen?
What Should Happen?
kin the task manager should hard-kill background agents — confirmed dead, no further output/clearshould be a hard reset — kill all in-flight agents (foreground and background) and suppress any pending output- Escape should always remain responsive — the main agent should never enter a state where Escape stops working
- No output should surface after
/clear— if agents were killed or conversation was cleared, their results should be discarded, not queued for delivery - The status bar should be accurate — if it shows no background processes, nothing should be running
Error Messages/Logs
Error Messages/Logs
No error messages or stack traces. The issue is behavioral — agents silently continued
executing and delivered output after being killed and after the conversation was cleared.
No logs were captured as the output appeared unexpectedly after /clear with no prior
indication of ongoing work.
Steps to Reproduce
Steps to Reproduce
- Start a Claude Code session with a codebase available for investigation
- Give Claude a task that causes it to launch multiple background agents
(e.g., "investigate these 12 findings in the codebase" — Claude will
typically parallelize with 3+ background Task agents using
run_in_background: true)
- Wait for background agents to appear in the task manager (visible via
arrow-down or status bar)
- Press Escape to interrupt the main agent
- Run
/clear - Navigate to each background agent in the task manager and press
kto kill - Confirm status bar shows no background processes
- Wait 30-60 seconds
Expected: Nothing happens. Session is clean.
Actual: The main agent resurrects and delivers a full response. Escape
may stop working. A second /clear may also fail to prevent output delivery.
Note: Reproduction may depend on timing — the agents need to be mid-execution
(not yet complete) when killed. Longer-running investigations (reading many
files) are more likely to trigger this.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude Code Version: 2.1.42
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
---
Additional Information
- MCP servers active at time of issue: trello
- The background agents were Explore-type subagents performing codebase
searches (Glob, Grep, Read operations across multiple files)
- The final output that surfaced after the second /clear was a complete,
well-formatted multi-page report — suggesting the agent ran to full
completion despite being "killed"
- This suggests the kill signal either didn't propagate to the underlying
process, or the output was already buffered/queued and delivered regardless
of conversation state
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗