fix: filter invalid MoA slot providers

This commit is contained in:
iniak 2026-07-13 01:46:38 +08:00 committed by Teknium
parent d4c6ae7b11
commit a7d78ad685
2 changed files with 32 additions and 2 deletions

View File

@ -29,7 +29,10 @@ def _prompt_choice(title: str, rows: list[str], default: int = 0) -> int:
def _model_options() -> list[dict[str, Any]]:
payload = build_models_payload(
load_picker_context(),
include_unconfigured=True,
# Slot pickers must only offer providers the user can actually call.
# Including setup-only rows makes an unconfigured canonical provider
# (usually OpenRouter, due to catalog ordering) become the default.
include_unconfigured=False,
picker_hints=True,
canonical_order=True,
pricing=True,
@ -37,7 +40,13 @@ def _model_options() -> list[dict[str, Any]]:
max_models=200,
)
providers = payload.get("providers") or []
return [p for p in providers if p.get("slug") and p.get("models")]
return [
p
for p in providers
if p.get("slug")
and str(p.get("slug")).strip().lower() != "moa"
and p.get("models")
]
def _pick_slot(current: dict[str, str] | None = None) -> dict[str, str]:

View File

@ -14,6 +14,27 @@ from hermes_cli.moa_config import (
)
def test_moa_slot_picker_excludes_unconfigured_providers(monkeypatch):
from hermes_cli import moa_cmd
captured = {}
monkeypatch.setattr(moa_cmd, "load_picker_context", lambda: object())
def fake_build(_context, **kwargs):
captured.update(kwargs)
return {
"providers": [
{"slug": "moa", "models": ["default"]},
{"slug": "opencode-go", "models": ["deepseek-v4-pro"]},
]
}
monkeypatch.setattr(moa_cmd, "build_models_payload", fake_build)
assert [row["slug"] for row in moa_cmd._model_options()] == ["opencode-go"]
assert captured["include_unconfigured"] is False
def test_normalize_moa_config_uses_default_named_preset():
cfg = normalize_moa_config({})