Skip to content

Add Grok 4.20 reasoning and non-reasoning to xAI model catalog#50772

Merged
huntharo merged 5 commits intoopenclaw:mainfrom
Jaaneek:feat/add-grok-4.20-models
Mar 20, 2026
Merged

Add Grok 4.20 reasoning and non-reasoning to xAI model catalog#50772
huntharo merged 5 commits intoopenclaw:mainfrom
Jaaneek:feat/add-grok-4.20-models

Conversation

@Jaaneek
Copy link
Copy Markdown
Contributor

@Jaaneek Jaaneek commented Mar 20, 2026

Summary

  • Problem: Grok 4.20 is now GA but only the experimental beta entries (grok-4.20-experimental-beta-0304-*) exist in the catalog.
  • Why it matters: Users can't select the GA model IDs from the bundled catalog or model picker.
  • What changed: Added grok-4.20-reasoning and grok-4.20-non-reasoning to the xAI catalog, removed the superseded beta entries, updated docs and tests.
  • What did NOT change: Forward-compatibility resolver, web search defaults, onboarding flow, auth.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Related: xAI Grok 4.20 GA release

User-visible / Behavior Changes

  • xai/grok-4.20-reasoning and xai/grok-4.20-non-reasoning now appear in openclaw models list and can be set as the default model.
  • grok-4.20-experimental-beta-0304-reasoning and grok-4.20-experimental-beta-0304-non-reasoning are removed from the bundled catalog (still forward-resolved by the grok-4.20 prefix matcher).

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: macOS 24.3.0
  • Runtime/container: Node 22.22.0
  • Model/provider: xai

Steps

  1. Start onboarding
  2. Select grok 4.20 reasoning
  3. Send messages to test

Expected

  • Both models visible in models list with yes auth status
  • Model resolves and responds

Actual

  • Both models appear, API confirms grok-4.20-0309-reasoning resolves correctly

Evidence

  • Failing test/log before + passing after
  • pnpm test -- extensions/xai/provider-models.test.ts — 5/5 passed
  • pnpm check — all passed
  • Direct API test: curl https://api.x.ai/v1/chat/completions with grok-4.20-reasoning returns valid response

Human Verification (required)

  • Verified scenarios: models list, direct API call, TUI model picker
  • Edge cases checked: no edge cases afaik
  • What you did not verify: Selecting the model when another model was already selected from previous version, I only tried on brand new openclaw with new onboarding

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert commit
  • Files/config to restore: extensions/xai/model-definitions.ts
  • Known bad symptoms reviewers should watch for: None expected

Risks and Mitigations

None

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XS labels Mar 20, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 20, 2026

Greptile Summary

This PR adds grok-4.20-reasoning and grok-4.20-non-reasoning to the xAI model catalog, each backed by the existing 2M-token XAI_LARGE_CONTEXT_WINDOW constant, along with updated documentation and a new test case that validates both entries. The implementation is clean and follows the established pattern for catalog entries.

  • model-definitions.ts: Two new XaiCatalogEntry objects added; type, flags, and constant usage are all correct.
  • provider-models.test.ts: New test covers both model IDs with the expected reasoning flag and context window.
  • docs/providers/xai.md: Catalog list updated; models are ordered (stable before experimental) consistently with typical convention.
  • Minor ordering inconsistency: The docs list the new stable models before the grok-4.20-experimental-beta-0304-* variants, but the catalog in model-definitions.ts places them after. Aligning the code order to match the docs would improve consistency.

Confidence Score: 5/5

  • This PR is safe to merge; changes are additive, well-tested, and follow the existing catalog pattern exactly.
  • The diff is minimal and low-risk: two new catalog entries, one new test block, and a one-line doc update. No existing behaviour is altered, the new entries use already-validated constants, and the fallback resolution logic in resolveXaiCatalogEntry was already correct for the grok-4.20 prefix. The only note is a cosmetic ordering inconsistency between docs and code.
  • No files require special attention.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/xai/model-definitions.ts
Line: 73-84

Comment:
**Catalog ordering differs from docs**

The new `grok-4.20-reasoning` / `grok-4.20-non-reasoning` entries are placed **after** the `grok-4.20-experimental-beta-0304-*` entries in the catalog, but the docs (`docs/providers/xai.md`) list them **before** the experimental beta variants. Since the stable models are conventionally preferred over the experimental ones, aligning the catalog order with the docs would make both easier to reason about:

```suggestion
  {
    id: "grok-4.20-reasoning",
    name: "Grok 4.20 (Reasoning)",
    reasoning: true,
    contextWindow: XAI_LARGE_CONTEXT_WINDOW,
  },
  {
    id: "grok-4.20-non-reasoning",
    name: "Grok 4.20 (Non-Reasoning)",
    reasoning: false,
    contextWindow: XAI_LARGE_CONTEXT_WINDOW,
  },
  {
    id: "grok-4.20-experimental-beta-0304-reasoning",
    name: "Grok 4.20 Experimental Beta 0304 (Reasoning)",
    reasoning: true,
    contextWindow: XAI_LARGE_CONTEXT_WINDOW,
  },
  {
    id: "grok-4.20-experimental-beta-0304-non-reasoning",
    name: "Grok 4.20 Experimental Beta 0304 (Non-Reasoning)",
    reasoning: false,
    contextWindow: XAI_LARGE_CONTEXT_WINDOW,
  },
```

