/clear kills running background agents (regression from late Feb 2026)
Summary
The /clear command now terminates all running background agents/tasks. Previously (before ~late February 2026), /clear only cleared the conversation context while leaving background agents running. This regression breaks the parallel agent orchestration workflow entirely.
Current (broken) behavior
- User launches one or more background agents via the Agent tool with
run_in_background: true. - Agents begin executing (confirmed by "Async agent launched successfully" message).
- User runs
/clearto free up context window space. - All background agents are killed immediately.
- All in-progress work from those agents is lost.
- User must re-launch everything from scratch.
Expected behavior (how it worked before the regression)
- User launches one or more background agents via the Agent tool with
run_in_background: true. - Agents begin executing.
- User runs
/clearto free up context window space. - Background agents continue running undisturbed.
- User receives notifications when background agents complete.
- User can reference agent results in the new (cleared) conversation context.
- User can resume or check on agents by ID if needed.
Steps to reproduce
- Start Claude Code CLI (latest version).
- Launch a background agent:
- Use the Agent tool with a non-trivial task and
run_in_background: true. - Alternatively, ask the model to "run X in the background" which triggers the same mechanism.
- Wait for confirmation that the background agent has started (look for the "Async agent launched successfully" message).
- Run
/clear. - Observe that the background agent process is terminated.
Expected result: The background agent continues running and eventually completes.
Actual result: The background agent is killed when /clear executes.
Impact
This is a critical workflow regression for power users who rely on parallel agent orchestration:
- Context management pattern: Complex multi-agent work fills the context window quickly. The standard workflow is to launch background agents,
/clearto reclaim context, then continue orchestrating with fresh context. This is now impossible without killing all background work.
- Agent manager pattern: A common pattern is to use the main conversation as a "manager" that dispatches work to background agents, clears context to stay within limits, and then checks results.
/cleardestroying agents makes this pattern unusable.
- Lost work: Background agents may be minutes into expensive operations (research, code generation, multi-file edits). Killing them silently causes significant wasted time and effort.
- No workaround: There is currently no way to clear the conversation context without also terminating background agents. Users are forced to choose between running out of context or losing all background work.
Root cause hypothesis
/clear appears to be tearing down all subprocess handles or agent state associated with the conversation, rather than only clearing the conversation transcript and message history. Background agents are independent subprocesses and should not be coupled to the conversation context lifecycle.
Suggested fix
/clearshould only clear the conversation transcript/context and reset the message history. It should not terminate background subprocesses.- If there is a legitimate need to kill background agents, that should be a separate, explicit command (e.g.,
/clear --all,/kill-agents, or/stop-all). - At minimum,
/clearshould warn the user if background agents are running and ask for confirmation before killing them.
Environment
- Product: Claude Code CLI (latest version as of March 2026)
- OS: macOS Sonoma 14.x
- Shell: zsh
- Regression introduced: Approximately late February 2026
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