feat(models): support Grok 4.5/4.6 on xAI and OpenRouter - #2871
Conversation
PR Summary by QodoSupport Grok 4.5 and 4.6 across xAI and OpenRouter
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
1. reasoning_effort comment uses narrative phrasing
|
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks, this is carefully done and the tests earn it: 29 of the 35 go red when the source is reverted, and of the six that stay green, four are the litellm registry pins your docstring flags as deliberate.
One suggestion inline on configuration.toml, then this is good to go.
Qodo's line-length finding on changing_a_model.md I would leave alone. The same rule has been raised and let through on #2817 and #2774, and that file already carries lines of 1098 and 785 characters.
08e4918 to
7b3168d
Compare
|
Code review by qodo was updated up to the latest commit 7b3168d |
|
Hey @PeterDaveHello, |
Register published xAI model IDs and aliases, plus their canonical OpenRouter routes, with 500K context windows so token budgeting works without custom limits. Clamp always-on Grok reasoning values to model-specific levels for native xAI and OpenRouter calls. Allow reasoning_effort through pinned LiteLLM for the grok-build-latest alias missing from its registry. PR-Agent sends its configured effort, medium by default, to these models; use high to retain xAI's native default. References: - https://docs.x.ai/developers/models/grok-4.5 - https://docs.x.ai/developers/models/grok-4.6 - https://openrouter.ai/docs/guides/best-practices/reasoning-tokens
7b3168d to
cb8fa07
Compare
|
Thanks Peter! |
…dels Addresses @IsmaelMartinez's review on The-PR-Agent#2530. All three findings verified against the code and reproduced before fixing. 1. OpenRouter double-configuration. He wrote: "grok_model is the basename, so openrouter/x-ai/grok-4 lands here too and gets reasoning_effort from [config] while the OpenRouter block below is already setting extra_body.reasoning from [openrouter]." Reproduced exactly -- with the flag on, openrouter/x-ai/grok-4.5 came out with BOTH top-level reasoning_effort='high' (from [config]) and extra_body.reasoning={'effort':'high'} (from [openrouter]). Adopted his inline `not is_openrouter` suggestion; the OpenRouter block is now the sole owner of that path. 2. allowed_openai_params too broad. He wrote: "grok-2 and grok-3 have reasoning_effort dropped without the allowlist and included with it ... grok-4.5 does not need the allowlist at all; grok-4.20-multi-agent genuinely does." Confirmed against the pinned litellm: get_supported_openai_params reports reasoning_effort for xai/grok-4.5 and xai/grok-4.20-multi-agent but not for xai/grok-3. The allowlist is now added only when litellm does not already report the param, mirroring how main does it for its own Grok path. 3. MAX_TOKENS entries. Added xai/grok-4.20-multi-agent (main's The-PR-Agent#2871, merged today, added the 4.5/4.6 entries but not this one), so the documented xhigh-capable model can actually run without custom_model_max_tokens. Also, and this narrows the PR substantially: main gained native always-on Grok 4.5/4.6 reasoning support in The-PR-Agent#2871 while this sat. The opt-in branch now also skips any model main already covers via GROK_REASONING_EFFORT_LEVELS, so it no longer overrides main's clamping. The residual scope is xAI-direct Grok families main does not cover. Rebased onto main (a64730a); the configuration.toml conflict he flagged is resolved (kept main's add_user_to_requests + "max" effort alongside our flag). Tests: adds the OpenRouter-isolation regression, an allowlist-narrowing test, and a test that natively-supported models are left to main. Adopts the _restore_litellm_globals autouse fixture per his third note. tests/unittest: 2702 passed, 1 pre-existing failure (TestLiteLLMReasoningEffortGrok::...[grok-4.6-xhigh-False]) that reproduces identically on pristine upstream/main and is untouched by this branch. Co-authored-by: IsmaelMartinez <IsmaelMartinez@users.noreply.github.com>
Summary
Behavior changes
Testing
References