You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Start a Claude thread in full-access runtime mode.
In one turn, start two pieces of background work and confirm both are progressing:
a background Bash command (run_in_background) that appends a counter line to a file every 5 s;
a background subagent (Agent tool, run_in_background) that runs 24 short timed steps (about 4 min) and appends one line per step to a second file.
While both are still running, change the thread's runtime mode in the composer (Full access → Auto-accept edits) and send any message.
Watch the thread, the two files, and the thread's orchestration events.
The worktree-change and provider-instance-switch paths go through the same detach (see Actual behavior); their trial results will follow in a comment.
Expected behavior
The same protection #14726 added for model and effort changes: while Claude still has background agents or commands running, a change that ends the Claude CLI process is refused or deferred with a clear, retryable message, and the background work is not lost. The guard's own comment gives the reason: "Background agents and shells run inside the CLI process, so a new selection would kill them and lose their results" (
Sending the message with the new runtime mode ends the Claude session at once, with no refusal or warning, and the running subagent is killed. In one controlled trial (times UTC, from the thread's events and the two progress files):
04:21:59.207 the message is sent: provider-session.detached, reason "Runtime mode changed."
04:21:59.291 the subagent goes to failed, 84 ms later. Its progress file stopped at step 18 of 24 and its completion marker never appeared (checked at T+305 s).
04:22:01.256 a new provider session attaches. The UI shows "Provider error — The provider event stream closed unexpectedly", the background agent as Failed mid-run, and the new session says the background command and subagent "were reported stopped when the previous session ended."
A note on background shells (not a confirmed T3 defect): in the same trial, our background Bash loop kept writing to its file after T3 and the new session reported it stopped (40 lines at the change, 64 at +120 s). We believe this is an artifact of our harness: the loop's timeout child is reparented and escapes the CLI teardown. We did not test a background command that stays inside the CLI process tree, so we report it only as an observation.
Runtime-mode, worktree and provider/instance changes go through dispatchThreadMutation, which emits provider-session.detached and a detach effect with no pending-background check (
Searched before filing (open and closed): "runtime mode background subagent", "worktree handoff background", "kills background agents", "BackgroundWorkBlocks", "provider-session.detached" (only #15695, unrelated). The closest report is #12694, closed by #14726, which guards model and effort replacement; this is the adjacent unguarded set (runtime mode, instance, worktree).
Suggested fix: apply the pending-background-work check before the session detach/restart, as #14726 does for query replacement (refuse with the same retryable message, or defer until the background roster is empty); on a detach, stop or reattach tracked background shells rather than reporting them stopped.
Linux x64 container, self-hosted t3 server, Node 24.13.1, Claude Code 2.1.289, Codex 0.160.0; Claude via an API-compatible proxy (not involved)
Logs or stack traces
04:18:33.352Z provider-session.attached status=ready
04:21:59.096Z subagent.updated status=running (last running update)
04:21:59.207Z provider-session.detached reason="Runtime mode changed."
04:21:59.291Z subagent.updated status=failed
04:22:01.256Z provider-session.attached status=ready (new session)
subagent progress file: 18 of 24 steps; no completion marker at T+305 s
background bash counter: 40 lines at the change, 64 at T+120 s, ran to its timeout (reported stopped)
Screenshots, recordings, or supporting files
No response
Workaround
Wait for background agents and commands to finish, or stop them, before changing the runtime mode, the provider instance or the worktree.
Before submitting
Area
apps/server
Steps to reproduce
full-accessruntime mode.run_in_background) that appends a counter line to a file every 5 s;run_in_background) that runs 24 short timed steps (about 4 min) and appends one line per step to a second file.The worktree-change and provider-instance-switch paths go through the same detach (see Actual behavior); their trial results will follow in a comment.
Expected behavior
The same protection #14726 added for model and effort changes: while Claude still has background agents or commands running, a change that ends the Claude CLI process is refused or deferred with a clear, retryable message, and the background work is not lost. The guard's own comment gives the reason: "Background agents and shells run inside the CLI process, so a new selection would kill them and lose their results" (
t3code/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
Lines 6939 to 6952 in efecd3c
Actual behavior
Sending the message with the new runtime mode ends the Claude session at once, with no refusal or warning, and the running subagent is killed. In one controlled trial (times UTC, from the thread's events and the two progress files):
provider-session.detached, reason "Runtime mode changed."failed, 84 ms later. Its progress file stopped at step 18 of 24 and its completion marker never appeared (checked at T+305 s).A note on background shells (not a confirmed T3 defect): in the same trial, our background Bash loop kept writing to its file after T3 and the new session reported it stopped (40 lines at the change, 64 at +120 s). We believe this is an artifact of our harness: the loop's
timeoutchild is reparented and escapes the CLI teardown. We did not test a background command that stays inside the CLI process tree, so we report it only as an observation.Source at efecd3c:
dispatchThreadMutation, which emitsprovider-session.detachedand a detach effect with no pending-background check (t3code/apps/server/src/orchestration-v2/Orchestrator.ts
Lines 3209 to 3290 in efecd3c
supportsRuntimeModeSwitchInSession: false(t3code/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
Line 183 in efecd3c
restart_and_resume(t3code/apps/server/src/orchestration-v2/ProviderSessionTransitionPolicy.ts
Lines 55 to 77 in efecd3c
t3code/apps/server/src/orchestration-v2/ProviderSwitchService.ts
Lines 186 to 199 in efecd3c
detachcallsreleaseEntry(reason: "manual_shutdown"), closing the CLI process (t3code/apps/server/src/orchestration-v2/ProviderSessionManager.ts
Lines 1912 to 2016 in efecd3c
hasPendingBackgroundWorkis consulted only on idle release (t3code/apps/server/src/orchestration-v2/ProviderSessionManager.ts
Lines 1005 to 1061 in efecd3c
Searched before filing (open and closed): "runtime mode background subagent", "worktree handoff background", "kills background agents", "BackgroundWorkBlocks", "provider-session.detached" (only #15695, unrelated). The closest report is #12694, closed by #14726, which guards model and effort replacement; this is the adjacent unguarded set (runtime mode, instance, worktree).
Suggested fix: apply the pending-background-work check before the session detach/restart, as #14726 does for query replacement (refuse with the same retryable message, or defer until the background roster is empty); on a detach, stop or reattach tracked background shells rather than reporting them stopped.
Impact
Major degradation or frequent failure
Version or commit
v0.0.46-nightly.20261004.2657 (efecd3c)
Environment
Linux x64 container, self-hosted t3 server, Node 24.13.1, Claude Code 2.1.289, Codex 0.160.0; Claude via an API-compatible proxy (not involved)
Logs or stack traces
Screenshots, recordings, or supporting files
No response
Workaround
Wait for background agents and commands to finish, or stop them, before changing the runtime mode, the provider instance or the worktree.