Skip to content

fix(grok): surface per-model reasoning effort in the composer - #5403

Closed
ahmed-besic wants to merge 3 commits into
pingdotgg:mainfrom
ahmed-besic:fix/grok-reasoning-effort
Closed

fix(grok): surface per-model reasoning effort in the composer#5403
ahmed-besic wants to merge 3 commits into
pingdotgg:mainfrom
ahmed-besic:fix/grok-reasoning-effort

Conversation

@ahmed-besic

@ahmed-besic ahmed-besic commented Aug 5, 2026

Copy link
Copy Markdown

What Changed

Grok already advertises per-model reasoning effort menus over ACP (models.availableModels[]._meta.reasoningEfforts), but T3 published every Grok model with empty capabilities and never applied a selected effort. The composer therefore had no Reasoning control for Grok, unlike Claude/Codex.

This maps each model's advertised menu into optionDescriptors (reasoningEffort), passes _meta.reasoningEffort through session/set_model on session start and each turn (including mid-thread effort-only changes), and wires the same selection into Grok text generation.

Why

Grok Build supports Low/Medium/High (and other per-model menus for custom models). Without reading _meta and applying effort on session/set_model, T3 always ran at the CLI default and users could not change it from the UI.

Related open work: #5160 takes a spawn-flag approach and blocks mid-thread changes. This PR is narrower: discovery + apply via the existing ACP session/set_model _meta path, which Grok applies in place without restarting the process.

UI Changes

Uses the existing Traits picker — no new UI components. Once Grok ACP discovery succeeds, models with reasoningEfforts show a Reasoning select; models with different menus keep their own options.

  • Before: Grok models have no Reasoning control in the composer traits menu.
  • After: Grok models that advertise effort menus show Reasoning, and the selected value is applied on the next send (same thread is fine for effort-only changes).

Live-verified against grok agent stdio and the T3 web UI over Tailscale.

Validation

  • vp test run src/provider/acp/GrokAcpSupport.test.ts src/provider/Layers/GrokProvider.test.ts — 17 passed
  • Live ACP probe: session/set_model with _meta.reasoningEffort applies the override
  • Manual web UI check: Reasoning control appears for discovered Grok models and updates per model

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (happy to add if needed — behavior uses the existing traits control)
  • A video is not applicable (no animation/timing change)

Made by Grok Build via the Grok Build harness while working on T3 Code.


Note

Medium Risk
Touches Grok ACP model selection and session/set_model payloads, so a bad _meta or skip-on-steer bug could send the wrong effort or extra set_model calls. Scope is Grok-only and covered by unit/adapter tests.

Overview
Grok models that advertise reasoningEfforts in ACP _meta now get a Reasoning select in the composer, and the chosen value is applied in-session instead of always using the CLI default.

Discovery maps each model's _meta.reasoningEfforts into optionDescriptors. applyGrokAcpModelSelection now sends _meta.reasoningEffort on session/set_model when effort is selected (including effort-only changes), and ACP setSessionModel forwards that _meta. Session start, turns, and text generation all pass modelSelection.options. Steering an in-flight prompt skips effort updates because Grok cannot apply them while a prompt is active.

Reviewed by Cursor Bugbot for commit 1754184. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add per-model reasoning effort support to Grok adapter and ACP session model

  • Surfaces reasoningEffort as a per-model Reasoning select descriptor built from session model state _meta.reasoningEfforts, replacing the previous EMPTY_CAPABILITIES for discovered Grok models
  • Extends applyGrokAcpModelSelection and AcpSessionRuntime.setSessionModel to forward options with _meta.reasoningEffort in session/set_model requests, issuing the request even when only the effort changes (model id unchanged)
  • Skips re-applying option selections during steering turns (when steeringTurnId is set) to avoid redundant session/set_model calls while a prompt is active
  • Text generation flow now passes modelSelection.options through to applyGrokAcpModelSelection so reasoning effort is applied before prompting
  • Behavioral Change: session/set_model is now invoked when a reasoningEffort selection is present even if the model id is unchanged; existing callers without options are unaffected

Macroscope summarized 1754184.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

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: bff6643f-00ef-4470-9f35-a1aefbdb071d

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 5, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Skipped

Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically.

Grok models already advertise reasoning effort menus in ACP model
_meta, but T3 always published empty capabilities and never applied a
selected effort. Map each model's reasoningEfforts into option
descriptors, pass _meta.reasoningEffort through session/set_model on
start and send, and cover discovery/apply with focused tests.
@ahmed-besic
ahmed-besic force-pushed the fix/grok-reasoning-effort branch from 9e2fb80 to c8d471b Compare August 12, 2026 09:03
@ahmed-besic

Copy link
Copy Markdown
Author

Additional fixes at #5405, #5409, #5412

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7d734a9. Configure here.

Comment thread apps/server/src/provider/acp/GrokAcpSupport.ts
@ahmed-besic

Copy link
Copy Markdown
Author

Fixed the small steering issue and added a regression test. Typecheck and focused Grok tests are passing.

@t3dotgg

t3dotgg commented Aug 23, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-5.6 Sol responding on behalf of Theo

