Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(provider-grok): Grok follow-ups steer into the running turn without cancelling its tool #37345

ClosedMkassabov(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/37345/headopened View on GitHub

Problem

Since #36422, a follow-up sent to a running Grok turn always waits for the turn to end. Send now and Steer can't push it in, so Stop is the only way, and Grok threads lost the only way to pick which queued message goes first. #36422 turned off interrupt-restart steering for Grok because cancelling a Grok prompt kills its foreground tool (#27014), but nothing replaced it.

Closes #37326.

Change

Grok has native mid-turn interjection over ACP: _x.ai/interject { sessionId, text } answers { result: { status: "queued" } }, and Grok reads the message at its next step without cancelling the running tool. Grok now steers through it, the same way Kiro uses _session/steer.

  • provider-grok: Grok reports supportsActiveSteering (tools keep running) and keeps interrupt-restart off. Its steering sends _x.ai/interject.
  • provider-acp steering hook:
    • injectedSteerId is optional. Grok sends no "message read" event, so its acknowledgment counts as delivery.
    • A steer waits until Grok has started the prompt (an update tagged with T3's t3-xai-prompt-* id), for at most 2 s. An interjection sent before that runs as its own turn ahead of the prompt; the first live recording showed this.
    • These steers are declined, so the message runs as the next turn, the same as today: a steer with attachments, a steer after the prompt already ended (the run stays open for background work), and a steer on a Grok without _x.ai/interject (-32601).
  • An interjection that reaches Grok just after its turn ended makes Grok start an interject-fallback-* turn. That turn now goes through the same path as Grok's background-task wake turns.

Scope

A regression from #36422, reported in #37326. Plain Enter still follows the user's Follow-up behavior setting (Queue or Steer).

Verification

  • I probed grok agent stdio (Grok 1.0.77) directly. _x.ai/interject during a sleep 15 foreground command: the command finished with FOREGROUND_DONE, with no cancel, and the reply in the same prompt followed the steer. _x.ai/queue/interject (Grok's own "send now") cancels the turn, so this PR does not use it. A late interjection starts an interject-fallback-* turn.
  • New live-recorded replay fixture grok_message_steering. The steer arrives while sleep 8 && echo FOREGROUND_DONE runs. The transcript shows 1 session/prompt, 1 _x.ai/interject, 0 session/cancel. The command exits 0 with FOREGROUND_DONE, and the reply is steering fixture observed in the same provider turn.
  • GrokAdapterV2.test.ts "Grok native steering" has 3 tests: the hold until Grok starts the prompt, the decline after 2 s with no start, and the declines for images and -32601. All 3 fail with the start gate and the -32601 mapping removed.
  • CommandPolicy.test.ts: Grok follow-ups resolve to steer_active, and execution is active_steering, never interrupt-restart (keeps the #27014 regression).
  • Grok, Kiro and fx replay fixtures, KiroAdapterV2, AcpRegistryAdapterV2, SteeringCompletion, ProviderTurnControlService, and vp run check:changed all pass.
  • I did not run this in the desktop app UI. The change is server-side, and the client already shows Send now / Steer when supportsActiveSteering is true.

Implemented with Claude Opus 5.5 through T3 Code (Grok harness).

    1. tanstack-source added labelsbug

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

    3. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — Grok follow-ups now steer the running turn without cancelling its foreground tool. This also changes automatic delivery from queueing to active steering, requiring confirmation that the new default interaction is intended.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      Grok now supports active steering through _x.ai/interject without interrupting running tools. The ACP adapter waits for configured prompt-start signals and declines steering when delivery conditions are not met. Replay fixtures and tests cover steering outcomes and orchestration policy.

      Changes: Grok native steering

      Layer / File(s)Summary
      ACP steering delivery
      packages/provider-acp/src/server/adapter.ts
      ACP steering can use an optional prompt-start predicate and optional steer ID. When configured, delivery waits for prompt start, with a two-second bound. Attachments, settled prompts, missing ACP methods, and prompt-start timeouts produce declined steering outcomes.
      Grok native interjection
      packages/provider-grok/src/server/xaiAcpExtension.ts, packages/provider-grok/src/server/adapter.ts
      Grok advertises active steering that does not interrupt tools. Its adapter uses _x.ai/interject, recognizes prompt-start and wake notification IDs, and accepts interjection requests only when Grok returns a queued status.
      Orchestration fixtures and validation
      apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts, apps/server/src/orchestration-v2/CommandPolicy.test.ts, apps/server/src/orchestration-v2/testkit/fixtures/grok_message_steering/*, apps/server/src/orchestration-v2/testkit/fixtures/shared.ts, apps/server/src/orchestration-v2/testkit/fixtures/index.ts
      The fixture runner can wait for a specified turn item before steering. Grok replay tests cover prompt-start timing, timeout, attachment and unsupported-method declines, and the resulting interjection transcript. Policy tests assert active steering behavior.

      Estimated code review effort: 3 (Moderate) | ~25 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Sequence Diagram(s)

      sequenceDiagram
        participant Orchestration
        participant GrokAdapter
        participant AcpAdapter
        participant GrokACP
        Orchestration->>GrokAdapter: Request active-run steering
        GrokAdapter->>AcpAdapter: Invoke configured steering handler
        GrokACP-->>AcpAdapter: Send prompt-start notification
        AcpAdapter->>GrokACP: Send _x.ai/interject with session and text
        GrokACP-->>AcpAdapter: Return queued status

      Possibly related PRs

      • pingdotgg/t3code#27025: Addresses steering of queued Grok messages during a running tool, using queueing rather than native interjection.
      • pingdotgg/t3code#37335: Implements overlapping Grok native interjection behavior for the same linked issue.

      Suggested labels: bugfix

      Suggested reviewers: juliusmarminge, t3dotgg

      Merge Risk: Minimal · up to fe064

      Grok follow-ups now steer into the running turn through native interjection without cancelling the foreground tool. Declined cases fall back to the next turn. The supplied evidence shows no concrete merge-blocking defect, and replay tests cover the main flows.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the main change: Grok follow-ups now steer into the running turn without cancelling its foreground tool. This matches the code changes, which add Grok active steering through _x.ai/int…
      Description checkPassedThe description follows the repository template. It has Problem, Change, Scope, and Verification sections, and it includes a conventional-commit-style context and the model and harness line. The Probl…
      Linked Issues checkPassedThe only linked issue, #37326, is closed. Per the assessment rules, it supplies background only. No active directly linked targets remain, so no linked-issue coding requirements apply. The PR still im…
      Out of Scope Changes checkPassedAll changed areas connect to Grok mid-turn steering. provider-grok adapter and xaiAcpExtension changes add the interject steer handler, the wake predicate change (isXAiWakeNotification covers interjec…
      Full details: Title check

      Explanation

      The title names the main change: Grok follow-ups now steer into the running turn without cancelling its foreground tool. This matches the code changes, which add Grok active steering through _x.ai/interject and keep interrupt-restart disabled. The title follows the conventional-commit form that the repository template requests.

      Full details: Description check

      Explanation

      The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and it includes a conventional-commit-style context and the model and harness line. The Problem section states the regression and its cause. The Change section explains the provider-grok and provider-acp edits and the decline cases. The Scope section links the regression from #36422 and the issue #37326. The Verification section lists specific tests, fixtures, and observed results, and it states what was not checked, namely the desktop UI. The description does not explicitly note that the title was checked against the CONTRIBUTING.md requirements, and the template comment asks to read CONTRIBUTING.md, but the template does not require a checkbox for that.

      Full details: Linked Issues check

      Explanation

      The only linked issue, #37326, is closed. Per the assessment rules, it supplies background only. No active directly linked targets remain, so no linked-issue coding requirements apply. The PR still implements the issue's historical goal: Grok steering without cancelling the running tool. Grok now advertises supportsActiveSteering, keeps interrupt-restart off, and sends _x.ai/interject through xAiInterjectSteering (packages/provider-grok). The change set also adds tests for this path (GrokAdapterV2.test.ts, CommandPolicy.test.ts) and a replay fixture (grok_message_steering).

      Full details: Out of Scope Changes check

      Explanation

      All changed areas connect to Grok mid-turn steering. provider-grok adapter and xaiAcpExtension changes add the interject steer handler, the wake predicate change (isXAiWakeNotification covers interject-fallback-* turns), and the prompt-ID prefix. provider-acp steering hook changes add the optional injectedSteerId, the prompt-start gate, the two-second bound, and the -32601 decline. These support the Grok steering behavior. Test and fixture changes (GrokAdapterV2.test.ts, CommandPolicy.test.ts, grok_message_steering fixture files, index.ts, and shared.ts waitForTurnItemType) support verification of that behavior. The assessment used the PR summary and PR description. Source-level review of each hunk was not performed, so this verdict rests on the summary's description of the changes.

      Finishing Touches

      Generate unit tests (beta)

      • 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 b9bc03869e0f5dd84fb25ae1c9aaa67050a5868f and fe064b665e4eb0df73288e8273d3785973c84584.

      Files selected for processing: 10

      • apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts
      • apps/server/src/orchestration-v2/CommandPolicy.test.ts
      • apps/server/src/orchestration-v2/testkit/fixtures/grok_message_steering/grok_transcript.ndjson
      • apps/server/src/orchestration-v2/testkit/fixtures/grok_message_steering/input.ts
      • apps/server/src/orchestration-v2/testkit/fixtures/grok_message_steering/output.ts
      • apps/server/src/orchestration-v2/testkit/fixtures/index.ts
      • apps/server/src/orchestration-v2/testkit/fixtures/shared.ts
      • packages/provider-acp/src/server/adapter.ts
      • packages/provider-grok/src/server/adapter.ts
      • packages/provider-grok/src/server/xaiAcpExtension.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Sign in to join this conversation.