fix(server): Claude steer interrupts a running command instead of waiting for it #15868
main fromrefs/pull/15868/head·opened View on GitHubA user steer sent while Claude runs a foreground command waits for that command to return. A now-priority prompt alone does not interrupt native tool execution.
Interrupt the native turn before offering a user's non-scheduled steer, while keeping the query and provider turn open. Agent and scheduled deliveries retain their existing behavior. An interrupt failure still permits delivery when the adapter owns the target; a second ownership check rejects late offers after completion, Stop or query replacement. Declare the SDK's per-task stop capability so a steer preserves background subagents. Main's existing foreground-subagent backgrounding still happens before the interrupt. Approval-card Cancel also uses Claude's interrupt semantics: background subagents can continue and later wake the thread. Stop still closes the query process.
Based on @nekohasekai's implementation and native-protocol findings in #15868. Their commits are preserved and current main is merged. The takeover replaces call-count-only coverage with delivery/lifecycle checks, adds ownership validation across the new async boundary, and updates the guidance to describe current foreground-subagent behavior.
Verification on a1fde99450, headless Linux:
Four PR-added adapter cases before → four afterward, in the existing adapter file. Existing automatic-delivery and foreground-subagent cases now prove ordering, same-turn completion, automatic-sender behavior, pending approval handling and preserved child output. No new test files or case-count growth.
Without the production change, three focused cases fail (user steering, promoted queued user steering and interrupt-error recovery). The final implementation passes 294 tests: 290 adapter and four automatic-delivery integration cases.
Three relevant deterministic Claude replays pass: message steering, background-subagent lifecycle and background-task interruption. A first concurrent run hit existing test deadlines under machine contention; the same cases passed on one isolated retry without changes.
The ownership regression fails without the new post-interrupt guard and passes with it, using a controlled interrupt and completed root turn.
Server typecheck, targeted lint, formatting and
git diff --checkpass. Existing unused-layer warnings remain.Native Claude Code 2.1.303, Sonnet 5.5, through the production query runner and query options, against isolated temporary configuration and a held local HTTP endpoint: interrupt then now-offer produced the steer response in 1.616 seconds, while the endpoint was still unreleased. The intermediate
aborted_toolsresult was followed by successful steer completion. Closing the runner cleaned the command connection.With a native approval callback pending for the foreground command, the interrupt cancelled the permission request and the steer completed in 815 ms.
With a native background agent blocked on its own held endpoint, a root-command steer completed in 2.027 seconds; the child remained running and reported successful completion after explicit release. Runner close also cleaned the held root-command connection.
A native Bash command launched with
run_in_background: truelikewise survived a root-command steer (1.009 seconds) and completed only after its held endpoint was released.
Two independent adversarial review rounds found no code blockers. Their publication findings are addressed here: current foreground-subagent behavior, current evidence, approval-Cancel disclosure and the verified background-Bash claim.
- In a separate native run, Stop's interrupt-then-close sequence closed both the held root-command and still-running background-agent connections. The first attempt rejected an unrelated stopped-task notification; the corrected probe checks the held child connection directly.
Native proof exercised the production runner/options and CLI with controlled prompts. It did not drive the complete adapter/orchestrator/client flow through a browser. No current-head iOS video is claimed. macOS, Windows, Electron desktop, iOS and Android were not exercised.
Model and harness: implementation with Codex gpt-6.1-sol; separate tests with Codex gpt-6-astra; independent reviews with Claude claude-opus-5-5 and Codex gpt-6-sol, through T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d294d1c1-f343-4e12-b0e4-47146d4852ea
📥 Commits
-
Reviewing files that changed from the base of the PR and between 1e2ecbd9758830669684b494d4398f626b0576e0 and aa3d6985e3f338a12ee5c0b3503ba7214277204d.
📒 Files selected for processing (5)
-
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.testkit.tsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsapps/server/src/orchestration-v2/testkit/fixtures/message_steering/claude_transcript.ndjsondocs/user/providers-claude.md
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
ClaudeAdapterV2 now interrupts the active query before offering user-created steers without a scheduled task ID. Agent-created and scheduled-task steers skip the interrupt. If an interrupt fails, the steer is still offered. Tests, a transcript fixture, and provider documentation reflect the behavior.
Changes: Claude turn steering
Layer / File(s) Summary Interrupt active turns for user steers
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsClaude query options enable the per-task stop affordance. User-created steers without a scheduled task ID interrupt the live query before the message is offered. Interrupt failures are logged and do not prevent the offer. Validate and document steering behavior
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.testkit.ts,apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts,apps/server/src/orchestration-v2/testkit/fixtures/message_steering/claude_transcript.ndjson,docs/user/providers-claude.mdThe test harness records and awaits interrupts before offering steering prompts. Tests cover user, agent, and scheduled-task steers, plus failed interrupts. The fixture records the interrupt and updated transcript. The guide describes interrupting active commands and tools, and the option to queue a message. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
sequenceDiagram participant ClaudeAdapterV2 participant queryRuntime participant ClaudeQuery ClaudeAdapterV2->>queryRuntime: interrupt active query queryRuntime->>ClaudeQuery: query.interrupt() ClaudeAdapterV2->>queryRuntime: offer steer with priority nowSuggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
aa3d6-
The changed steering behavior is ready to merge after normal checks; no actionable issue remains identified.
Security Architecture Review
-
Security architecture risk: 🔵 Low · up to
aa3d6Steering now interrupts foreground work while preserving background work. Stop remains the intended way to end all work. No new permission bypass was established, but overlapping requests and failure recovery are not fully verified.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- inferred — The demonstrated control-flow change affects the active query and its existing background work. The inspected change does not establish new tenant, service, credential, or data-store authority. Actual execution exposure remains bounded by the existing query's permissions and environment, which were not comprehensively audited here.
Trust Boundaries and Controls
- observed — The provider control service forwards creator and scheduled-task metadata from the persisted message. The adapter uses those fields, rather than message text, to select interruption. Its active-turn identity check remains enforced before interruption and delivery.
Resilience and Maintainability Implications
- inferred — The new asynchronous interruption creates an additional transition before delivery. Adapter-level inspection alone cannot establish ordering across overlapping steers, atomicity with persisted steering effects, or recovery if interruption succeeds but delivery does not. Orchestration records steering as a pending effect; its worker serialization and recovery behavior remain unverified, so no reachable race or orphaned-work finding is asserted.
-
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold. Passed checks: 4 passed-
Check name Status Explanation Linked Issues check #15720requires Claude user Steer to interrupt a running command, deliver the steer promptly, and keep the query open.ClaudeAdapterV2.steerTurninterrupts user-authored, non-scheduled steers before…Out of Scope Changes check The perTaskStopAffordanceoption supports the interrupt behavior by preventing interrupts from stopping background subagents. The adapter tests, replay recorder and fixture, and Claude provider docu…Title check The title is concise, specific, and accurately describes the main change: Claude Steer interrupts a running command instead of waiting. Description check The description provides a clear problem statement, implementation details, scope context, extensive verification results, limitations, and model and harness information. It does not use the template … Full details: Linked Issues check
-
Explanation
#15720requires Claude user Steer to interrupt a running command, deliver the steer promptly, and keep the query open.ClaudeAdapterV2.steerTurninterrupts user-authored, non-scheduled steers before offering them. It logs interrupt failures and still offers the message. Existing handling keeps the query open after the aborted result. Tests cover sender selection, ordering, and the failed-interrupt path.
Full details: Out of Scope Changes check
-
Explanation
The
perTaskStopAffordanceoption supports the interrupt behavior by preventing interrupts from stopping background subagents. The adapter tests, replay recorder and fixture, and Claude provider documentation all cover or explain the same Steer behavior. The reviewed changes show no unrelated work.
Full details: Description check
-
Explanation
The description provides a clear problem statement, implementation details, scope context, extensive verification results, limitations, and model and harness information. It does not use the template headings, and approval evidence is indirect, but the required information is substantially present.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
- Fix all pre-merge checks with AI
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge added labelsmacroscope-review
Rebased onto
80664d5266and re-ran the scenario with Claude Code 2.1.296: on main the steer was answered 46.7 s after it reached the CLI, once the held command returned; with this PR, 0.8 s after.#18641 fixes the same issue by moving the running command to the background instead of stopping it. I added a short comparison to the description. One difference from what #18641 says about #15799: this PR declares
perTaskStopAffordance, so a steer here does not stop background subagents. Only one of the two should land.juliusmarminge assignedjuliusmarminge
Taking over this one as maintainer for batch claude-06. I will preserve the user-versus-agent steering distinction, reconcile the interrupt order with current background-task handling, and verify approvals and surviving background work before pushing here.
Thanks @nekohasekai for the earlier investigation and implementation. This PR is stale: its head predates subsequent changes to the Claude adapter on main. Closing it as a duplicate of #18641, where @shivamhwp addresses the same foreground-command steering problem with regression coverage and a real Claude web-flow demonstration. That approach backgrounds the command rather than interrupting it, so the behavior differs; the remaining direction can be decided there.
juliusmarminge closed this
Sign in to join this conversation.
Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — The production adapter changes how active Claude commands and subagents are interrupted, and it introduces a new default SDK query option for every Claude session. These lifecycle and default-behavior changes warrant human review despite the added focused test coverage.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).