fix(models): refresh stale xAI catalog + auto-derive from models.dev (#16699)#16925
Merged
Conversation
_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.
This was referenced Apr 28, 2026
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
The
/modelpicker 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)— @vominh1919Replaces 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:2.
fix(models): auto-derive xAI model list from models.dev cacheReplaces the static list with
_xai_curated_models(), mirroring_codex_curated_models()from #7844. Reads$HERMES_HOME/models_dev_cache.jsonat 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
/modelpicker 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:xaipresent but empty models dictTargeted 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.