From bb5d745ab156bafc5d0800e288c14cf96eeeeec2 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Tue, 15 Sep 2026 12:02:26 -0700 Subject: [PATCH] fix(catalog): keep the delisted deepseek-v4-flash-free out of the live OpenCode picker too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Zen relay still LISTS deepseek-v4-flash-free in GET /zen/v1/models but no longer serves it (opencode.ai/docs/zen dropped it; every anonymous POST 400s "Upstream request failed: Model is unavailable"). Removing it from the offline floor alone leaves the picker offering it whenever the live fetch succeeds — which is nearly always — so the first turn 400s and the fallback switch strands the session (#111749). Add it to the live-list exclusion set (renamed from the keyed-twin-only _OPENCODE_FREE_KEYED_SUFFIX_MODELS to _OPENCODE_FREE_EXCLUDED_MODELS, same semantics for ox-alpha-free), drop the same id from the opencode-zen keyed catalog (a Zen pick of a free slug heals to the keyless relay and 400s the same way), move the test fixture's "current free tier" to the relay's actual state, and pin the filter with one invariant test. --- hermes_cli/models.py | 21 ++++++----- hermes_cli/models_catalog_static.py | 2 +- .../test_opencode_free_live_catalog.py | 37 +++++++++++++++++-- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/hermes_cli/models.py b/hermes_cli/models.py index 8f9099987f..364629ec55 100644 --- a/hermes_cli/models.py +++ b/hermes_cli/models.py @@ -2138,12 +2138,15 @@ def normalize_opencode_model_id(provider_id: Optional[str], model_id: Optional[s OPENCODE_ZEN_FREE_KEYLESS_PLACEHOLDER = "opencode-zen-free-keyless" _OPENCODE_ZEN_FREE_BASE_URL = "https://opencode.ai/zen/v1" -# ``-free``-suffixed slugs that are KEYED (Go-subscription) models, NOT anonymous-servable — -# excluded from the keyless catalog despite the suffix (ox-alpha-free is Ox Alpha's Go twin). -# The Go relay delisted ox-alpha-free (2026-09-09; GET /zen/go/v1/models omits it, POST → 401), -# so it is gone from the opencode-go curated floor too — the exclusion stays so a stale live -# list can never route it into the keyless catalog. -_OPENCODE_FREE_KEYED_SUFFIX_MODELS = frozenset({"ox-alpha-free"}) +# ``-free``-suffixed slugs the live list may carry that the keyless catalog must NOT offer: +# - KEYED (Go-subscription) twins, not anonymous-servable despite the suffix (ox-alpha-free is +# Ox Alpha's Go twin; the Go relay delisted it 2026-09-09 — the exclusion stays so a stale live +# list can never route it into the keyless catalog). +# - Delisted ids the relay still LISTS but no longer serves: deepseek-v4-flash-free (promo ended; +# gone from opencode.ai/docs/zen by 2026-09-15 yet still in GET /zen/v1/models, and every POST +# 400s "Model is unavailable"). Offering it lets a first-turn 400 drive a fallback switch that +# strands the whole session (#111749). +_OPENCODE_FREE_EXCLUDED_MODELS = frozenset({"ox-alpha-free", "deepseek-v4-flash-free"}) # In-process memo for _fetch_opencode_free_models(): (fetched_at, ids-or-None). Validation and # healing call provider_model_ids("opencode-free") several times per resolution; failures are @@ -2170,8 +2173,8 @@ def opencode_zen_free_headers() -> dict: def _fetch_opencode_free_models( timeout: float = 8.0, *, force_refresh: bool = False) -> Optional[list[str]]: """Live keyless OpenCode Free catalog from the Zen relay, filtered to the anonymous-servable - ``*-free`` tier minus known keyed twins (Go ``ox-alpha-free`` is KEYED despite the suffix) — the - same membership criterion ``opencode_zen_free_runtime`` routes on.""" + ``*-free`` tier minus ``_OPENCODE_FREE_EXCLUDED_MODELS`` (keyed twins and listed-but-dead ids) — + the same membership criterion ``opencode_zen_free_runtime`` routes on.""" from hermes_cli.urllib_security import open_credentialed_url now = time.time() @@ -2194,7 +2197,7 @@ def _fetch_opencode_free_models( live_free = [ m["id"] for m in items if isinstance(m, dict) and isinstance(m.get("id"), str) - and m["id"].lower().endswith("-free") and m["id"].lower() not in _OPENCODE_FREE_KEYED_SUFFIX_MODELS + and m["id"].lower().endswith("-free") and m["id"].lower() not in _OPENCODE_FREE_EXCLUDED_MODELS ] result = live_free or None _set_opencode_free_live_memo(result) diff --git a/hermes_cli/models_catalog_static.py b/hermes_cli/models_catalog_static.py index 971de125d3..9a2c260c3d 100644 --- a/hermes_cli/models_catalog_static.py +++ b/hermes_cli/models_catalog_static.py @@ -228,7 +228,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = { "gemini-3.7-flash", "gemini-3.6-flash", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.1-pro", "gemini-3-flash", "grok-4.6", "grok-4.5", "grok-build-0.1", "muse-spark-1.2", "minimax-m3", "minimax-m2.7", "minimax-m2.5", "glm-5.3", "glm-5.3-flash", "glm-5.2", "glm-5.1", "glm-5", "kimi-k2.7-code", "deepseek-v4-pro", - "deepseek-v4-flash", "deepseek-v4-flash-free", "qwen3.6-plus", "qwen3.5-plus", "big-pickle", "mimo-v2.5-free", + "deepseek-v4-flash", "qwen3.6-plus", "qwen3.5-plus", "big-pickle", "mimo-v2.5-free", "nemotron-3-ultra-free", "nemotron-3.5-lightning-free", "muse-spark-1.2-contributor-free", "muse-spark-1.3-contributor-free", ], diff --git a/tests/hermes_cli/test_opencode_free_live_catalog.py b/tests/hermes_cli/test_opencode_free_live_catalog.py index 8bcc090361..b704c58c70 100644 --- a/tests/hermes_cli/test_opencode_free_live_catalog.py +++ b/tests/hermes_cli/test_opencode_free_live_catalog.py @@ -33,9 +33,9 @@ _STATIC_FLOOR = list(_PROVIDER_MODELS["opencode-free"]) # The live relay's current free tier. x-preview-f-free was DELISTED 2026-08-26; # hy3-free and laguna-s-2.1-free were DELISTED 2026-09-09 (gone from live -# /models, anon 401 "Model … is not supported"). +# /models, anon 401 "Model … is not supported"); deepseek-v4-flash-free was +# DELISTED 2026-09-15 (still LISTED by /models, every POST 400s "Model is unavailable"). _LIVE_FREE_MODELS = [ - "deepseek-v4-flash-free", "mimo-v2.5-free", "nemotron-3-ultra-free", "nemotron-3.5-lightning-free", @@ -50,6 +50,7 @@ _LIVE_RAW_IDS = _LIVE_FREE_MODELS + [ "claude-sonnet-5", # paid "gpt-5.6-sol", # paid "ox-alpha-free", # KEYED Go-subscription (suffix looks free) + "deepseek-v4-flash-free", # delisted but still listed; POST → 400 "Model is unavailable" ] @@ -63,7 +64,7 @@ class TestProviderModelIdsOpencodeFree: result = provider_model_ids("opencode-free") assert "x-preview-f-free" not in result # delisted — REVERT-PROOF - assert "deepseek-v4-flash-free" in result # newly-live — REVERT-PROOF + assert "nemotron-3-ultra-free" in result # newly-live — REVERT-PROOF assert "mimo-v2.5-free" in result # newly-live — REVERT-PROOF def test_live_catalog_filters_out_keyed_free_suffix_model(self): @@ -183,6 +184,36 @@ class TestOpencodeFreeFollowUps: assert calls["n"] == 1 self._reset_memo(mod) + def test_fetch_drops_listed_but_delisted_model(self): + """A delisted id the relay still LISTS (deepseek-v4-flash-free: docs/zen dropped it, + every POST 400s "Model is unavailable") must not reach the keyless picker; offering it + lets a first-turn 400 drive a fallback switch that strands the session (#111749).""" + import hermes_cli.models as mod + + self._reset_memo(mod) + + def fake_open(req, timeout): + import io, json as _json + + class _Resp(io.BytesIO): + def __enter__(self): + return self + + def __exit__(self, *a): + return False + + return _Resp(_json.dumps({"data": [{"id": m} for m in _LIVE_RAW_IDS]}).encode()) + + try: + with patch("hermes_cli.urllib_security.open_credentialed_url", fake_open): + live = mod._fetch_opencode_free_models(force_refresh=True) + finally: + self._reset_memo(mod) + assert live is not None + assert "deepseek-v4-flash-free" not in live + assert "ox-alpha-free" not in live + assert "mimo-v2.5-free" in live # control: a servable free model survives the filter + def test_heal_union_includes_live_only_model(self): """A newly-live free model absent from the static floor must still heal opencode-go/zen selections to the keyless Zen relay (sibling-site widen: