feat(xai): wire reasoning effort through the Grok adapter - #6627
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryLow Risk Overview Catalog updates cover 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 SummaryThe PR enables model-specific reasoning-effort controls for supported Grok models and forwards the selected effort through xAI request variants.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| 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
|
@cursor review |
There was a problem hiding this comment.
✅ 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.
Summary
capabilities.reasoningEfforton the four Grok models that actually accept it, with per-model valuesreasoning_effortfromproviders/xai/index.ts, so the flag stops being dead for xAIgrok-4.5's missingcachedInput($0.30/M) and add a provider TSDoc headerBefore this, xAI declared no
reasoningEffortcapability and the adapter only ever senttemperatureandmax_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/completionswith the staging hosted key. xAI's docs are wrong in three places:grok-4.6grok-4.5xhighgrok-4.3nonegrok-4.20-multi-agent-0309nonegrok-4.20-0309-reasoningdoes not support parameter reasoningEffortgrok-4.20-0309-non-reasoninggrok-build-0.1noneis 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.autois rejected by every model (Invalid reasoning effort), which is why Sim'sautosentinel must never be forwarded.Also confirmed live that
reasoning_effortco-exists with everything the adapter sends:tools+tool_choiceauto/forced/none,response_format: json_schema,temperature, and streaming. And that xAI streams rawreasoning_contentdeltas, which is what the generated docs table now claims.Placement
The guard sets
reasoning_effortonbasePayload, 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
sanitizeRequestdropsreasoningEffortwhen a catalogued model lacks the capability, but does not check the value against that model'svalueslist. That is a deliberate, documented policy, not a gap —providers/index.test.tspins it:This PR is itself evidence for that policy: xAI's docs omit
xhighforgrok-4.5and don't listgrok-4.3as 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 takesnone) togrok-4.6(which rejects it) leaves the storednonein place —dependsOnrefetches 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
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, andagent-stream-docs:check.Checklist