Repository navigation
feat(grok): steer by interjection and report Grok's own turns - #716
Conversation
|
Review of 83612d6: changes requested for four reproducible cases.
The no- Validation on Linux x64: the 38 existing targeted tests pass; both real Grok 1.0.77 interjection vendor tests pass against a local scripted provider; all four added adversarial checks fail on this exact head. These findings use deterministic fixtures/process mocks, not a claim that the live late-drain race was reproduced. Reproduction patch and logs are supplied in the Raft review thread. No approval yet.
|
Grok's steer was `session/prompt` with `_meta.sendNow`, which cancels the running turn and restarts it. It is now `_x.ai/interject`: Grok answers `queued`, echoes `_x.ai/session/interjection`, and takes the input into the running turn at its next safe point without cancelling it. Live on 1.0.77, a steer sent while a command ran reached the next provider request and the prompt answered once with end_turn. An interjection that misses the turn's last safe point runs as Grok's own `interject-fallback-*` turn, so steering requires OAR to see turns it did not prompt. OAR now names every prompt (`_meta.promptId`, used verbatim by Grok) and treats any other root prompt id as Grok's own turn: `turn_active` from `_x.ai/queue/changed` `runningPromptId`, `turn_ended` from its `turn_completed`, with its ledger billed once. A host folding the stream returns to idle after a sub-agent wake instead of staying busy. OAR prompts listed as held report `input_queued`/`turn_active` with their input id. While Grok's own turn runs, prompt() is busy, held input waits and steer() interjects into it. A Grok turn overlapping a still-open OAR prompt turn is kept inside that turn, so a waiting host gets the prompt's end. An abort clears Grok's buffered interjections; Grok reports neither taking nor clearing one, so no input_dropped is claimed. Shared ACP: `steerRequest` (a steer that is its own RPC) and `nativeTurns` profile hooks; session state moves to session-state.ts. Evidence: experiments/grok-interject (raw probe, 1.0.77, local provider), sea-trial/vendor/grok-interject.vendor.test.ts (live through OAR), the 17 applicable behavior cases and the Grok vendor suite on 1.0.77. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of #716 (Otter) found four cases; each is now a regression test. - Grok's own turn could not be stopped: abort() only saw OAR's prompted turn. The turn driver now adopts Grok's turn as the active turn, so abort() sends session/cancel with the usual fallback, prompt() is busy, held input waits and steer() reaches it, without a separate busy flag. - A Grok turn that started before OAR recorded the previous prompt's answer and outlived it was left idle. Its start is now held until that prompt's turn closes and reported on the closing frame after the prompt's turn_ended; a run that also ends before then stays inside it. - A second wake of the same child reuses its prompt id and was dropped as a duplicate. End reports are now deduplicated by their native event id. - The interjection could go out after the transport's second spawn wait even if its turn had ended. The target turn is rechecked inside the send callback; a vanished or replaced turn gets no_active_turn and no native request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
83612d6 to
8a62825
Compare
|
The four earlier findings are fixed on
A subprocess fixture reproduces the public mismatch: configureSession issues Moving
|
A Grok turn that starts after the open answer but before OAR finishes configuring the session was projected from the recorder's queue before the native-turn tracker knew the turn driver, so it showed running without being the active turn and abort() was refused (Otter, #716 review). The recorder now flushes its queue only once the driver is bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Re-reviewed All five findings are addressed: the driver owns native turns for abort/busy/held-input/steer, an overlapping native turn survives the earlier prompt's closing frame, repeated child wakes are not deduplicated by prompt id, steer rechecks its target at dispatch, and buffered post-open notifications are flushed only after the native-turn control is bound. The opening regression now checks running, busy, accepted abort and the aborted terminal outcome. Independent validation on Linux x64: 43 targeted ACP/Grok tests and both live Grok 1.0.77 interjection vendor tests passed against a local scripted provider. The no-
|
<!-- stamp:review:v1 --> <sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_63320bc32e280f94a8c9147d127f6446"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup> --- <!-- /stamp:review:v1 --> Minor release: Grok steers without cancelling and reports the turns it runs on its own; Grok and OpenCode failures say more precisely why a turn failed; Codex is found on Windows when it is not on PATH. ## Grok: steer by interjection, and Grok's own turns (#716) - `steer()` on Grok now sends `_x.ai/interject`: the input joins the running turn at its next safe point and the turn is not cancelled. Before, a steer was `session/prompt` with `_meta.sendNow`, which cancelled the running prompt and re-ran its work. - What changes for a host: `steer()` is `accepted` once Grok answers `{status: "queued"}` (15 s deadline) and can now be rejected `runtime_refused` (Grok's error) or `error` (delivery); with no turn running it is rejected `no_active_turn` and nothing is sent. Its record is a frame `_x.ai/interject`, not a second `session/prompt` answer with its own outcome, and the turn ends once, with the prompt's answer. A steer carries no `outputSchema`; the turn keeps its prompt's. - An interjection that misses the turn's last safe point is not lost: Grok runs it after the prompt's `turn_ended` as its own turn (`turn_active` without an `inputId`, so it cannot be tied to the steer). - Turns Grok runs without a prompt from OAR (a finished sub-agent waking its parent, an interjection that missed its turn, and others) are now turns: `turn_active` at their start, `turn_ended` at their end, their usage billed once. A host folding the stream goes back to idle afterwards instead of staying busy. While such a turn runs, `prompt()` is `busy`, held input waits, `steer()` reaches it and `abort()` cancels it. - OAR names each prompt it sends (`_meta.promptId`); Grok's queue reports now give OAR prompts `input_queued` and `turn_active` with their input id. - A Grok turn that starts before OAR has recorded the previous prompt's answer is reported right after that prompt's `turn_ended`, so a host waiting on the prompt gets the prompt's end and the session stays busy until Grok's own end. - An abort clears interjections Grok has not taken yet. Grok reports neither taking nor clearing one, so OAR reports no `input_dropped` for them. - Evidence: Grok 1.0.77 on Linux against a local provider ([probe](https://github.com/botiverse/oar/blob/main/experiments/grok-interject/README.md)). ## Failure classes - **Grok (#717):** every HTTP 429 used to be `rate_limited`. A 429 whose provider error type names a quota (`insufficient_quota`) or Grok's own free-allowance code is now `quota` (`credit_balance_exhausted` is `billing`); others stay `rate_limited`, with `status` 429. For other API errors Grok keeps the provider status in `data.http_status`, and it now decides when Grok's own retry type is the generic `api`: 402 `billing`, 400 `invalid_request`, 401 `auth`, 404 `model_unavailable`, 503/529 `overloaded` (all were `provider`), with that `status` on the outcome; Grok's specific retry types (`auth`, `context_length`) still decide. Failures of Grok's own turns carry no status. - **OpenCode (#711, from Ancienttwo's #710):** a prompt error with one of OpenCode's known `data.errorName` values (`provider.rate-limit`, `provider.free-limit`, `provider.quota` and other budget limits) uses that class before the message text; unknown names keep the text rules. ## Codex on Windows (#719) - When Codex is not on PATH, OAR now also looks for npm's global shim (`%APPDATA%\npm\codex.cmd`) and then the Codex Desktop CLI under `%LOCALAPPDATA%`, after `OAR_CODEX_BIN` and PATH. There is no version comparison: the first that passes `codex app-server --help` wins, so a Desktop CLI older than the one on PATH is never chosen over it. No native Windows run in this release; the locations follow Raft's own Codex driver. ## Record retention (#714, fixes #713) - With `retainedBytes`, a rejected control (for example an idle `abort()`) no longer elides the payload of the newest native frame. Retention now protects the newest frame, not the last record, as documented; older frames are still elided once a newer frame arrives. ## Other - Design decision recorded: OAR does not drive Claude Code's interactive `/limit-reset` to offer Claude limit resets (#721; upstream request anthropics/claude-code#108851). - Docs: weekly pass (#706 to #709), including `PromptRun` README examples that now compile and the documented `oar run` exit codes; Qwen 0.27.0 verification (#705). - Test and evidence updates: Pi 1.5.2 clean-install pairing (#715) and RPC version expectations (#718), November 9 native checks (#712), OpenCode error-name evidence (#711). Grok CI still pins 1.0.70, where the #716 vendor jobs passed; the new behavior was also run against 1.0.77 locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Cindy <[email protected]>
Grok's steer now adds the message to the running turn instead of cancelling it, and turns Grok runs on its own (a finished sub-agent waking its parent, a late interjection) are reported as turns, so a host returns to idle afterwards. Requested by Raft for turning Grok on through OAR (
#oar-rafttask 4; tygg: "steer is important").Steer.
steer()wassession/promptwith_meta.sendNow, which Grok answers by cancelling the running prompt and starting over. It is now_x.ai/interject {sessionId, text, interjectionId: inputId}: Grok answers{result: {status: "queued"}}, echoes_x.ai/session/interjection, and takes the input at the running turn's next safe point. Live on Grok 1.0.77, a steer sent while a 4-second command ran reached the next provider request and the prompt answered once withend_turn. With nothing running, OAR rejects the steerno_active_turnand sends nothing.Grok's own turns. An interjection that misses the turn's last safe point runs as Grok's own
interject-fallback-*turn, and sub-agent wakes already did the same (subagent-completed-*); OAR used to leave those without a turn end, so a host folding the stream stayed busy. OAR now names each prompt (_meta.promptId, which Grok uses verbatim) and treats any other root prompt id as Grok's own turn, without trusting prefixes:turn_activefrom_x.ai/queue/changedrunningPromptId,turn_endedfrom itsturn_completed, its ledger billed once, repeated delivery recognised by the native_meta.eventId(a later wake of the same child reuses its prompt id and is a new turn). OAR prompts getinput_queued/turn_activewith their input id. The turn driver adopts Grok's turn as the active turn:prompt()isbusy, held input waits,steer()interjects into it, andabort()cancels it with the usual fallback. Grok can start its next turn before OAR records the previous prompt's answer; such a start is reported on the prompt's closing frame after itsturn_ended, so a waiting host gets the prompt's end and the session stays busy until Grok's own end.Abort. Grok clears buffered interjections on
session/canceland reports neither taking nor clearing one, so OAR claims noinput_dropped.Shared ACP. Two profile hooks,
steerRequest(a steer that is its own RPC) andnativeTurns; only Grok uses them. Session state creation moves tosession-state.ts.Evidence (Linux arm64, local scripted provider, no login):
experiments/grok-interject: mid-command interject, idle interject (own turn), interject then cancel (cleared), client prompt id.sea-trial/vendor/grok-interject.vendor.test.ts(2 cases), the 17 applicable Grok behavior cases and the Grok vendor suite (23 tests), all on 1.0.77.pnpm run check: 3,810 tests and 18 mock behavior cases pass. Review round 1 (Otter) found four cases (stopping Grok's own turn, a Grok turn outliving the prompt answer it overlapped, a repeated wake of the same child, a steer racing the transport's spawn wait); each is a regression test that fails on the first head.The late-interjection own turn is native-verified by the probe and covered through OAR by fixture tests only: OAR never interjects with nothing running, and the late-drain window is not reliably reachable live.
🤖 Generated with Claude Code