From 8a246910bf0fc10ff2922f633715707a596af320 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 15 Apr 2026 22:22:07 -0700 Subject: [PATCH] fix: reject startup when no provider configured instead of silent OpenRouter fallback (#10766) When no provider was set in config.yaml and auto-detection found no credentials, the agent silently fell back to bare OPENROUTER_API_KEY from the environment and sent the configured model name to OpenRouter. This produced undefined behavior -- wrong provider, wrong model routing, and auxiliary tasks (compression, vision) hitting the wrong endpoint. Fix: replace the silent fallback with a hard RuntimeError telling the user to run hermes model or hermes setup. The provider must be explicitly configured -- env vars are for secrets, not config. --- run_agent.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/run_agent.py b/run_agent.py index 47473eb51..110c3137c 100644 --- a/run_agent.py +++ b/run_agent.py @@ -1021,16 +1021,12 @@ class AIAgent: f"was found. Set the {_env_hint} environment " f"variable, or switch to a different provider with `hermes model`." ) - # Final fallback: try raw OpenRouter key - client_kwargs = { - "api_key": os.getenv("OPENROUTER_API_KEY", ""), - "base_url": OPENROUTER_BASE_URL, - "default_headers": { - "HTTP-Referer": "https://hermes-agent.nousresearch.com", - "X-OpenRouter-Title": "Hermes Agent", - "X-OpenRouter-Categories": "productivity,cli-agent", - }, - } + # No provider configured — reject with a clear message. + raise RuntimeError( + "No LLM provider configured. Run `hermes model` to " + "select a provider, or run `hermes setup` for first-time " + "configuration." + ) self._client_kwargs = client_kwargs # stored for rebuilding after interrupt