Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(orchestrator): Surface Grok reasoning effort options #5160

Closedmwolson(GitHub profile, opens in a new tab)wants to merge 7 commits intot3code/codex-turn-mapping fromrefs/pull/5160/headopened View on GitHub

Summary

  • Add a Reasoning selector for Grok models that advertise effort support, using each model's ACP menu (Grok 4.5: Low / Medium / High; Grok 4.6 also includes Extra High).
  • Require Grok 1.0.0 or newer and apply model and reasoning changes in the active conversation through ACP session/set_model metadata.
  • Keep the active model and reasoning metadata synchronized across new, loaded, resumed, and restarted ACP sessions, including first-party text generation.
  • When a model advertises more than one default, keep a single Default badge and prefer the advertised current effort.

Problem and Fix

Problem and Why it HappenedFix
T3 Code did not surface Grok's advertised reasoning-effort choices, so every turn used the provider default.Map ACP model reasoning metadata into the existing provider-option UI on web and mobile.
Grok 1.0.0 honors reasoning effort in session/set_model metadata, while the generic ACP adapter previously treated model selection as only a model-id change.Compare both the model id and normalized { reasoningEffort } metadata so the next turn can apply either change in the same conversation.
Loading or resuming a provider session can replace the model state discovered when the process initialized.Record the active model and metadata after every session activation, then reapply the requested selection when necessary.
An older Grok binary can accept process launch but ignore the dynamic reasoning metadata.Parse the complete Grok CLI version, including prerelease suffixes, and gate orchestration and first-party text generation on Grok 1.0.0 or newer.
Grok 4.6's catalog marks Extra High and High as default: true, so the picker showed two Default badges.Collapse multiple advertised defaults to one and prefer the advertised current effort.

Defensive Fixes

Problem and Why it HappenedFix
Provider metadata can be absent or malformed, and persisted selections can drift from a model's current advertised menu.Fall back only when the effort menu is absent, reject malformed-present metadata, preserve future valid advertised values, and normalize stale values to the model's advertised default.
Clearing reasoning metadata is also a state change, but a one-sided comparison can miss the transition from a defined effort to no explicit effort.Compare the current and requested metadata symmetrically and cover clearing and reapplying effort on the same model.

UI Changes

After: Grok models with reasoning support expose their advertised choices in the composer. Grok 4.6 shows Extra High when that is the advertised current effort, with a single Default badge in the open menu.

Grok 4.6 Reasoning menu with Extra High Default

Grok 4.6 composer with Extra High menu open

A video is not applicable because this change has no animation or timing behavior.

Validation

  • A live Grok ACP probe changed an active session to Low, completed a real prompt, loaded the same session in a fresh runtime, and read Low back from the advertised model metadata. Grok's durable session history recorded "reasoning_effort":"low" on those assistant messages.
  • A later live Grok 4.6 thread changed mid-conversation from High to Extra High. Subsequent assistant messages recorded "reasoning_effort":"xhigh".
  • After collapsing duplicate advertised defaults, a Nightly AppImage on Grok 4.6 shows Extra High selected and a single Default badge on Extra High.
  • Focused Grok provider tests cover advertised menus, the Grok 4.6 dual-default catalog, and Extra High as the current effort.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included after screenshots for UI changes
  • A video is not applicable because there are no animation or timing changes

Note

Surface Grok reasoning effort as a spawn-bound option in the orchestrator and UI

  • Adds GROK_REASONING_EFFORT_OPTION_ID and supporting utilities in GrokAcpSupport.ts to resolve and pass --reasoning-effort as a CLI flag when spawning the Grok agent process.
  • Extends the ACP adapter in AcpAdapterV2.ts to support spawnOptionIds on flavors, excluding those options from ACP config validation and setConfigOption calls, and logging a warning on mismatch.
  • Updates GrokProvider.ts to parse reasoning effort menus from ACP model _meta and advertise a Reasoning select capability on discovered Grok models, with a fallback for grok-4.5.
  • Blocks option changes mid-thread on both web (ChatComposer.tsx) and mobile (ThreadComposer.tsx) when the active provider requires a new thread for model changes, showing a warning toast and reverting to the committed selection.
  • Behavioral Change: reasoning effort for Grok is now applied at spawn time rather than via session config, so changing it mid-thread is blocked and requires starting a new thread.
