The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: Make MoA strictly opt-in in model pickers (#63353)
webtecnicaf4ac4aa6b88f
diff --git a/hermes_cli/inventory.py b/hermes_cli/inventory.pyindex afa0df8a982..6c6740beaad 100644--- a/hermes_cli/inventory.py+++ b/hermes_cli/inventory.py@@ -770,7 +770,15 @@ def _prewarm_pricing_async(def _moa_provider_row(current_provider: str = "") -> dict | None:- """The virtual ``moa`` row shared by the CLI inventory and gateway picker; ``None`` without presets."""+ """The virtual ``moa`` row shared by the CLI inventory and gateway picker; ``None`` without presets.++ Strictly opt-in (#63353): the row only appears when the user's raw config.yaml explicitly+ enables at least one MoA preset. The synthesized ``default`` preset from+ ``normalize_moa_config({})`` — which every user gets via DEFAULT_CONFIG defaults — must not+ be treated as a user choice."""+ if not _raw_config_has_enabled_moa_preset():+ return None+try:from hermes_cli.config import load_configfrom hermes_cli.moa_config import normalize_moa_configdiff --git a/tests/hermes_cli/test_inventory.py b/tests/hermes_cli/test_inventory.pyindex 9eb5e7f10c5..10028df88da 100644--- a/tests/hermes_cli/test_inventory.py+++ b/tests/hermes_cli/test_inventory.py@@ -110,6 +110,52 @@ def _nous_row(model: str = "openai/gpt-5.5") -> dict:}+def test_build_models_payload_returns_expected_shape():+ rows = [+ {"slug": "openrouter", "name": "OpenRouter", "models": ["m1"],+ "total_models": 1, "is_current": True, "is_user_defined": False,+ "source": "built-in"},+ ]+ ctx = _empty_ctx(provider="openrouter", model="m1", base_url="")+ raw_config = {+ "moa": {+ "presets": {+ "default": {"enabled": True},+ },+ },+ }+ with (+ _list_auth_returning(rows),+ patch("hermes_cli.config.read_raw_config", return_value=raw_config),+ patch("hermes_cli.config.load_config", return_value=raw_config),+ ):+ payload = build_models_payload(ctx)+ assert set(payload.keys()) == {"providers", "model", "provider"}+ assert payload["model"] == "m1"+ assert payload["provider"] == "openrouter"+ assert payload["providers"][0]["slug"] == "moa"+ assert payload["providers"][0]["models"] == ["default"]+ assert payload["providers"][1:] == rows+++def test_build_models_payload_hides_moa_without_raw_preset():+ """Strict opt-in (#63353): no ``moa`` row when the raw config has no enabled preset —+ the DEFAULT_CONFIG ``default`` preset everyone gets via ``load_config()`` is not a user choice."""+ rows = [+ {"slug": "openrouter", "name": "OpenRouter", "models": ["m1"],+ "total_models": 1, "is_current": True, "is_user_defined": False,+ "source": "built-in"},+ ]+ ctx = _empty_ctx(provider="openrouter", model="m1", base_url="")+ # load_config() still returns the synthesized DEFAULT_CONFIG moa preset.+ synthesized = {"moa": {"presets": {"default": {"enabled": True}}}}+ with (+ _list_auth_returning(rows),+ patch("hermes_cli.config.read_raw_config", return_value={}),+ patch("hermes_cli.config.load_config", return_value=synthesized),+ ):+ payload = build_models_payload(ctx)+ assert [r["slug"] for r in payload["providers"]] == ["openrouter"]@@ -121,7 +167,8 @@ def _nous_row(model: str = "openai/gpt-5.5") -> dict:def test_include_unconfigured_appends_canonical_skeletons():"""include_unconfigured=True adds CANONICAL_PROVIDERS rows thatlist_authenticated_providers didn't emit. Skeleton rows have empty- models and source='canonical'."""+ models and source='canonical'. MoA is a virtual routing mode, not a+ canonical provider, so it is excluded — see issue #63353."""rows = [{"slug": "openrouter", "name": "OpenRouter", "models": ["m1"],"total_models": 1, "is_current": True, "is_user_defined": False,@@ -131,11 +178,13 @@ def test_include_unconfigured_appends_canonical_skeletons():with _list_auth_returning(rows):payload = build_models_payload(ctx, include_unconfigured=True)# All canonical providers other than openrouter should appear as- # skeleton rows.+ # skeleton rows. MoA is virtual/opt-in and excluded from unconfigured.from hermes_cli.models import CANONICAL_PROVIDERSseen_slugs = {r["slug"] for r in payload["providers"]}for entry in CANONICAL_PROVIDERS:+ if entry.slug == "moa":+ continue # virtual; only shown when explicitly configuredassert entry.slug in seen_slugs, f"missing {entry.slug}"# Skeletons have empty models and source='canonical'.skeletons = [r for r in payload["providers"]@@ -367,6 +416,37 @@ def test_canonical_order_uses_slug_not_is_user_defined_flag():)+def test_canonical_order_with_unconfigured_preserves_full_universe():+ """Combined picker call: include_unconfigured + picker_hints ++ canonical_order is the production TUI shape. Verify the result+ has CANONICAL_PROVIDERS in declaration order, hints applied,+ custom rows trailing. MoA is excluded from unconfigured skeletons+ (virtual, opt-in only — issue #63353).+ """+ from hermes_cli.models import CANONICAL_PROVIDERS++ rows = [+ {"slug": "custom:Ollama", "name": "Ollama", "models": [],+ "total_models": 0, "is_current": False, "is_user_defined": True,+ "source": "user-config"},+ ]+ ctx = _empty_ctx()+ with _list_auth_returning(rows):+ payload = build_models_payload(+ ctx,+ include_unconfigured=True,+ picker_hints=True,+ canonical_order=True,+ )+ slugs = [r["slug"] for r in payload["providers"]]+ # First row: first canonical provider in declaration order.+ assert slugs[0] == CANONICAL_PROVIDERS[0].slug+ # Custom row trails all visible canonical rows. MoA is virtual/opt-in+ # so it is excluded from the unconfigured skeleton set.+ visible_canonical_count = sum(+ 1 for e in CANONICAL_PROVIDERS if e.slug != "moa"+ )+ assert slugs.index("custom:Ollama") >= visible_canonical_count# ─── Integration: end-to-end through real load_picker_context ──────────