Closing this PR after an automated pass over open pull requests. Duplicates trusted Grok reasoning controls in #6386.

@t3dotgg t3dotgg closed this Aug 23, 2026
netpro2k added a commit to netpro2k/t3code that referenced this pull request Aug 24, 2026
Intent:
Keep Grok 4.6 usable from T3: plan-mode turns must stay reviewable over ACP,
advertised reasoning levels and user-invocable skills must show in the
composer, and the T3 runtime-mode control must actually drive Grok instead of
~/.grok/config.toml.

Behavior:
- Handle both x.ai/exit_plan_mode and _x.ai/exit_plan_mode, including wrapped
  payloads and null planContent.
- Emit the existing proposed-plan card from planContent, or fall back to the
  last session plan.md body when Grok races the plan-file write.
- Reply abandoned with a capture message so Grok unblocks without implementing
  in the same turn.
- Detect enter_plan_mode and promote writes to ~/.grok/sessions/.../plan.md
  onto the same card. Ignore workspace plan.md files, dedupe identical
  markdown per turn, and clear fallback state on settle or a new non-steer
  turn.
- Leave implement and request-changes to the existing proposed-plan follow-up;
  do not auto-approve plans even in full-access mode.
- Map each Grok model's ACP _meta.reasoningEfforts into the existing Reasoning
  select, preserving labels and descriptions and exposing the applied effort
  as currentValue. Keep one default badge and do not invent a menu when
  metadata is absent.
- Apply reasoning effort through session/set_model _meta.reasoningEffort,
  including effort-only changes. Do not carry an effort across model switches
  unless explicitly selected, skip set_model when nothing changes, and defer
  turn-time mutation until sendTurn validation succeeds.
- Honor the selected effort in Grok-backed title, commit, PR, and branch-name
  generation.
- Read user-invocable skills from grok inspect --json into the provider
  snapshot; use those names for both $ and /, skip bundled helpers, and leave
  both catalogs empty on inspect failure without failing provider discovery.
- Supervised spawns `--permission-mode default` so the thread asks even if the
  Grok CLI config is always-approve or auto.
- Auto-accept edits spawns `--permission-mode acceptEdits`.
- Auto spawns `--permission-mode auto` and sends session/new (and session/load)
  `_meta.autoMode: true`.
- Full access spawns `grok agent --always-approve stdio` and sends
  `_meta.yoloMode: true`.
- Probe and text-generation ACP processes omit a T3 mode and keep `grok agent
  stdio`.
- Always allow this session falls back to allow_once when Grok omits
  allow_always, then auto-approves later prompts in that session.
- Auto still escalates risky calls to T3; it is not always-approve.

Design constraints:
- Keep Grok-specific ACP, inspect, and permission dialects at the
  adapter/provider boundary. Do not change contracts or other providers.
- Reuse turn.proposed.completed, the existing plan card, and generic composer
  optionDescriptors / skills / slashCommands. Add no Grok-only approval
  prompt or new composer UI.
- Do not spawn-bind --reasoning-effort or require a new thread to change
  effort; Grok applies _meta in place.
