fix(cli): warn when --provider default_model cannot be resolved

A named --provider without -m used to swallow lookup failures and
silently keep the global model.default. Log the resolution error so
the fallback is visible.
This commit is contained in:
Christopher
2026-08-15 22:27:04 +02:00
committed by Teknium
parent d6688adcc2
commit 3cbd86aac8
2 changed files with 34 additions and 1 deletions
+7 -1
View File
@@ -4865,7 +4865,13 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):
from hermes_cli.runtime_provider import _get_named_custom_provider
_named_custom = _get_named_custom_provider(provider)
except Exception:
except Exception as exc:
logger.warning(
"Could not resolve --provider %s default model; "
"keeping global model.default (%s)",
provider,
exc,
)
_named_custom = None
_provider_default = str((_named_custom or {}).get("model") or "").strip()
if _provider_default:
+27
View File
@@ -183,6 +183,33 @@ def test_explicit_model_wins_over_provider_default_model(monkeypatch):
assert shell.model == "explicit-id"
def test_provider_flag_logs_when_custom_default_model_cannot_resolve(monkeypatch, caplog):
"""A named --provider that fails to resolve must not fail silently."""
cli = _import_cli()
monkeypatch.setitem(
cli.CLI_CONFIG,
"model",
{"default": "tencent/hy3:free", "provider": "nous"},
)
def _boom(_name):
raise RuntimeError("catalog unavailable")
monkeypatch.setattr(
"hermes_cli.runtime_provider._get_named_custom_provider",
_boom,
)
with caplog.at_level("WARNING"):
shell = cli.HermesCLI(provider="gmk-lan", compact=True, max_turns=1)
assert shell.model == "tencent/hy3:free"
assert any(
"gmk-lan" in rec.getMessage() and "catalog unavailable" in rec.getMessage()
for rec in caplog.records
)
def test_hermes_cli_init_does_not_eagerly_resolve_runtime_provider(monkeypatch):
cli = _import_cli()
calls = {"count": 0}