📊 Macroscope summarized 64cbc0c. 26 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

>
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 72a67341-bf75-4496-ac58-dd45f02f89ef

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/80e716c5b49642431470e8830172914a09a39584/apps/mobile/src/state/use-thread-outbox-drain.ts#L447

      sendQueuedMessage receives the stale thread snapshot captured before the confirmThreadOutboxMessageQueued await, even though the delivery path already re-reads freshThread after that await. If the thread's committed modelSelection changes during the confirmation window, resolveOutboxModelSelectionForEnvironment pins against the obsolete committed selection, and the settings-sync step can then overwrite the newer selection on the server before sending the turn. The code re-reads freshThread but passes the old thread to sendQueuedMessage, so the freshness check is wasted. Consider passing freshThread into sendQueuedMessage (and re-evaluating the model-selection resolution and settings-sync guards against it) instead of the pre-await snapshot.

      ✅ Resolved in aec2a423755e7b60d5c99f66a7903f5c3f428145

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/6590540463e99e78801758590db3739874202346/apps/mobile/src/state/use-thread-outbox-drain.ts#L409

      deferredConfigMessageIdsRef leaks message IDs when a deferred message is deleted from the outbox before its provider config arrives. The set is only cleared when that exact message reappears in a later drain pass with a non-null model selection — so if the message is removed (rolled back, dropped, or delivered another way) while still deferred, its ID stays in the set forever. Repeated defer-then-delete cycles grow the set for the lifetime of the mounted drain. Consider removing the ID from deferredConfigMessageIdsRef when the message is removed from the outbox, or clearing it on delivery/removal paths.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/mobile/src/state/use-thread-outbox-drain.ts around line 409:
      
      `deferredConfigMessageIdsRef` leaks message IDs when a deferred message is deleted from the outbox before its provider config arrives. The set is only cleared when that exact message reappears in a later drain pass with a non-null model selection — so if the message is removed (rolled back, dropped, or delivered another way) while still deferred, its ID stays in the set forever. Repeated defer-then-delete cycles grow the set for the lifetime of the mounted drain. Consider removing the ID from `deferredConfigMessageIdsRef` when the message is removed from the outbox, or clearing it on delivery/removal paths.
    5. Fixed on the latest head. The drain now prunes deferred-config IDs against the live outbox before dispatch, so a rolled-back or externally removed message cannot remain in the log-dedupe set. The mobile outbox and model-option suites pass (49 tests), along with vp check and full typecheck.

    6. Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    7. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium components/ChatView.tsx:1538

      hasStartedModelSession falls back to threadHasStarted(activeThread), which returns true whenever the thread shell has itemCount > 0 or a latestRun — even if no runtime exists. After a failed first turn, the shell has a run but both the projected and shell runtimes are null, so resolveModelChangeRuntime correctly returns null (intending to keep the thread unlocked), but threadHasStarted immediately overrides that, marking the session as started. This causes getStartedThreadModelChangeBlockReason to permanently block model/instance changes for providers that require a new thread, even though no provider session was ever created. The || fallback defeats the explicit resolveModelChangeRuntime logic intended to keep a failed first turn unlocked. Consider relying solely on modelChangeRuntime !== null to determine whether a model session has started.

        const hasStartedModelSession = modelChangeRuntime !== null;
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/web/src/components/ChatView.tsx around lines 1538-1538306230843084:
      
      `hasStartedModelSession` falls back to `threadHasStarted(activeThread)`, which returns `true` whenever the thread shell has `itemCount > 0` or a `latestRun` — even if no runtime exists. After a failed first turn, the shell has a run but both the projected and shell runtimes are null, so `resolveModelChangeRuntime` correctly returns null (intending to keep the thread unlocked), but `threadHasStarted` immediately overrides that, marking the session as started. This causes `getStartedThreadModelChangeBlockReason` to permanently block model/instance changes for providers that require a new thread, even though no provider session was ever created. The `||` fallback defeats the explicit `resolveModelChangeRuntime` logic intended to keep a failed first turn unlocked. Consider relying solely on `modelChangeRuntime !== null` to determine whether a model session has started.
    8. Fixed in the current head. hasStartedModelSession now relies only on resolveModelChangeRuntime(...) !== null, so a failed first turn without a provider runtime remains unlocked. Focused ChatView coverage, vp check, and the full workspace typecheck pass.

    9. Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    10. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Adapters/AcpAdapterV2.ts:6168

      readThreadSnapshot returns every entry in the session-wide providerTurns map without filtering by snapshotInput.providerThread.id. When the runtime loads a different thread, the snapshot includes provider turns from the previously active thread, so consumers receive turns whose providerThreadId belongs to another thread. The providerTurns map is never cleared on session load, so stale turns accumulate. Consider filtering the returned array by snapshotInput.providerThread.id, or clearing providerTurns when a new session is activated in the activeSessionId mismatch branch above.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts around line 6168:
      
      `readThreadSnapshot` returns every entry in the session-wide `providerTurns` map without filtering by `snapshotInput.providerThread.id`. When the runtime loads a different thread, the snapshot includes provider turns from the previously active thread, so consumers receive turns whose `providerThreadId` belongs to another thread. The `providerTurns` map is never cleared on session load, so stale turns accumulate. Consider filtering the returned array by `snapshotInput.providerThread.id`, or clearing `providerTurns` when a new session is activated in the `activeSessionId` mismatch branch above.
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Adapters/AcpAdapterV2.ts:6225

      forkThread sets activeSessionId to the forked session but does not reset the in-memory snapshot, so a subsequent readThreadSnapshot for the fork sees activeSessionId already matches and skips the loadSession branch — returning the source session's cached messages (including the source app threadId) as the fork's snapshot. Consider clearing snapshot (and activeSelection) in forkThread alongside setting activeSessionId, so readThreadSnapshot re-loads the forked session's messages.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts around line 6225:
      
      `forkThread` sets `activeSessionId` to the forked session but does not reset the in-memory `snapshot`, so a subsequent `readThreadSnapshot` for the fork sees `activeSessionId` already matches and skips the `loadSession` branch — returning the source session's cached messages (including the source app `threadId`) as the fork's snapshot. Consider clearing `snapshot` (and `activeSelection`) in `forkThread` alongside setting `activeSessionId`, so `readThreadSnapshot` re-loads the forked session's messages.
    11. Confirmed as a latent generic ACP snapshot issue, but it predates this change at 5fc2f9b. The adapter snapshot method has no production caller today, and the session-model work here does not change the providerTurns cache. I am keeping this out of the Grok reasoning change so it can be handled with dedicated multi-thread snapshot coverage.

    12. Confirmed as a pre-existing ACP fork snapshot issue. Continuing a forked thread uses the turn path and does not consume this cached snapshot, while a future snapshot consumer could observe source-thread ids. This is separate ACP lifecycle work and is not introduced by the Grok session-model metadata change.

    13. Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    14. Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    15. After: Grok 4.6 reasoning selector

      Composer after the change. Grok 4.6 is selected with Extra High as the current reasoning effort.

      Grok 4.6 composer with Extra High selected

    16. After: Grok 4.6 reasoning menu

      Open Reasoning menu. Extra High is the only Default.

      Grok 4.6 Reasoning menu with Extra High Default

      Composer with Grok 4.6 and the open Extra High menu.

      Grok 4.6 composer with Extra High menu open

    17. Reviewed the web UI changes for the session-bound provider-option lock (ChatView, ChatComposer, TraitsPicker, composerProviderState). Prop forwarding through composerProviderState and the display/dispatch split look consistent with the shared control contracts. Two findings on the new locked-option interaction.

      Posted via Macroscope — UI Consistency
    18. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/64cbc0cb89f63c142b42ab0ea972450eb6aa229b/apps/mobile/src/features/threads/ThreadComposer.tsx#L665

      When optionChangeBlocked changes after settingsRouteSession is memoized, the settings callback keeps the old lock state and can update a spawn-bound option in an active conversation without showing the warning. Add both props.optionChangeBlocked and props.optionChangeBlockedInstanceId to the useMemo dependency list so the session callback is recreated when locking changes.

      ✅ Resolved in 9c587c9175d924411872383a6b328afc5ab5eb98

    19. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      Closing this PR after an automated pass over open pull requests. Large stale reasoning-controls draft duplicates trusted Grok work in #6386.

Sign in to join this conversation.