- Do not map T3 Auto to yolo / bypassPermissions. That is Full access.
- Do not restart mid-thread on a runtime-mode change (separate hang: upstream
  pingdotgg#6517).

Integration:
- Grok adapter, xAI ACP extension helpers, ACP mock, ACP session runtime
  (set_model and session/new|/load _meta), Grok spawn args, Grok
  model/provider snapshot, inspect catalog parser, text generation, focused
  tests, internals provider docs, install.md, and permission-modes.md.
- Web, desktop, and mobile consume existing proposed-plan events, generic
  snapshot fields, and the existing runtime-mode picker with no client
  changes.

Verification:
- vp test run apps/server/src/provider/acp/GrokAcpSupport.test.ts
  apps/server/src/provider/Layers/GrokProvider.test.ts
  apps/server/src/provider/Drivers/GrokSkills.test.ts
  apps/server/src/provider/Layers/GrokAdapter.test.ts
  apps/server/src/provider/acp/XAiAcpExtension.test.ts
- Runtime-mode slice: 57 passed (GrokAcpSupport, GrokAdapter, GrokProvider).
- Earlier combined Grok slice: 64 passed including skills and xAI extension.

Rebase notes:
- Conflict hotspots are GrokAdapter plan handlers, sendTurn settlement,
  handleRequestPermission, buildGrokAcpSpawnInput, XAiAcpExtension.ts,
  GrokProvider discovered-model capabilities, GrokDriver inspect cwd, and
  AcpSessionRuntime setSessionModel plus session/new _meta.
- Upstream pingdotgg#4514 (plan), pingdotgg#5403/pingdotgg#6386/pingdotgg#6887 (reasoning), pingdotgg#4109 (skills),
  pingdotgg#6502/pingdotgg#6626 (Always allow and spawn permission-mode). Drop this patch only
  when main handles both plan-exit spellings with live/fallback plan capture,
  maps ACP reasoningEfforts and effort-only set_model, publishes grok inspect
  skills to $ and /, forwards all four T3 modes onto Grok argv with
  autoMode/yoloMode on session setup, Supervised overrides config.toml, and
  Always allow does not cancel when allow_always is missing.
netpro2k added a commit to netpro2k/t3code that referenced this pull request Aug 25, 2026
Intent:
Keep Grok 4.6 usable from T3: plan-mode turns must stay reviewable over ACP,
advertised reasoning levels and user-invocable skills must show in the
composer, and the T3 runtime-mode control must actually drive Grok instead of
~/.grok/config.toml.

Behavior:
- Handle both x.ai/exit_plan_mode and _x.ai/exit_plan_mode, including wrapped
  payloads and null planContent.
- Emit the existing proposed-plan card from planContent, or fall back to the
  last session plan.md body when Grok races the plan-file write.
- Reply abandoned with a capture message so Grok unblocks without implementing
  in the same turn.
- Detect enter_plan_mode and promote writes to ~/.grok/sessions/.../plan.md
  onto the same card. Ignore workspace plan.md files, dedupe identical
  markdown per turn, and clear fallback state on settle or a new non-steer
  turn.
- Leave implement and request-changes to the existing proposed-plan follow-up;
  do not auto-approve plans even in full-access mode.
- Map each Grok model's ACP _meta.reasoningEfforts into the existing Reasoning
  select, preserving labels and descriptions and exposing the applied effort
  as currentValue. Keep one default badge and do not invent a menu when
  metadata is absent.
- Apply reasoning effort through session/set_model _meta.reasoningEffort,
  including effort-only changes. Do not carry an effort across model switches
  unless explicitly selected, skip set_model when nothing changes, and defer
  turn-time mutation until sendTurn validation succeeds.
- Honor the selected effort in Grok-backed title, commit, PR, and branch-name
  generation.
- Read user-invocable skills from grok inspect --json into the provider
  snapshot; use those names for both $ and /, skip bundled helpers, and leave
  both catalogs empty on inspect failure without failing provider discovery.
- Supervised spawns `--permission-mode default` so the thread asks even if the
  Grok CLI config is always-approve or auto.
- Auto-accept edits spawns `--permission-mode acceptEdits`.
- Auto spawns `--permission-mode auto` and sends session/new (and session/load)
  `_meta.autoMode: true`.
- Full access spawns `grok agent --always-approve stdio` and sends
  `_meta.yoloMode: true`.
- Probe and text-generation ACP processes omit a T3 mode and keep `grok agent
  stdio`.
- Always allow this session falls back to allow_once when Grok omits
  allow_always, then auto-approves later prompts in that session.
- Auto still escalates risky calls to T3; it is not always-approve.

Design constraints:
- Keep Grok-specific ACP, inspect, and permission dialects at the
  adapter/provider boundary. Do not change contracts or other providers.
- Reuse turn.proposed.completed, the existing plan card, and generic composer
  optionDescriptors / skills / slashCommands. Add no Grok-only approval
  prompt or new composer UI.
- Do not spawn-bind --reasoning-effort or require a new thread to change
  effort; Grok applies _meta in place.
- Do not map T3 Auto to yolo / bypassPermissions. That is Full access.
- Do not restart mid-thread on a runtime-mode change (separate hang: upstream
  pingdotgg#6517).

Integration:
- Grok adapter, xAI ACP extension helpers, ACP mock, ACP session runtime
  (set_model and session/new|/load _meta), Grok spawn args, Grok
  model/provider snapshot, inspect catalog parser, text generation, focused
  tests, internals provider docs, install.md, and permission-modes.md.
- Web, desktop, and mobile consume existing proposed-plan events, generic
  snapshot fields, and the existing runtime-mode picker with no client
  changes.

Verification:
- vp test run apps/server/src/provider/acp/GrokAcpSupport.test.ts
  apps/server/src/provider/Layers/GrokProvider.test.ts
  apps/server/src/provider/Drivers/GrokSkills.test.ts
  apps/server/src/provider/Layers/GrokAdapter.test.ts
  apps/server/src/provider/acp/XAiAcpExtension.test.ts
- Runtime-mode slice: 57 passed (GrokAcpSupport, GrokAdapter, GrokProvider).
- Earlier combined Grok slice: 64 passed including skills and xAI extension.

Rebase notes:
- Conflict hotspots are GrokAdapter plan handlers, sendTurn settlement,
  handleRequestPermission, buildGrokAcpSpawnInput, XAiAcpExtension.ts,
  GrokProvider discovered-model capabilities, GrokDriver inspect cwd, and
  AcpSessionRuntime setSessionModel plus session/new _meta.
- Upstream pingdotgg#4514 (plan), pingdotgg#5403/pingdotgg#6386/pingdotgg#6887 (reasoning), pingdotgg#4109 (skills),
  pingdotgg#6502/pingdotgg#6626 (Always allow and spawn permission-mode). Drop this patch only
  when main handles both plan-exit spellings with live/fallback plan capture,
  maps ACP reasoningEfforts and effort-only set_model, publishes grok inspect
  skills to $ and /, forwards all four T3 modes onto Grok argv with
  autoMode/yoloMode on session setup, Supervised overrides config.toml, and
  Always allow does not cancel when allow_always is missing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants