Skip to content

feat: add Grok 4.5 model support and fix xAI reasoning format#867

Open
navedmerchant wants to merge 1 commit into
mainfrom
feat/grok-4.5-support
Open

feat: add Grok 4.5 model support and fix xAI reasoning format#867
navedmerchant wants to merge 1 commit into
mainfrom
feat/grok-4.5-support

Conversation

@navedmerchant

@navedmerchant navedmerchant commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #866

Description

Grok 4.5 was publicly released on July 9, 2026 as xAI's new flagship model. This PR adds support for it in the xAI provider and fixes a latent reasoning format bug.

Key implementation details:

  1. New model definition (packages/types/src/providers/xai.ts): Added grok-4.5 with 500K context window, $2.00/$6.00 input/output pricing, $0.50 cache pricing, and configurable reasoning effort (["low", "medium", "high"], default "high"). Updated xaiDefaultModelId from grok-4.20 to grok-4.5.

  2. Reasoning format bug fix (src/api/providers/xai.ts): The xAI Responses API expects reasoning: { effort: "high" } format, but the handler was passing reasoning: { reasoning_effort: "high" } (Chat Completions format). This was a latent bug that affected grok-3-mini and would have broken grok-4.5's configurable reasoning. The handler now converts from the OpenAI params shape to the Responses API { effort } format.

  3. Test updates (src/api/providers/__tests__/xai.spec.ts): Fixed the existing grok-3-mini reasoning test to expect the correct { effort } format. Added two new tests for grok-4.5 — one verifying default high reasoning effort, one verifying custom low effort.

  4. E2e test update (apps/vscode-e2e/src/suite/providers/xai.test.ts): Updated the primary model ID from grok-4.20 to grok-4.5.

Test Procedure

Unit tests (all passing):

  • cd src && npx vitest run api/providers/__tests__/xai.spec.ts — 17 tests pass (15 original + 2 new grok-4.5 tests)
  • cd src && npx vitest run api/transform/__tests__/model-params.spec.ts api/transform/__tests__/reasoning.spec.ts shared/__tests__/api.spec.ts — 161 tests pass
  • cd src && npx vitest run api/transform/__tests__/openai-format.spec.ts — 56 tests pass
  • cd src && npx vitest run shared/__tests__/ProfileValidator.spec.ts — 28 tests pass
  • cd packages/types && npx vitest run — 230 tests pass

Lint & type-check (pre-commit/pre-push hooks):

  • ESLint passes with --max-warnings=0 across all packages
  • tsc --noEmit passes for @roo-code/types, @roo-code/vscode-e2e, and zoo-code

Pre-Submission Checklist

  • Issue Linked: This PR is linked to issue Add Grok 4.5 model support to xAI provider #866.
  • Scope: My changes are focused on the linked issue (adding grok-4.5 support + fixing the reasoning format bug it exposed).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates required — model definitions are self-documenting via the description field.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A — no UI changes. The new grok-4.5 model will automatically appear in the xAI provider model dropdown.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The reasoning format bug (reasoning_effort vs effort) was pre-existing and would have silently caused grok-4.5 to ignore the user's reasoning effort setting, always falling back to the model's default. The xAI API likely silently ignores unrecognized fields in the reasoning object, so this wouldn't have caused errors — just incorrect behavior.

Get in Touch

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Updated xAI model support to use the newer grok-4.5 default.
    • Improved how reasoning settings are sent in xAI requests so they follow the expected format.
    • Added coverage for default and custom reasoning-effort behavior with the latest model.

Add grok-4.5 model definition with 500K context window, .00/.00
input/output pricing, /bin/sh.50 cache pricing, and configurable reasoning
(low/medium/high, default high). Update xaiDefaultModelId from
grok-4.20 to grok-4.5 as the new flagship model.

Fix a latent bug in the xAI handler where reasoning effort was sent in
Chat Completions format (reasoning: { reasoning_effort }) instead of
the Responses API format (reasoning: { effort }). This affected
grok-3-mini and would have broken grok-4.5's configurable reasoning.

Update tests to cover the reasoning format fix and add grok-4.5
reasoning support tests. Update e2e test primary model to grok-4.5.

Fixes #866
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 25a8f59e-e3a5-4353-bc48-205a4ec9968a

📥 Commits

Reviewing files that changed from the base of the PR and between edb6564 and eb40ce1.

📒 Files selected for processing (4)
  • apps/vscode-e2e/src/suite/providers/xai.test.ts
  • packages/types/src/providers/xai.ts
  • src/api/providers/__tests__/xai.spec.ts
  • src/api/providers/xai.ts

📝 Walkthrough

Walkthrough

This PR replaces the xAI default model grok-4.20 with grok-4.5, adding its pricing/context/reasoning metadata. It fixes XAIHandler.createMessage to send reasoning.effort instead of raw reasoning_effort, matching the Responses API shape, and updates unit and e2e tests accordingly.

Changes

xAI grok-4.5 model and reasoning fix

Layer / File(s) Summary
Model definition and default id update
packages/types/src/providers/xai.ts
xaiDefaultModelId changed to "grok-4.5"; xaiModels map now starts with a grok-4.5 entry including pricing, context, tool support, and reasoning-effort metadata.
Reasoning payload conversion in createMessage
src/api/providers/xai.ts
createMessage now sets requestBody.reasoning = { effort: model.reasoning.reasoning_effort } instead of forwarding model.reasoning directly, with added comments explaining the Responses API shape.
Unit test updates for reasoning format
src/api/providers/__tests__/xai.spec.ts
Mini-model assertion updated to nested reasoning.effort; new tests verify grok-4.5 default ("high") and custom ("low") reasoning effort.
E2E test model reference update
apps/vscode-e2e/src/suite/providers/xai.test.ts
XAI_MODEL_ID and a fetch-interceptor comment updated from grok-4.20 to grok-4.5.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Suggested labels: awaiting-review

Suggested reviewers: hannesrudolph, JamesRobert20

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: Grok 4.5 support plus the xAI reasoning-format fix.
Description check ✅ Passed The description follows the template and includes the linked issue, implementation details, tests, checklist, and notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/grok-4.5-support

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.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

Add Grok 4.5 model support to xAI provider

1 participant