fix(model_metadata): drop stale ≤256K cache entries for Grok-4.3 - #38996
Merged
Conversation
The ``grok-4.3`` (1M context) catalog entry was added on 2026-05-15 (ce0e189). Between 2026-04-10 (when ``grok-4`` at 256,000 was first added by b577697) and 2026-05-15, grok-4.3 slugs resolved via the generic ``grok-4`` substring catch-all and that 256,000 value was persisted to context_length_cache.yaml. Users who first queried grok-4.3 in that 35-day window are stuck at 256K forever — the cache is read at step 1 before the hardcoded defaults in step 8, so the correct 1M entry is never reached. Mirror the existing Kimi/Codex/MiniMax-M3 stale-cache guards: add _model_name_suggests_grok_4_3() and an elif branch that drops any cached value ≤ 256,000 for a grok-4.3 slug so the next lookup falls through to the 1M hardcoded default. Adds 4 regression tests: helper unit test, stale-drop-and-re-resolve, correct-cache-preserved, and no-clobber for plain grok-4 (256K correct).
Contributor
🔎 Lint report:
|
Closed
1 task
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
Stale ≤256K context-cache entries for
grok-4.3now drop and re-resolve to the correct 1M, fixing the lingering "Context: 256K tokens (detected)" report.Root cause: between 2026-04-10 (
grok-4→ 256,000) and 2026-05-15 (grok-4.3→ 1M), anygrok-4.3lookup matched the genericgrok-4substring catch-all and persisted 256,000.get_model_context_length()reads that cache at step 1, before the hardcoded defaults, so stale entries returned 256K indefinitely.Changes
agent/model_metadata.py: add_model_name_suggests_grok_4_3()(matchesgrok-4.3only — notgrok-4.20/grok-4-fast/grok-4) + anelif cached <= 256_000 and _model_name_suggests_grok_4_3(model)guard mirroring the existing Kimi / MiniMax-M3 stale-cache guards.tests/agent/test_model_metadata.py:TestGrok43StaleCacheGuard(4 tests).Validation
grok-4.3@ 256K (stale)grok-4.3@ 1M (correct)grok-4@ 256K (correct)E2E verified with real imports + isolated HERMES_HOME; targeted suite 97/97 passing.
Salvage of #37068 by @AhmetArif0, cherry-picked onto current main with authorship preserved.
Infographic