Skip to content

fix(model_metadata): drop stale ≤256K cache entries for Grok-4.3 - #38996

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-4b46dc2a
Jun 4, 2026
Merged

fix(model_metadata): drop stale ≤256K cache entries for Grok-4.3#38996
teknium1 merged 1 commit into
mainfrom
hermes/hermes-4b46dc2a

Conversation

@teknium1

@teknium1 teknium1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Stale ≤256K context-cache entries for grok-4.3 now 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), any grok-4.3 lookup matched the generic grok-4 substring 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() (matches grok-4.3 only — not grok-4.20 / grok-4-fast / grok-4) + an elif 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

Cache entry Before After
grok-4.3 @ 256K (stale) 256K returned forever dropped → 1M
grok-4.3 @ 1M (correct) 1M 1M (preserved)
grok-4 @ 256K (correct) 256K 256K (untouched)

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

grok-4.3-stale-cache-guard

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).
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-4b46dc2a vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9792 on HEAD, 9792 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5085 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1
teknium1 merged commit 9756dff into main Jun 4, 2026
23 checks passed
@teknium1
teknium1 deleted the hermes/hermes-4b46dc2a branch June 4, 2026 12:36
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/xai xAI (Grok) P3 Low — cosmetic, nice to have labels Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have provider/xai xAI (Grok) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants