Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions hermes_cli/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,15 @@ def _codex_curated_models() -> list[str]:
"glm-4.5",
"glm-4.5-flash",
],
# Curated fallback used when models.dev is unreachable. xAI is in
# _MODELS_DEV_PREFERRED below, so when models.dev is reachable the live
# catalog (filtered to tool_call=True) is merged on top of this list.
"xai": [
"grok-4.20-reasoning",
"grok-4-1-fast-reasoning",
"grok-4.20-0309-reasoning",
"grok-4.20-0309-non-reasoning",
"grok-4-fast",
"grok-4-fast-non-reasoning",
"grok-code-fast-1",
],
"nvidia": [
# NVIDIA flagship reasoning models
Expand Down Expand Up @@ -1735,6 +1741,7 @@ def _resolve_copilot_catalog_api_key() -> str:
"zai",
"gemini",
"google",
"xai",
})


Expand Down
38 changes: 38 additions & 0 deletions tests/hermes_cli/test_models_dev_preferred_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,44 @@ def test_opencode_zen_includes_fresh_models(self):
assert "claude-opus-4-7" in out
assert "kimi-k2.6" in out

def test_xai_is_preferred(self):
"""xAI catalog drifts (e.g. grok-4.20-* date-suffixed renames upstream),
so the picker must merge fresh models.dev entries on top of curated.
Regression for #16699 — selecting picker entries returned HTTP 400
because curated names had no match in xAI's live catalog.
"""
assert "xai" in _MODELS_DEV_PREFERRED

def test_xai_includes_fresh_models_dev_entries(self):
"""provider_model_ids('xai') surfaces current xAI IDs from models.dev."""
mdev = [
"grok-4.20-0309-reasoning",
"grok-4.20-0309-non-reasoning",
"grok-4-fast",
"grok-code-fast-1",
]
with patch("agent.models_dev.list_agentic_models", return_value=mdev):
out = provider_model_ids("xai")
# Fresh models surface (the picker bug from #16699 is fixed).
assert "grok-4.20-0309-reasoning" in out
assert "grok-4.20-0309-non-reasoning" in out
assert "grok-4-fast" in out
assert "grok-code-fast-1" in out

def test_xai_offline_falls_back_to_curated(self):
"""Offline models.dev → curated-only list, no crash, current IDs only.

The curated fallback must be valid current IDs (not stale renamed
ones), since users on offline/restricted networks see this list.
"""
with patch("agent.models_dev.list_agentic_models", return_value=[]):
out = provider_model_ids("xai")
# Curated floor must be real current xAI IDs.
assert "grok-4.20-0309-reasoning" in out
# Stale entries that returned HTTP 400 must be gone.
assert "grok-4.20-reasoning" not in out
assert "grok-4-1-fast-reasoning" not in out


class TestOpenRouterAndNousUnchanged:
"""Per Teknium: openrouter and nous are NEVER merged with models.dev."""
Expand Down
Loading