fix(tui): setup.runtime_check resolves like session creation and reports the model

Without an explicit `provider`, `setup.runtime_check` called the strict
`resolve_runtime_provider(requested=None)` while `_make_agent` goes through
`_resolve_agent_model_runtime` (startup model + provider pin, then the
configured fallback chain). With the primary blocked and a working fallback
entry the probe answered ok:False (the primary's auth error) and the Desktop
showed onboarding for a backend whose sessions built fine. The probe also
reported `model: null` because the resolver never populates that key.

The default case now runs the session builder's resolver; an explicit
`provider` stays a strict single-provider check (onboarding verifies the
provider just connected — another provider's fallback must not mask a failed
connection) and resolves against the startup model like the session would.
Both branches report the selected model.

Fixes #111775
This commit is contained in:
KoNit-K
2026-09-15 11:54:23 -07:00
committed by Teknium
parent 05e82b741d
commit 6f975b768e
2 changed files with 38 additions and 11 deletions
+22 -4
View File
@@ -9158,9 +9158,10 @@ def test_probe_credentials_allows_keyless_custom_runtime():
def test_setup_runtime_check_rejects_empty_runtime_key(monkeypatch):
monkeypatch.setattr("hermes_cli.main._has_any_provider_configured", lambda **_kw: True)
monkeypatch.setattr(server, "_resolve_startup_runtime", lambda: ("openrouter/test-model", None))
monkeypatch.setattr(
"hermes_cli.runtime_provider.resolve_runtime_provider",
lambda requested=None: {
lambda requested=None, **_kw: {
"provider": "openrouter",
"api_key": "",
"source": "env/config",
@@ -9172,7 +9173,7 @@ def test_setup_runtime_check_rejects_empty_runtime_key(monkeypatch):
assert resp["result"] == {
"ok": False,
"provider": "openrouter",
"model": None,
"model": "openrouter/test-model",
"source": "env/config",
"error": "No usable credentials found for openrouter.",
}
@@ -9182,7 +9183,7 @@ def test_setup_runtime_check_allows_no_key_custom_runtime(monkeypatch):
monkeypatch.setattr("hermes_cli.main._has_any_provider_configured", lambda **_kw: True)
monkeypatch.setattr(
"hermes_cli.runtime_provider.resolve_runtime_provider",
lambda requested=None: {
lambda requested=None, **_kw: {
"provider": "custom",
"api_key": "no-key-required",
"source": "env/config",
@@ -9199,7 +9200,7 @@ def test_setup_runtime_check_rejects_implicit_bedrock_when_unconfigured(monkeypa
monkeypatch.setattr("hermes_cli.main._has_any_provider_configured", lambda **_kw: False)
monkeypatch.setattr(
"hermes_cli.runtime_provider.resolve_runtime_provider",
lambda requested=None: {
lambda requested=None, **_kw: {
"provider": "bedrock",
"api_key": "aws-sdk",
"source": "iam-role",
@@ -9245,6 +9246,23 @@ def test_setup_runtime_check_honors_requested_provider(monkeypatch):
assert default["result"]["provider"] == "anthropic"
def test_setup_runtime_check_reports_target_model_on_credential_failure(monkeypatch):
"""#111775: the probe names the model session creation would use, never ``model: null``."""
monkeypatch.setattr("hermes_cli.main._has_any_provider_configured", lambda **_kw: True)
monkeypatch.setattr(server, "_resolve_startup_runtime", lambda: ("z-ai/glm-5.2", None))
monkeypatch.setattr(
"hermes_cli.runtime_provider.resolve_runtime_provider",
lambda *, requested=None, target_model=None: {
"provider": "zai", "api_key": "", "source": "env/config"
},
)
resp = server.handle_request({"id": "1", "method": "setup.runtime_check", "params": {}})
assert resp["result"]["ok"] is False
assert resp["result"]["model"] == "z-ai/glm-5.2"
def test_setup_readiness_scopes_to_requested_profile(monkeypatch, tmp_path):
"""#94071: the Desktop preflights a freshly created bot on its target
backend. ``profile`` binds THAT profile's home + .env — launch-process