Skip to content

The agent that grows with you

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

Christopher3cbd86aac857
diff --git a/cli.py b/cli.py
index 39faa07c339..084cd5941c3 100644
--- a/cli.py
+++ b/cli.py
@@ -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:
diff --git a/tests/cli/test_cli_provider_resolution.py b/tests/cli/test_cli_provider_resolution.py
index 3d5b60fc2f8..ff4734f8962 100644
--- a/tests/cli/test_cli_provider_resolution.py
+++ b/tests/cli/test_cli_provider_resolution.py
@@ -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}