Skip to content

fix(grok): encode session/cancel as a real notification and interrupt steers - #224

Merged
leoisadev1 merged 8 commits into
mainfrom
leoisadev1/t3-port-grok-cancel
Sep 13, 2026
Merged

leoisadev1 merged 8 commits into
mainfrom
leoisadev1/t3-port-grok-cancel

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

Problem

Grok CLI dropped session/cancel because effect-acp encoded notifications as JSON-RPC requests with id: "" and headers. Stop did not stop. The next send queued behind the old prompt.

Mid-turn sends also waited behind the in-flight ACP prompt instead of interrupting like Claude and Codex.

Changes

Outbound ACP notifications now encode as JSON-RPC with no id or headers. RpcClient Interrupt frames are dropped. AcpSessionRuntime.cancel waits for the cancel write. prompt can signal dispatched once the RPC fiber is registered.

Grok mid-turn sends cancel the in-flight prompt, then send the replacement under a prompt epoch and lifecycle semaphore. A failed steer does not discard the live prompt.

Upstream

Adapted from pingdotgg/t3code#9154 session/cancel and steer work. Depends on #214 for grok-build handling and initialize-only runtime.

Shared ACP encoding also applies to Cursor and OpenCode. Cursor adapter tests still pass. No Mastra Codex/Kimi/OpenCode Go change.

Scope

This PR is cancel encoding and Grok steer only.

Assigned Grok ports:

Verification

  • effect-acp protocol tests: 21 passed, including cancel frames without id/headers.
  • GrokAdapter tests: 23 passed, including mid-turn steer cancel and failed-steer keeps original prompt.
  • CursorAdapter tests: 19 passed.
  • XAiAcpExtension tests: 10 passed.
  • Targeted lint and format passed.

Stacked on #214. Leave both open.

Made by Grok 4.6 High in Grok Build via Orca.

…anges

Grok health checks opened a full ACP session, so background probes could hang
on authenticate or boot every configured MCP server. They also never reported
login state, and the snapshot locked model changes to a new thread even though
session/set_model already works.

The check now runs grok --version, grok models, then a single ACP initialize
and reads models from _meta.modelState. Failed initialize degrades to warning.
grok-build is never sent as a model id.

Adapted from pingdotgg#9154 and pingdotgg#8392.

Made by Grok 4.6 High in Grok Build via Orca.
Keep the Grok probe PR current with main.
… steers

Grok CLI dropped session/cancel because effect-acp encoded notifications as
requests with an empty id and headers. Stop then queued the next prompt behind
work that never cancelled.

Notifications now encode as JSON-RPC with no id. Cancel waits for that write.
A mid-turn send cancels the in-flight prompt and continues the same turn.

Adapted from pingdotgg#9154. Shared ACP encoding also applies to Cursor
and OpenCode; their adapters still use start() and are covered by existing tests.

Made by Grok 4.6 High in Grok Build via Orca.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
akeru-bot-landing Building Building Preview Sep 10, 2026 5:55pm UTC

Request Review

@github-actions github-actions Bot added type:provider Agent provider contribution. vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This update corrects Grok mid-turn steering so a superseded prompt can flush the replacement prompt’s stored terminal outcome when it drains last. The accompanying tests now cover both prompt-settlement orders.

Confidence Score: 5/5

Safe to merge.

No outstanding findings remain.

Reviews (3): Last reviewed commit: "merge main into grok cancel stack" | Re-trigger Greptile

A successful replacement could be reported as cancelled when the superseded
prompt finished local draining last. The last in-flight settlement owned the
terminal state.

Store the current epoch's result and emit that when the last prompt drains.
Unit tests cover both settlement orders.

Made by Grok 4.6 High in Grok Build via Orca.
@leoisadev1

Copy link
Copy Markdown
Member Author

This is Leo's agent. Independent review found that #228's terminal-emission finding also applies to this exact head, 11ccb78b76cfa08c2f3f25a5e709e850f6c78c62.

I ran the 109 focused protocol and adapter tests successfully, then reproduced the omitted case against the shipped grokTurnCompletionForPromptEpoch:

  1. Epoch 2 stores { completedStopReason: "end_turn" } while one older prompt remains.
  2. Superseded epoch 1 drains with remainingPrompts: 0 and emitTurnCompletion: false.
  3. The helper returns emit: undefined instead of flushing the stored current-epoch completion.

The helper is identical in #224 and #228. This reproduction exercises the real helper; it does not claim a full provider-process interleaving. The existing adapter tests do not cover this final no-emission drain.

I requested a scoped repair and committed lifecycle regression from the existing Grok worker, with the fix propagated to #228. That worker is currently weekly-quota blocked, so no fix has executed. Both PRs remain on hold pending the repair and fresh verification.

Base automatically changed from leoisadev1/t3-port-grok to main September 13, 2026 21:50
@leoisadev1
leoisadev1 changed the base branch from leoisadev1/t3-port-grok to main September 13, 2026 21:50
@github-actions github-actions Bot added type:plugin Plugin catalog contribution. area:directory Plugin directory and its user interface. size:XXL and removed size:L labels Sep 13, 2026
@github-actions github-actions Bot added size:L and removed type:plugin Plugin catalog contribution. area:directory Plugin directory and its user interface. size:XXL labels Sep 13, 2026
@leoisadev1
leoisadev1 merged commit 4bec11e into main Sep 13, 2026
11 checks passed
@leoisadev1
leoisadev1 deleted the leoisadev1/t3-port-grok-cancel branch September 13, 2026 22:05
This was referenced Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L type:provider Agent provider contribution. vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant