fix(models_dev): alias opencode-free to the Zen "opencode" catalog; pin Muse Spark 1M invariant

opencode-free had no PROVIDER_TO_MODELS_DEV entry, so every models.dev
lookup on the free tier missed and Muse Spark fell to the 256K default.
The free tier is served by the Zen relay (hermes_cli/models.py:
"opencode-free is Zen-hosted"), and models.dev's "opencode" provider is
the catalog that lists muse-spark-1.2 / -1.2-contributor-free /
-1.3-contributor-free at 1,048,576 — so the alias is "opencode", not
"opencode-go" (Go's catalog carries only the paid -contributor SKUs).

Missing alias identified by @Steve-prog001 in #101905.

Tests: one parametrized offline invariant (models.dev + live /models
mocked away) asserting 1,048,576 on opencode-free / opencode-go /
meta-ai / commandcode — fails on main, passes here — plus the alias pin.
This commit is contained in:
Teknium
2026-09-03 00:12:00 -07:00
parent 779aecb62b
commit 4359af7705
3 changed files with 26 additions and 1 deletions

View File

@@ -188,6 +188,11 @@ PROVIDER_TO_MODELS_DEV: Dict[str, str] = {
"ai-gateway": "vercel",
"opencode-zen": "opencode",
"opencode-go": "opencode-go",
# opencode-free is Zen-hosted (the free tier lives on the Zen relay, see
# hermes_cli/models.py), and models.dev's "opencode" catalog is the one
# that lists its *-contributor-free SKUs — without this alias every
# opencode-free lookup missed models.dev entirely.
"opencode-free": "opencode",
"kilocode": "kilo",
"fireworks": "fireworks-ai",
"huggingface": "huggingface",

View File

@@ -303,6 +303,21 @@ class TestDefaultContextLengths:
model, provider="kimi-coding", base_url=base_url
) == 1_048_576
@pytest.mark.parametrize("model, provider, base_url", [
("muse-spark-1.3-contributor-free", "opencode-free", "https://opencode.ai/zen/v1"),
("muse-spark-1.3-contributor", "opencode-go", "https://opencode.ai/zen/go/v1"),
("muse-spark-1.3", "meta-ai", "https://api.meta.ai/v1"),
("meta/muse-spark-1.3", "commandcode", "https://api.commandcode.ai/provider/v1"),
])
def test_muse_spark_resolves_1m_without_network(self, model, provider, base_url):
"""Muse Spark is 1,048,576 on every host even when models.dev and the
live /models probe are unavailable (fresh HERMES_HOME, offline)."""
with patch("agent.model_metadata.get_cached_context_length", return_value=None), \
patch("agent.model_metadata._query_ollama_api_show", return_value=None), \
patch("agent.model_metadata.fetch_endpoint_model_metadata", return_value={}), \
patch("agent.models_dev.fetch_models_dev", return_value={}):
assert get_model_context_length(model, provider=provider, base_url=base_url) == 1_048_576
def test_empty_model_uses_fallback_context(self):
assert get_model_context_length("") == DEFAULT_FALLBACK_CONTEXT
assert get_model_context_length(None) == DEFAULT_FALLBACK_CONTEXT # type: ignore[arg-type]

View File

@@ -1,4 +1,4 @@
"""Meta Model API maps to the models.dev 'meta' provider id (context/pricing)."""
"""Muse Spark hosts map to the right models.dev provider id (context/pricing)."""
from agent.models_dev import PROVIDER_TO_MODELS_DEV
@@ -6,3 +6,8 @@ from agent.models_dev import PROVIDER_TO_MODELS_DEV
def test_meta_ai_maps_to_meta():
assert PROVIDER_TO_MODELS_DEV.get("meta-ai") == "meta"
assert PROVIDER_TO_MODELS_DEV.get("meta") == "meta"
def test_opencode_free_maps_to_zen_catalog():
# The free tier is served by the Zen relay, whose models.dev id is "opencode".
assert PROVIDER_TO_MODELS_DEV.get("opencode-free") == "opencode"