Background sub-agent (Agent tool) killed with 'stopped by the user' when user did not send a stop

Status Open
Maintainer reply None cached
Activity 0 comments · opened Aug 16, 2026

Summary

While running Claude Code interactively, a background sub-agent I had dispatched via the Agent tool (a coder-type agent, isolation: worktree, non-fork) was terminated. The harness reported this to the orchestrating session as:

Background agent "<task description>" was stopped by the user.

I did not send any stop/interrupt/kill action, intentionally or otherwise, targeting that agent. When I flagged this to Claude in the session, it correctly did not assume the report was accurate and asked me directly rather than treating the kill as confirmed-by-me.

What I was doing at the time

The agent had been running in the background for several minutes while I was actively interacting with the main session in the same terminal — asking unrelated follow-up questions (about a separate cost/benefit summary Claude had produced). I was not attempting to cancel, interrupt, or otherwise stop the sub-agent, and did not use any stop/cancel affordance (no Ctrl-C, no explicit "stop" command, no UI action aimed at the sub-agent).

Suspected cause

Possibly a stray keypress or terminal input event during normal typing/interaction with the main session getting misrouted as a stop/interrupt signal to the background sub-agent, or a race between a task-completion/notification event and unrelated input handling.

Impact

The killed agent had done real, non-trivial work in its isolated git worktree (uncommitted file edits across 5 files) before being killed. The work was not lost — the worktree persisted on disk and I was able to resume by dispatching a fresh agent into the same worktree path — but this seems like it could cause real, silent work loss for a user who doesn't notice the "stopped by the user" notification and doesn't realize they didn't actually send that stop.

What would help

  • Any additional signal in the "stopped by the user" notification about what triggered the stop (which input/action), so a user can tell a genuine stop from a spurious one.
  • Investigation into whether background-agent stop handling can be triggered by input intended for the foreground/main session.

Environment

  • Claude Code CLI, interactive terminal session
  • Sub-agent dispatched via the Agent tool with subagent_type: "coder" and isolation: "worktree" (not a fork)
  • Happened once so far; have not yet confirmed reproducibility

Reported on behalf of the user by their Claude Code session, per their request.

View original on GitHub ↗