Skip to content

feat(xai): wire reasoning effort through the Grok adapter - #6627

Merged
waleedlatif1 merged 3 commits into
stagingfrom
feat/xai-reasoning-effort
Aug 12, 2026
Merged

feat(xai): wire reasoning effort through the Grok adapter#6627
waleedlatif1 merged 3 commits into
stagingfrom
feat/xai-reasoning-effort

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Declare capabilities.reasoningEffort on the four Grok models that actually accept it, with per-model values
  • Forward reasoning_effort from providers/xai/index.ts, so the flag stops being dead for xAI
  • Fix grok-4.5's missing cachedInput ($0.30/M) and add a provider TSDoc header

Before this, xAI declared no reasoningEffort capability and the adapter only ever sent temperature and max_completion_tokens. The Agent block's effort dropdown never appeared for Grok, and any effort value was silently dropped.

Values are live-verified, not doc-derived

I probed every live Grok model × every effort value against POST /v1/chat/completions with the staging hosted key. xAI's docs are wrong in three places:

Model Docs say API actually accepts
grok-4.6 low, medium, high, xhigh ✅ same
grok-4.5 low, medium, high also xhigh
grok-4.3 not listed as supporting it low, medium, high, xhigh, and none
grok-4.20-multi-agent-0309 low, medium, high, xhigh ✅ plus none
grok-4.20-0309-reasoning implied supported rejects it: does not support parameter reasoningEffort
grok-4.20-0309-non-reasoning rejects
grok-build-0.1 rejects

none is a real vendor value on the two models that list it (reasoning_tokens: 0), and is rejected by 4.5/4.6 — hence the per-model lists rather than one shared array. auto is rejected by every model (Invalid reasoning effort), which is why Sim's auto sentinel must never be forwarded.

Also confirmed live that reasoning_effort co-exists with everything the adapter sends: tools + tool_choice auto/forced/none, response_format: json_schema, temperature, and streaming. And that xAI streams raw reasoning_content deltas, which is what the generated docs table now claims.

Placement

The guard sets reasoning_effort on basePayload, which every derived payload spreads — so it survives the tool loop, the response-format pass, and the streaming request. The new test asserts exactly that on all four paths; I verified all four fail when the guard is removed.

Forwarding an undeclared value is intentional

sanitizeRequest drops reasoningEffort when a catalogued model lacks the capability, but does not check the value against that model's values list. That is a deliberate, documented policy, not a gap — providers/index.test.ts pins it:

an unrecognized level is forwarded rather than dropped: the provider answers with an error naming the values it accepts, instead of Sim silently substituting the model default and quietly corrupting a sweep.

This PR is itself evidence for that policy: xAI's docs omit xhigh for grok-4.5 and don't list grok-4.3 as supporting the parameter at all, yet the API accepts both. A stricter sanitizer would have silently discarded working values.

The practical consequence is that switching a block from grok-4.3 (which takes none) to grok-4.6 (which rejects it) leaves the stored none in place — dependsOn refetches the dropdown options but does not clear the value — and xAI answers with a clear 400 naming the accepted values. That is the intended behavior.

Type of Change

  • New feature

Testing

New providers/xai/index.test.ts (5 tests) covering forward-when-set, omit-on-auto, omit-when-unset, and persistence across the tool loop / response-format / streaming payloads. Full provider suite green (1483 tests), plus lint, type-check, and agent-stream-docs:check.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

The catalog never declared reasoningEffort for xAI and the adapter never
sent reasoning_effort, so the flag was dead for every Grok model.

Values are per-model and verified against the live API rather than the
docs, which are wrong in three places: grok-4.5 does accept xhigh, grok-4.3
supports the parameter at all (undocumented) including none, and
grok-4.20-0309-reasoning rejects it outright despite being a reasoning model.

Also corrects grok-4.5's missing cachedInput and drops an inline comment the
new provider TSDoc now covers.
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 12, 2026 6:03pm

Request Review

@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Additive provider behavior behind capability gates and tests; no auth or data-path changes. Residual risk is misconfigured per-model effort lists causing provider 400s when switching models with incompatible stored values (intentional).

Overview
Grok models can now use Reasoning Effort end-to-end — the xAI adapter maps reasoningEffort to reasoning_effort on chat completions (omitting Sim’s auto sentinel, which xAI rejects), and the model catalog declares per-model capabilities.reasoningEffort so the Agent block effort control appears for supported Groks.

Catalog updates cover grok-4.6, grok-4.5, grok-4.3, and grok-4.20-multi-agent-0309 with API-verified value lists (including xhigh and, where applicable, none); grok-4.5 also gets missing cachedInput pricing. Provider-layer tests assert effort is kept or stripped by capability, and new xAI unit tests cover tool loops, JSON schema follow-ups, and streaming.

Agent docs add xAI to the streamed-thinking table and broaden the FAQ on which providers expose Reasoning Effort.

Reviewed by Cursor Bugbot for commit 0d5dd61. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR enables model-specific reasoning-effort controls for supported Grok models and forwards the selected effort through xAI request variants.

  • Adds per-model reasoning-effort capability metadata and updates Grok pricing metadata.
  • Preserves reasoning effort across ordinary, tool-loop, response-format, and streaming requests.
  • Updates Agent documentation and model-facing descriptions.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/providers/xai/index.ts Forwards non-default reasoning effort through the shared xAI base payload.
apps/sim/providers/models.ts Declares model-specific Grok reasoning-effort values and updates cached-input pricing.
apps/sim/providers/xai/index.test.ts Adds request-path coverage for xAI reasoning-effort forwarding.
apps/sim/providers/index.test.ts Verifies model-level capability sanitization for supported and unsupported Grok models.
apps/sim/blocks/blocks/agent.ts Generalizes the Agent reasoning-effort input description beyond GPT-5 models.
apps/docs/content/docs/en/workflows/blocks/agent.mdx Documents xAI reasoning streaming and broader reasoning-effort provider support.

Reviews (2): Last reviewed commit: "fix(agent): correct reasoning-effort cop..." | Re-trigger Greptile

Comment thread apps/sim/providers/xai/index.test.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0d5dd61. Configure here.

@waleedlatif1
waleedlatif1 merged commit 9dfd9db into staging Aug 12, 2026
30 of 31 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/xai-reasoning-effort branch August 12, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant