mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-24 16:54:43 +00:00
fix(tui_gateway): skip credential warning for keyless custom providers
`no-key-required` is a valid sentinel for local/self-hosted/custom routers. Warning on it made Desktop treat a working setup as missing API keys. Co-authored-by: Yingliang Zhang <zhangyingliang@outlook.com> Co-authored-by: Brandon R <kingdomwarrior23@gmail.com>
This commit is contained in:
parent
7cbdcf1ba6
commit
a01499136d
2 changed files with 27 additions and 4 deletions
|
|
@ -4901,6 +4901,20 @@ def test_setup_status_reports_provider_config(monkeypatch):
|
|||
assert resp["result"]["provider_configured"] is False
|
||||
|
||||
|
||||
def test_probe_credentials_emits_exact_empty_key_warning():
|
||||
agent = types.SimpleNamespace(api_key="", provider="openrouter")
|
||||
|
||||
assert server._probe_credentials(agent) == (
|
||||
"No API key configured for provider 'openrouter'. First message will fail."
|
||||
)
|
||||
|
||||
|
||||
def test_probe_credentials_allows_keyless_custom_runtime():
|
||||
agent = types.SimpleNamespace(api_key="no-key-required", provider="custom")
|
||||
|
||||
assert server._probe_credentials(agent) == ""
|
||||
|
||||
|
||||
def test_setup_runtime_check_rejects_empty_runtime_key(monkeypatch):
|
||||
monkeypatch.setattr("hermes_cli.main._has_any_provider_configured", lambda: True)
|
||||
monkeypatch.setattr(
|
||||
|
|
@ -4914,8 +4928,13 @@ def test_setup_runtime_check_rejects_empty_runtime_key(monkeypatch):
|
|||
|
||||
resp = server.handle_request({"id": "1", "method": "setup.runtime_check", "params": {}})
|
||||
|
||||
assert resp["result"]["ok"] is False
|
||||
assert resp["result"]["provider"] == "openrouter"
|
||||
assert resp["result"] == {
|
||||
"ok": False,
|
||||
"provider": "openrouter",
|
||||
"model": None,
|
||||
"source": "env/config",
|
||||
"error": "No usable credentials found for openrouter.",
|
||||
}
|
||||
|
||||
|
||||
def test_setup_runtime_check_allows_no_key_custom_runtime(monkeypatch):
|
||||
|
|
|
|||
|
|
@ -3866,11 +3866,15 @@ def _get_usage(agent) -> dict:
|
|||
|
||||
|
||||
def _probe_credentials(agent) -> str:
|
||||
"""Light credential check at session creation — returns warning or ''."""
|
||||
"""Light credential check at session creation — returns warning or ''.
|
||||
|
||||
``no-key-required`` is a valid sentinel for keyless custom providers; only
|
||||
warn when the key is genuinely missing.
|
||||
"""
|
||||
try:
|
||||
key = getattr(agent, "api_key", "") or ""
|
||||
provider = getattr(agent, "provider", "") or ""
|
||||
if not key or key == "no-key-required":
|
||||
if not key:
|
||||
return f"No API key configured for provider '{provider}'. First message will fail."
|
||||
except Exception:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue