Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Stop on a Claude thread kills its background agents, commands and delegated children, with no notice to the thread #46329

Opentheotherzach(GitHub profile, opens in a new tab) opened this issue 0 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Start a Claude thread.
  2. Ask it to start a background Bash command (run_in_background) that runs for 4 minutes and then writes a file.
  3. In the same turn, ask it to start a background agent with the Agent tool and run_in_background. The agent works for 4 minutes and then writes a file. A delegate_task child that does the same shows the cascade.
  4. Let the turn end. The thread shows the work as pending.
  5. Press Stop, or send thread.stop.
  6. Wait 5 minutes.

I ran these steps with Stop sent while the thread was idle and waiting on the work. In real use I hit the same loss when I pressed Stop on a running turn. An earlier turn had started the background work.

Expected behavior

Stop on a running turn ends that turn. Background work that earlier turns started keeps running, as it does when I press Esc in Claude Code's terminal.

If Stop has to end background work, any one of these would fix the loss:

  • Interrupt a Claude turn without closing the query.
  • Offer two Stop actions. "Stop this turn" keeps background work, and "Stop everything" ends it.
  • At the least, post a message to the thread that names each task Stop ended.

Actual behavior

Stop closes the whole Claude Code process. Every piece of background work the thread's session started ends in the same second:

  • background Bash commands,
  • background agents,
  • commands those agents started,
  • delegate_task children, whose results are thrown away.

The thread gets no message. It learns of the loss only on its next turn, from Claude Code's "didn't finish before the previous session ended" notice. In my case the Stop ended an agent before it committed its code changes, and it ended a long test run.

In the repro, none of the files appeared, and none of the processes survived 20 seconds past the Stop.

What I found in the bundled server code:

  • ClaudeAdapterV2.interruptTurn calls query.interrupt and then always calls query.close.
  • The Claude runtime sets backgroundTasksEndWithProcess: true, so every background task ends with the process.
  • Orchestrator.dispatchThreadStop adds a delegated-tasks.stop effect unless the command sets stopDelegatedTasks: false. The web Stop control never sets it. ThreadManagementService.stopDelegatedTasks then sends thread.stop to each active child.
  • disposeDelegatedCompletionCohort disposes the child's pending result, so nothing reaches the parent.

The idle release is not involved. ProviderSessionManager.releaseIfStillIdle put the release off for as long as the background work was live, with nothing registered through t3_background_wait.

Impact

Major degradation or frequent failure

Version or commit

0.1.12-nightly.20261124.5209

Environment

macOS, T3 Code (Nightly) desktop app, Claude provider, Claude Opus 5.5 and Claude Haiku 4.5

Logs or stack traces

# Real use: Stop pressed 5 seconds into a running turn. Times are seconds after the Stop.
+0.00  ws.rpc.orchestration.dispatchCommand  command_type=thread.stop
+0.66  task_updated  background agent      status=killed
+0.66  task_updated  background command    status=killed
+0.66  outgoing query.interrupt
+0.71  outgoing query.close
+0.77  task_updated  background command    status=killed
+18.5  query.open resume: "didn't finish before the previous session ended"

# Repro with a delegate_task child: Stop sent to the idle parent.
+0.000  thread.stop  thread=<parent>
+0.014  ThreadManagementService.stopDelegatedTasks
+0.018  thread.stop  thread=<delegated child>

Workaround

Send the next message without pressing Stop. The composer steers the running turn, and the background work survives.

  1. tanstack-source added labelsbug

Sign in to join this conversation.