fix(server): a Claude steer no longer waits behind a running foreground command #37756
main fromrefs/pull/37756/head·opened View on GitHubProblem#
A steer sent to a Claude thread during a long foreground Bash command is not read until the command ends. Claude Code holds a "now" message behind a foreground Bash call. People wait minutes for an answer, then press Stop and lose the message.
Fix#
Before a steer, the adapter already moves the turn's foreground subagents to the background with Query.backgroundTasks. It now does the same for the turn's running commands. The command keeps running, the agent reads the steer at once, and the command's result reaches the agent when it ends. This is what Claude Code's own send-now (ctrl+x ctrl+s) does in the terminal.
Only a steer that a person or an agent sent moves a command. A delivery T3 writes itself, such as a child's result, waits for the command as before. Queue does not change.
Credit#
This replaces #36170 by @MohamedTahaAmer. Their commit is kept with its authorship. The second commit adds the server-delivery limit and its test case.
Fixes #15720 for Claude.
Verification#
Live run on this branch: isolated dev server, real Claude Code, claude-haiku-5-5. The thread ran python3 -c "import time; time.sleep(150); print('SLEEP_DONE')" in the foreground. 40 s in, I sent "Reply with only the word PONG." with the composer's Steer button.
20:08:19.174 in task_started <- the foreground command
20:08:57.991 Steer button clicked
20:08:58.177 out query.background_tasks
20:08:58.177 out prompt priority=now <- the steer
20:08:58.187 in tool_result "Command was manually backgrounded by user"
20:09:01.137 in assistant "PONG" <- 3 s after the steer
20:10:46.191 in task_notification completed <- same PID, full 150 s
20:10:50 assistant "The sleep command finished with exit code 0. Its output was SLEEP_DONE."
The adapter test moves a running foreground command to the background before a steer checks that a server-written steer moves nothing, that a user steer moves only the Bash call (not a running Read), and that the move goes out before the steer. vp run check:changed passes.
Not checked: macOS, Windows, and a session with CLAUDE_CODE_DISABLE_BACKGROUND_TASKS set (the SDK throws, the adapter logs a warning, and the steer goes out as before).
Co-authored-by: Mohamed Amer <58145820+MohamedTahaAmer@users.noreply.github.com>
Created with Claude Fable 5.2 in Claude Code.
🤖 Generated with Claude Code
- 1
t3dotgg(GitHub profile, opens in a new tab) linked this to fix #15720
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
ba14cf2Macroscope's review found this PR approvable — Claude steers can now proceed while foreground commands continue in the background, with results delivered when they finish. Server-generated deliveries retain their existing behavior, and a reported live exercise confirms the intended command lifecycle.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 1 1 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Other scenarios#
All 64 scenario measurements match
main.All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling Codex short turn resumeWebSocket decoded10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅ Codex short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn running, cold openHTTP decoded281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅ Codex long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Codex long turn running, history pageHTTP decoded92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅ Codex long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Codex long turn finished, cold openHTTP decoded381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, socket cold openWebSocket decoded381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, work pageHTTP decoded186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅ Codex long turn finished, work pagerows150 150 0 (0.0%) 150 ✅ Codex idle thread resumeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell snapshotHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Codex fleet shell subscribeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Codex fleet shell resume checkrows0 0 0 0 ✅ Codex stale shell reloadHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex stale shell reloadrows27 27 0 (0.0%) 27 ✅ Codex stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Codex stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex stale todo list cold openHTTP decoded72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅ Codex stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Codex stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Codex stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Codex stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Codex stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Codex stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Claude short turn resumeWebSocket decoded10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅ Claude short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn running, cold openHTTP decoded283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅ Claude long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Claude long turn running, history pageHTTP decoded93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅ Claude long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Claude long turn finished, cold openHTTP decoded384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, socket cold openWebSocket decoded384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, work pageHTTP decoded188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅ Claude long turn finished, work pagerows150 150 0 (0.0%) 150 ✅ Claude idle thread resumeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell snapshotHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Claude fleet shell subscribeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Claude fleet shell resume checkrows0 0 0 0 ✅ Claude stale shell reloadHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude stale shell reloadrows27 27 0 (0.0%) 27 ✅ Claude stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Claude stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude stale todo list cold openHTTP decoded73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅ Claude stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Claude stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Claude stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Claude stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Claude stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Claude stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Baseline:
02f8a32· PR result:ba14cf2· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
No actionable comments were generated in the recent review.
Walkthrough
-
The Claude adapter now supports moving a foreground command to the background before offering eligible priority-now steers. Server-created agent messages do not trigger command moves. Tests cover the distinction between server-originated and user-originated steers.
Changes: Claude steer handling
Layer / File(s) Summary Move foreground work
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsThe combined mover can include root-turn foreground commands, reuse in-flight moves, and log failures separately for commands and subagents. Apply move policy to steers
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts,apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tssteerTurnenables command moves except for server-created agent messages. Tests verify that user steers move a running Bash command before offering the steer, while server-originated steers leave it running.Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix · Severity of issue fixed: High
Sequence Diagram(s)#
sequenceDiagram actor User participant steerTurn participant backgroundForegroundWork participant backgroundTasks participant ClaudeCLI User->>steerTurn: Send steer steerTurn->>backgroundForegroundWork: Move eligible foreground work backgroundForegroundWork->>backgroundTasks: Background running command steerTurn->>ClaudeCLI: Offer priority-now steerPossibly related PRs
- pingdotgg/t3code#18641: Uses the same background-tasks mechanism for a running root Bash command when handling a Claude steer.
- pingdotgg/t3code#24653: Extends background-task handling to root-turn Bash calls before sending a steer.
Suggested reviewers:
macroscopeapp,juliusmarminge,maria-rcks
Merge Risk:
Minimal · up toba14c-
Steers sent by a person or agent now move a running foreground command to the background first, so Claude can reply while the command keeps running. Server-written deliveries still wait. No concrete defect was found. The author's live run and the new adapter test support the behavior. One unverified point remains: whether a moved command is always tracked as background work before the turn ends. It is worth a quick manual check but is not a merge blocker.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: a Claude steer no longer waits behind a running foreground command. It matches the summary, which backgrounds foreground commands before a priority "now" steer. The ti… Description check The description follows the template. It has Problem, Fix (Change), Credit (Scope, with a link to the replaced PR and the fixed issue #15720), and Verification sections. The Verification section gives…Linked Issues check The only directly linked issue, #15720, is closed. The issue is marked as historical context only, so its acceptance criteria are not active requirements for this pull request. No active directly link…Out of Scope Changes check The changes are limited to the Claude V2 adapter steer path and its test. ClaudeAdapterV2.ts replaces backgroundForegroundSubagents with backgroundForegroundWork. This function also moves running fore… Full details: Title check
-
Explanation
The title names the main change: a Claude steer no longer waits behind a running foreground command. It matches the summary, which backgrounds foreground commands before a priority "now" steer. The title uses the fix(server) conventional-commit form that the template asks for.
Full details: Description check
-
Explanation
The description follows the template. It has Problem, Fix (Change), Credit (Scope, with a link to the replaced PR and the fixed issue
#15720), and Verification sections. The Verification section gives a live run with timestamps, names the focused adapter test, and lists what was not checked (macOS, Windows, and the CLAUDE_CODE_DISABLE_BACKGROUND_TASKS case). The Scope section does not state explicitly that the fix is a bug fix, but it links issue#15720and describes the bug. The template's Scope guidance asks to link the issue that shows the bug, and this is met. The PR is largely complete.
Full details: Linked Issues check
-
Explanation
The only directly linked issue,
#15720, is closed. The issue is marked as historical context only, so its acceptance criteria are not active requirements for this pull request. No active directly linked targets remain, and no linked-issue coding requirements apply. For context, the change set in ClaudeAdapterV2.ts backgrounds running foreground commands before a user or agent steer, and adds a test for that behavior. This addresses the reported symptom, but that is not assessed as a requirement.
Full details: Out of Scope Changes check
-
Explanation
The changes are limited to the Claude V2 adapter steer path and its test. ClaudeAdapterV2.ts replaces backgroundForegroundSubagents with backgroundForegroundWork. This function also moves running foreground command executions to the background before a priority "now" steer. steerTurn passes the active turn and disables command moves for server-created agent messages. The new test in ClaudeAdapterV2.test.ts covers user steers, server-written steers, and the ordering of the background move before the steer. All changes connect directly to the steer behavior that the PR description states. The PR description also states the replacement of
#36170and the server-delivery limit. Those items are part of the same steer change. No unrelated change was found in the reviewed summary. The summary was used as evidence; no full diff was read.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: t3/take-over-pr-36170
- File: .coderabbit.config.ts
- Commit: ba14cf2
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
ef15c89d-f55a-46cc-85a7-65307827c65b
Commits-
Reviewing files that changed from the base of the PR and between 02f8a3280b8635d75a64b21587aef678b4391b51 and ba14cf2bccb347c641310c5cb94221bc5a19aae1.
Files selected for processing: 2-
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
Included review availability: This review used your included allowance. 8 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.
-
-
Thanks for the PR, @t3dotgg! We're closing this because the issue it fixes, #15720, was resolved as working as intended. In both Claude Code and Codex, the harness applies a steer after the next tool call, and T3 Code uses that native behaviour. Interrupt-then-send is only used for harnesses that can't steer directly.
shivamhwp(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes