mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
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.
This commit is contained in:
parent
c5acc6edb6
commit
8a246910bf
1 changed files with 6 additions and 10 deletions
16
run_agent.py
16
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue