Files
hermes-webui/tests/test_issue5311_opencode_go_static_models.py
T
nesquena-hermes 14ad45bd1f fix(#5311): skip live /v1/models probe for opencode-go — use curated static list
OpenCode Go's /v1/models endpoint returns models from the full public catalog that
are NOT enabled on the Go tier; selecting any such probe-only model 404s
('model not found') when the chat request is sent. get_available_models now skips
the live probe for opencode-go (bare branch) so the next `if not raw_models` falls
through to the curated static _PROVIDER_MODELS['opencode-go'] list — the actual
Go-tier models. Narrow, provider-scoped; no other provider affected.

Contributor stage; gate-pass. Co-authored-by: webtecnica <webtecnica@users.noreply.github.com>
2026-07-05 05:05:30 +00:00

31 lines
1.3 KiB
Python

"""#5311 / #5611: OpenCode Go's live /v1/models probe returns public-catalog
models not enabled on the Go tier, so selecting one 404s on send. get_available_models
must skip the live probe for opencode-go and fall through to the curated static
_PROVIDER_MODELS list instead.
"""
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
CONFIG = (ROOT / "api" / "config.py").read_text(encoding="utf-8")
def test_opencode_go_skips_live_models_probe():
# The provider-loop must special-case opencode-go to skip the live probe.
body = CONFIG[CONFIG.index("def get_available_models"):]
body = body[: body.index("\ndef ", 1)]
assert 'elif pid == "opencode-go":' in body
# It must NOT call the live-provider probe on the opencode-go branch — the
# branch is a bare skip so the next `if not raw_models` falls back to static.
idx = body.index('elif pid == "opencode-go":')
branch = body[idx: idx + 400]
assert "_models_from_live_provider_ids" not in branch.split("else:")[0]
def test_opencode_go_has_curated_static_models():
# The static fallback the skip relies on must exist and be non-empty.
assert '"opencode-go": [' in CONFIG
block = CONFIG[CONFIG.index('"opencode-go": ['):]
block = block[: block.index("],") + 1]
assert block.count('"id":') >= 5