Skip to content

fix(models): refresh stale xAI catalog + auto-derive from models.dev (#16699)#16925

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-629a7af8
Apr 28, 2026
Merged

fix(models): refresh stale xAI catalog + auto-derive from models.dev (#16699)#16925
teknium1 merged 2 commits into
mainfrom
hermes/hermes-629a7af8

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

The /model picker for xAI-direct now shows every current xAI model ID and self-heals when xAI renames models, instead of drifting until someone opens an issue.

Salvages #16818 (@vominh1919, credit preserved) with three name corrections, then adds the structural piece issue #16699 actually asked for.

Root cause

_PROVIDER_MODELS["xai"] hardcoded two stale names (grok-4.20-reasoning, grok-4-1-fast-reasoning) → HTTP 400 "Unknown Model" on xAI-direct. Same drift pattern that hit openai-codex (#6595, fixed by #7844's _codex_curated_models()).

Commits

1. fix(models): update stale xAI model list (#16699)@vominh1919

Replaces the stale entries with xAI-direct's actual current catalog IDs.

PR #16818 as-submitted had three names that look right but don't exist on xAI-direct (grok-4.20, grok-4.20-multi-agent, grok-4.1-fast — those are OpenRouter/Vercel-gateway normalized aliases). This commit corrects to the IDs xAI-direct actually serves, verified against ~/.hermes/models_dev_cache.json:

grok-4.20-0309-reasoning
grok-4.20-0309-non-reasoning
grok-4.20-multi-agent-0309
grok-4-1-fast
grok-4-1-fast-non-reasoning
grok-4-fast
grok-4-fast-non-reasoning
grok-4
grok-code-fast-1

2. fix(models): auto-derive xAI model list from models.dev cache

Replaces the static list with _xai_curated_models(), mirroring _codex_curated_models() from #7844. Reads $HERMES_HOME/models_dev_cache.json at import time (disk only, no network) and falls back to a small static snapshot when the cache is missing.

Hermes already refreshes this cache during normal operation, so the /model picker self-heals on the next refresh whenever xAI renames a model. Next time: no issue, no PR.

Validation

E2E tested against four scenarios with isolated HERMES_HOME:

Scenario Result
Real populated cache (25 current xAI IDs) ✓ picker shows all 25, including new grok-2/3/4 variants
Fresh install / no cache file ✓ static fallback (9 IDs)
Malformed JSON ✓ static fallback, no crash
xai present but empty models dict ✓ static fallback
Import-time cost 11 ms (disk read only, confirmed no HTTP)

Targeted tests: tests/hermes_cli/test_model_validation.py (76 passed), tests/hermes_cli/ -k models (227 passed).

Fixes #16699
Closes #16818

Credit: @vominh1919 for the initial fix; extended with a models.dev-backed resolver as the issue requested.

vominh1919 and others added 2 commits April 28, 2026 01:44
_PROVIDER_MODELS["xai"] was pointing at model IDs the xAI direct API
no longer accepts:
- grok-4.20-reasoning
- grok-4-1-fast-reasoning

Replaced with the actual current xAI catalog IDs from models.dev
($HERMES_HOME/models_dev_cache.json, mirror of https://models.dev/api.json):
  grok-4.20-0309-reasoning
  grok-4.20-0309-non-reasoning
  grok-4.20-multi-agent-0309
  grok-4-1-fast
  grok-4-1-fast-non-reasoning
  grok-4-fast
  grok-4-fast-non-reasoning
  grok-4
  grok-code-fast-1

The xAI-direct API (https://api.x.ai/v1) serves the dated IDs shown
above; the bare aliases (grok-4.20, grok-4.1-fast, etc.) are
OpenRouter/Vercel-gateway normalizations and are not accepted on
xAI-direct. Those gateways remain unaffected.

Fixes #16699
Follow-up to the static list refresh: replace the hardcoded xAI entries
with _xai_curated_models(), mirroring the _codex_curated_models()
pattern from PR #7844. The helper reads $HERMES_HOME/models_dev_cache.json
at import time (no network call) and falls back to a small static list
when the cache is missing or malformed.

Why: _PROVIDER_MODELS["xai"] has drifted once already (issue #16699) and
will drift again next time xAI renames a model. Hermes already maintains
the models.dev cache and uses it for context-length lookups; pointing
_PROVIDER_MODELS at the same source means the /model picker self-heals on
the next cache refresh instead of requiring a PR.

Behavior:
- With cache populated (normal user): shows every current xAI model ID,
  picks up renames automatically on next refresh.
- Without cache (fresh install, offline): falls back to a static snapshot
  of the 9 current flagship IDs.
- Malformed cache / unexpected shape: same static fallback, no crash.

Import time verified <20ms — disk read only, no HTTP.

Addresses the structural piece of #16699 ("consider a single
_provider_models(provider) resolver") for xAI. Other per-provider lists
can adopt the same pattern as drift is observed.
@teknium1 teknium1 merged commit a83f669 into main Apr 28, 2026
11 of 12 checks passed
@teknium1 teknium1 deleted the hermes/hermes-629a7af8 branch April 28, 2026 08:49
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard provider/xai xAI (Grok) labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/xai xAI (Grok) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] _PROVIDER_MODELS["xai"] is stale — grok-4.20-reasoning renamed; broader fragility from hardcoded provider lists

3 participants