Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): a Claude steer no longer waits behind a running foreground command #37756

Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/37756/headopened View on GitHub

Problem

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. tanstack-source added labelsbug

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Approvability

      Verdict: Approved at ba14cf2

      Macroscope'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).
    4. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Other scenarios

      All 64 scenario measurements match main.

      All 64 scenario measurements
      ProviderScenarioMetricMain baselineThis PRImpactPR ceiling
      Codexshort turn resumeWebSocket decoded10.5 KiB10.5 KiB0 B (0.0%)12.7 KiB✅
      Codexshort turn resumeWebSocket messages220 (0.0%)2✅
      Codexlong turn running, cold openHTTP decoded281.7 KiB281.7 KiB0 B (0.0%)302.7 KiB✅
      Codexlong turn running, cold openrows75750 (0.0%)75✅
      Codexlong turn running, history pageHTTP decoded92.4 KiB92.4 KiB0 B (0.0%)107.4 KiB✅
      Codexlong turn running, history pagerows75750 (0.0%)75✅
      Codexlong turn finished, cold openHTTP decoded381.5 KiB381.5 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, socket cold openWebSocket decoded381.6 KiB381.6 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Codexlong turn finished, socket cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, work pageHTTP decoded186.2 KiB186.2 KiB0 B (0.0%)200.2 KiB✅
      Codexlong turn finished, work pagerows1501500 (0.0%)150✅
      Codexidle thread resumeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexidle thread resumeWebSocket messages110 (0.0%)1✅
      Codexfleet shell snapshotHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexfleet shell snapshotrows27270 (0.0%)27✅
      Codexfleet shell subscribeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexfleet shell subscribeWebSocket messages110 (0.0%)1✅
      Codexfleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Codexfleet shell resume checkrows0000✅
      Codexstale shell reloadHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexstale shell reloadrows27270 (0.0%)27✅
      Codexstale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Codexstale shell resumeWebSocket messages220 (0.0%)2✅
      Codexstale todo list cold openHTTP decoded72.4 KiB72.4 KiB0 B (0.0%)83.0 KiB✅
      Codexstale todo list cold openrows75750 (0.0%)75✅
      Codexstale todo list cold opennodes220 (0.0%)4✅
      Codexstale todo list cold opensubagents220 (0.0%)4✅
      Codexstale todo list cold openplans110 (0.0%)2✅
      Codexstale todo list cold openproviderTurns110 (0.0%)2✅
      Codexstale todo list cold opencheckpoints110 (0.0%)2✅
      Claudeshort turn resumeWebSocket decoded10.6 KiB10.6 KiB0 B (0.0%)12.7 KiB✅
      Claudeshort turn resumeWebSocket messages220 (0.0%)2✅
      Claudelong turn running, cold openHTTP decoded283.3 KiB283.3 KiB0 B (0.0%)302.7 KiB✅
      Claudelong turn running, cold openrows75750 (0.0%)75✅
      Claudelong turn running, history pageHTTP decoded93.4 KiB93.4 KiB0 B (0.0%)107.4 KiB✅
      Claudelong turn running, history pagerows75750 (0.0%)75✅
      Claudelong turn finished, cold openHTTP decoded384.2 KiB384.2 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, socket cold openWebSocket decoded384.3 KiB384.3 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Claudelong turn finished, socket cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, work pageHTTP decoded188.1 KiB188.1 KiB0 B (0.0%)200.2 KiB✅
      Claudelong turn finished, work pagerows1501500 (0.0%)150✅
      Claudeidle thread resumeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudeidle thread resumeWebSocket messages110 (0.0%)1✅
      Claudefleet shell snapshotHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudefleet shell snapshotrows27270 (0.0%)27✅
      Claudefleet shell subscribeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudefleet shell subscribeWebSocket messages110 (0.0%)1✅
      Claudefleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Claudefleet shell resume checkrows0000✅
      Claudestale shell reloadHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudestale shell reloadrows27270 (0.0%)27✅
      Claudestale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Claudestale shell resumeWebSocket messages220 (0.0%)2✅
      Claudestale todo list cold openHTTP decoded73.4 KiB73.4 KiB0 B (0.0%)83.0 KiB✅
      Claudestale todo list cold openrows75750 (0.0%)75✅
      Claudestale todo list cold opennodes220 (0.0%)4✅
      Claudestale todo list cold opensubagents220 (0.0%)4✅
      Claudestale todo list cold openplans110 (0.0%)2✅
      Claudestale todo list cold openproviderTurns110 (0.0%)2✅
      Claudestale todo list cold opencheckpoints110 (0.0%)2✅

      Baseline: 02f8a32 · PR result: ba14cf2 · Source CI: success

      Scenario 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.

    5. Explain Change →

      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.ts
      The 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.ts
      steerTurn enables 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 steer

      Possibly 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 to ba14c

      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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe 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 checkPassedThe 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 checkPassedThe 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 #15720 and 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 #36170 and 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

      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.ts
      • apps/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.

    6. 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.

Sign in to join this conversation.