This is a cosmetic point and has no functional impact, but it keeps the code and docs in sync.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "xai: add grok-4.20-r..."

Comment thread extensions/xai/model-definitions.ts
@Jaaneek Jaaneek force-pushed the feat/add-grok-4.20-models branch from e7535e9 to 7e26c0b Compare March 20, 2026 03:22
@Jaaneek Jaaneek changed the title xai: add grok-4.20-reasoning and grok-4.20-non-reasoning models Add Grok 4.20 reasoning and non-reasoning to xAI model catalog Mar 20, 2026
@huntharo huntharo self-assigned this Mar 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: S and removed size: XS labels Mar 20, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 363edc0cb5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +124 to +125
if (provider === "xai") {
return normalizeXaiModelId(model);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve legacy xAI keys when normalizing model refs

This new normalization rewrites xai/grok-4.20-experimental-beta-0304-* to the GA IDs before selection, but resolveThinkingDefault still reads cfg.agents.defaults.models by the normalized key and does not check the deprecated xAI key form. In an upgraded config that still stores per-model params.thinking under the old key, that override is now silently ignored and the runtime falls back to global/default thinking. Please add a legacy-key fallback (or migrate keys) so backward compatibility also preserves per-model settings.

Useful? React with 👍 / 👎.

@huntharo huntharo force-pushed the feat/add-grok-4.20-models branch from df9b0fc to e2fff01 Compare March 20, 2026 18:43
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2fff01389

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +124 to +125
if (provider === "xai") {
return normalizeXaiModelId(model);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep legacy xAI model keys when reading per-model params

Normalizing deprecated grok-4.20-experimental-beta-0304-* IDs at model-ref parse time changes the selected key to xai/grok-4.20-*, but downstream lookups still read cfg.agents.defaults.models by exact provider/model (for example in resolveExtraParams and resolveFastModeState). In upgraded configs that still store params under the old xAI keys, settings like temperature, maxTokens, and fastMode are silently ignored, so the backward-compat path is incomplete unless we also fall back to the legacy key (or migrate it).

Useful? React with 👍 / 👎.

@huntharo huntharo force-pushed the feat/add-grok-4.20-models branch 3 times, most recently from 00b1b16 to fa3919b Compare March 20, 2026 19:21
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa3919b83f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -121,6 +121,9 @@ function normalizeProviderModelId(provider: string, model: string): string {
if (provider === "google" || provider === "google-vertex") {
return normalizeGoogleModelId(model);
}
if (provider === "xai") {
return normalizeXaiModelId(model);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize legacy xAI IDs before unique-provider inference

parseModelRef now rewrites legacy Grok 4.20 beta IDs to GA IDs, but inferUniqueProviderFromConfiguredModels still compares the caller-supplied model string verbatim against parsed allowlist entries. With a legacy session/runtime model like grok-4.20-experimental-beta-0304-reasoning (no modelProvider) and an allowlist containing that same legacy key, the allowlist side is normalized to grok-4.20-reasoning while the runtime side is not, so provider inference fails and downstream identity/cost paths in resolveSessionModelIdentityRef lose the provider unexpectedly.

Useful? React with 👍 / 👎.

@huntharo huntharo force-pushed the feat/add-grok-4.20-models branch from fa3919b to b322ea1 Compare March 20, 2026 19:27
Jaaneek and others added 5 commits March 20, 2026 15:28
Grok 4.20 is now GA. This adds both variants to the bundled catalog
and removes the superseded experimental beta entries that shipped
during the preview period.

- Add grok-4.20-reasoning (2M context, reasoning enabled)
- Add grok-4.20-non-reasoning (2M context, reasoning disabled)
- Remove grok-4.20-experimental-beta-0304-reasoning
- Remove grok-4.20-experimental-beta-0304-non-reasoning
- Update provider docs and tests
@huntharo huntharo force-pushed the feat/add-grok-4.20-models branch from b322ea1 to 095e645 Compare March 20, 2026 19:28
@huntharo huntharo merged commit 916f496 into openclaw:main Mar 20, 2026
10 checks passed
@huntharo
Copy link
Copy Markdown
Member

Merged via squash.

Thanks @Jaaneek!

frankekn pushed a commit to artwalker/openclaw that referenced this pull request Mar 23, 2026
…law#50772)

Merged via squash.

Prepared head SHA: 095e645
Co-authored-by: Jaaneek <25470423+Jaaneek@users.noreply.github.com>
Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com>
Reviewed-by: @huntharo
furaul pushed a commit to furaul/openclaw that referenced this pull request Mar 24, 2026
…law#50772)

Merged via squash.

Prepared head SHA: 095e645
Co-authored-by: Jaaneek <25470423+Jaaneek@users.noreply.github.com>
Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com>
Reviewed-by: @huntharo
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…law#50772)

Merged via squash.

Prepared head SHA: 095e645
Co-authored-by: Jaaneek <25470423+Jaaneek@users.noreply.github.com>
Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com>
Reviewed-by: @huntharo
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…law#50772)

Merged via squash.

Prepared head SHA: 095e645
Co-authored-by: Jaaneek <25470423+Jaaneek@users.noreply.github.com>
Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com>
Reviewed-by: @huntharo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants