Skip to content

fix(grok): map Always allow to allow_once when Grok omits allow_always - #228

Open
leoisadev1 wants to merge 3 commits into
leoisadev1/t3-port-grok-cancelfrom
leoisadev1/t3-port-grok-approvals
Open

fix(grok): map Always allow to allow_once when Grok omits allow_always#228
leoisadev1 wants to merge 3 commits into
leoisadev1/t3-port-grok-cancelfrom
leoisadev1/t3-port-grok-approvals

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

Problem

Grok 4.6 often omits ACP allow_always. Choosing Always allow this session then mapped to a missing option and cancelled the turn.

Changes

selectGrokPermissionOptionId falls back to allow_once when allow_always is absent. The command still runs.

Session-scoped auto-approval memory from the same upstream work is not in this change.

Upstream

Adapted from pingdotgg/t3code#8358. Stacked on #224.

Verification

  • Unit test: acceptForSession maps to allow-once when allow_always is omitted.
  • Targeted lint passed.

Leave this PR and its base open.

Made by Grok 4.6 High in Grok Build via Orca.

Grok 4.6 often omits ACP allow_always. Choosing Always allow this session then
mapped to a missing option and cancelled the turn.

Fall back to allow_once so the command still runs. Session-scoped auto-approval
memory from the same upstream work is not in this change.

Adapted from pingdotgg#8358.

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.

1 Skipped Deployment
Project Deployment Actions Updated
akeru-bot-landing Skipped Skipped Sep 10, 2026 6:00pm 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:S labels Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

The Grok terminal-settlement changes can leave a merged turn without its completion event when an older superseded prompt drains last. This must be fixed before merging.

Confidence Score: 4/5

Not safe to merge until the missing terminal-completion event is preserved.

The reproduced terminal-settlement failure can leave consumers waiting after a session becomes ready. The earlier fixture typing thread was resolved by greptile-apps[bot] without explanation and does not remain outstanding.

Files Needing Attention: apps/server/src/provider/Layers/GrokAdapter.ts

T-Rex T-Rex Logs

What T-Rex did

  • Produced a proof for the posted P1 finding and attached three supporting artifacts.
  • Generated a proof for another posted P1 finding.
  • Validated the contract behavior for terminal emission by running a before/after repro and analyzing the emit logic, confirming that stored terminal results are dropped when emitTurnCompletion is false in the final drain path.

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (2)

  1. apps/server/src/provider/Layers/GrokAdapter.ts, line 278 (link)

    P1 Stored completion is discarded

    When the current prompt finishes while an older superseded prompt is still draining, its terminal result is stored. If the older prompt drains last through the no-emission path, this condition suppresses the stored result too. The session becomes ready without publishing turn.completed, so event consumers can wait indefinitely. Emit the stored current-prompt result when the final superseded prompt drains.

    Artifacts

    Evidence from the check

    • Authored TypeScript script directly calls the Grok epoch completion function for the requested current-then-superseded drain sequence, demonstrating the target behavior.

    Command output from the check

    • Captured successful command output shows epoch 2 storing `end_turn` with one prompt remaining and no immediate emission, establishing the pre-drain state.

    Command output from the check

    • Captured successful command output shows epoch 1 draining last with emission disabled, retaining but not emitting the stored `end_turn` result, confirming the defect.

    View artifacts

    T-Rex Ran code and verified through T-Rex

    Fix in Claude Code

  2. General comment

    P1 Final superseded no-emission drain drops stored current terminal

    • Bug
      • After epoch 2 stores { completedStopReason: "end_turn" } with one older prompt still in flight, epoch 1 drains with remainingPrompts: 0 and emitTurnCompletion: false. The function preserves the stored terminal but returns emit: undefined, so no terminal completion is emitted for the merged turn.
    • Cause
      • grokTurnCompletionForPromptEpoch gates the final flush on input.emitTurnCompletion at apps/server/src/provider/Layers/GrokAdapter.ts:278, including when a superseded prompt is merely draining the already-stored current-epoch outcome.
    • Fix
      • Allow the last prompt drain to emit an existing stored current-epoch terminal result even if the draining superseded settlement has emitTurnCompletion: false, while continuing to suppress that superseded prompt's own incoming terminal.

    T-Rex Ran code and verified through T-Rex

Fix all with Greploop Fix All in Claude Code

Reviews (3): Last reviewed commit: "merge leoisadev1/t3-port-grok-cancel int..." | Re-trigger Greptile

Comment thread apps/server/src/provider/Layers/GrokAdapter.test.ts
CI typecheck inferred permission option kinds as string, so the new allow_once
fallback test failed to compile.

Annotate the fixture with satisfies RequestPermissionRequest so the ACP
literal union is preserved.

Made by Grok 4.6 High in Grok Build via Orca.
Keep the Grok permission fallback stacked on the steered-turn epoch settlement fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 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