fix(xai): resolve grok-composer-2.5-fast context for OAuth - #40046
Closed
XVVH wants to merge 1 commit into
Closed
Conversation
grok-composer-2.5-fast is absent from GET /v1/models and models.dev; Hermes fell through to the generic grok substring (131072), causing under-reported UI limits and aggressive context compression. Live /v1/responses probing enforces ~262144 tokens total. Add grok-composer: 262144 before the grok catch-all (longest-match). Tests: extend test_grok_substring_matching; add test_grok_composer_context_length_is_262k.
XVVH
marked this pull request as ready for review
June 5, 2026 19:08
Author
|
Standby on merging this in - I've found a bug with tool web_search calling for grok-composer-2.5-fast. I'll submit another PR that supersedes this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
grok-composer-2.5-fast(xAI OAuth / SuperGrok) is missing fromGET /v1/modelsand models.dev. Hermes resolves its context via the genericgrok→ 131072 substring fallback, so the UI shows ~131.1k and the context compressor triggers at half of that (~65k tokens). Live/v1/responsesprobing shows the API enforces ~262144 tokens total (input + output). This PR addsgrok-composer: 262144 before the catch-all, matching the pattern used forgrok-buildin09afafb87.Problem
provider: xai-oauthwithmodel: grok-composer-2.5-fastsee 131072 in status / compressor init.long_context_thresholdon other Grok IDs in/v1/models).Root cause
get_model_context_length()falls through models.dev (no entry) to longest-first substring match onDEFAULT_CONTEXT_LENGTHS. Forgrok-composer-2.5-fast, the only matching key today isgrok(131072). Keys likegrok-build/grok-4do not substring-match this slug._CODEX_OAUTH_CONTEXT_FALLBACKis not used here (openai-codexonly); xAI OAuth usescodex_responsestransport butxai-oauthprovider.Solution
Add to
DEFAULT_CONTEXT_LENGTHS(xAI Grok block):Placed above
"grok": 131072so longest-first matching resolves Composer correctly.Value 262144: from native probe — grow
inputonPOST https://api.x.ai/v1/responsesuntil HTTP 400"The prompt is too long for this model's context window."Largest successful call had input_tokens + output_tokens ≈ 262143. Composer is absent from/v1/models(404 on per-model GET), so metadata cannot be sourced from the catalog endpoint.Tests
tests/agent/test_model_metadata.py::TestDefaultContextLengths::test_grok_substring_matchingwith("grok-composer-2.5-fast", 262144).test_grok_composer_context_length_is_262kintests/run_agent/test_codex_xai_oauth_recovery.py(longest-match key isgrok-composer, notgrok).Checklist
grok-4,grok-build, etc.)_CODEX_OAUTH_CONTEXT_FALLBACKRelated
09afafb87—grok-build→ 256000 for OAuth / models.dev gap#26664/ce0e189d3—grok-4.3→ 1M (substring specificity lesson)User-facing
After merge, new sessions (or agent re-init) pick up 262144; compress-at-50% moves from ~65k → ~131k tokens. Existing compressed sessions are unchanged until
/newor restart.