Skip to content

Claude threads: no way to stop or background one running tool call without Stop ending every subagent #38068

Closed as not planned

Description

@edwardEsmerson

What happened

A foreground tool call in a Claude thread was taking much longer than expected while subagents were running beside it. I wanted to end or detach just that call and keep the subagents going.

Stop is the only control that reaches the call, and it ends every subagent and background command in the thread. Sending a follow-up with Follow-up behavior set to Steer doesn't help: the message waits until the call finishes.

Auto-backgrounding every long command isn't the answer either, because sometimes I want a command to stay in the foreground. What's missing is a per-call control: stop this call, or move it to the background, without touching the rest of the turn.

Diagnosis

  • Stop runs interruptTurn in ClaudeAdapterV2.ts: query.interrupt() then query.close(). Closing ends the Claude Code process, and every subagent and background command goes with it.
  • Steer (steerTurn) moves running subagents to the background with backgroundTasks(toolUseId), then sends the message with priority: "now". A lone running Bash call is not cancelled by it; the message is read after the call ends. fix(server): steers on Claude threads no longer cancel running tool calls #35088 would switch steers to priority: "next", so after it lands, steering never ends a running call.
  • The Agent SDK already has per-call controls that T3 doesn't use for tool calls:
    • query.stopTask(taskId), with the task id Claude Code assigns a running Bash call (the task_started message carrying that call's tool_use_id), kills only that call. The model gets Exit code 137 [killed] and the turn continues.
    • query.backgroundTasks(toolUseId) with the Bash call's id moves only that call to the background (the Ctrl+B equivalent). It keeps running and the model is told when it finishes.

T3 calls stopTask only for subagents and workflows, and backgroundTasks only for subagents during a steer.

Possible direction, a design call for maintainers: "Stop this call" and "Move to background" actions on a running tool call, wired to those two SDK calls, with commands staying in the foreground by default.

Steps to reproduce

Not reproduced through the app UI. These are Agent SDK runs that send the same calls T3 sends:

  1. Start a Claude query. Launch a subagent with run_in_background: true that sleeps 45 s, then writes a file.
  2. Run a foreground Bash call that sleeps 40 s, then writes a file.
  3. About 6 s into the Bash call, apply one action:
Action Bash call Subagent
T3 Stop (interrupt() + close()) killed killed
T3 Steer (priority: "now" message) not cancelled; message read after it ended finished
stopTask(<Bash task id>) only it killed, turn continued finished
backgroundTasks(<Bash tool_use id>) moved to background, finished finished

In the app: a Claude thread with a background subagent runs a long foreground command; there is no way to end only that command.

Version

0.1.10-nightly.20261116.4774 (code paths also checked on main at 215bd59)

Environment

Linux (kernel 7.0), Node 22.22.1, Claude Code 2.1.323, @anthropic-ai/claude-agent-sdk 0.3.276, Claude Haiku 5.5 for the SDK runs

Evidence

# stopTask on the Bash call's task
[10.5s] system task_started bok2j8gj9 [main Bash]
[13.4s] system task_notification bok2j8gj9 stopped [main Bash]
[13.4s] tool_result [main Bash]: Exit code 137 [killed]
[55.5s] system task_notification a7df2b4b76bac097d completed [Agent]

# T3 Stop
[13.5s] interrupt()
[13.5s] system task_notification ad8d9a78a58275212 stopped [Agent]
[13.5s] close()

Related issues

#21895 / #35088 make steers stop cancelling tools, which leaves Stop as the only way to end a stuck call. #37876: one tool's OOM kill takes down the agent and its subagents. Discussion #15287. None asks for a per-call stop or background control.

Fix applied or workaround

None applied. Claude Code's CLAUDE_CODE_AUTO_BACKGROUND_TIMEOUT_MS moves every main-thread Bash call to the background after N ms, but that changes all commands, which is not what I want.

Activity

  1. juliusmarminge commented on Nov 17, 2026

    @juliusmarminge
    Member

    Thanks for writing this up. It asks for new behaviour rather than reporting a defect, so it does not belong in the bug tracker and I'm closing it as not planned here. Feature ideas are discussed in Discussions: please post it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions