Skip to content

fix: fail fast when explicit provider has no API key instead of silent OpenRouter fallback (salvage #2272)#2445

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-5e6ebebb
Mar 22, 2026
Merged

fix: fail fast when explicit provider has no API key instead of silent OpenRouter fallback (salvage #2272)#2445
teknium1 merged 1 commit intomainfrom
hermes/hermes-5e6ebebb

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Based on PR #2272 by @StefanIsMe, applied manually to fix bugs in the original and extend coverage.

When a non-OpenRouter provider (e.g. minimax, anthropic) is set in config.yaml but its API key is missing, Hermes silently fell back to OpenRouter. This caused confusing 404 errors because OpenRouter received the request with the wrong model/endpoint.

Now checks provider not in ('auto', 'openrouter', 'custom') before falling back. Explicit providers raise RuntimeError with a clear message naming the missing env var. Auto/openrouter/custom providers still fall through to OpenRouter as before.

Changes from original PR

  • Fixed pconfig.api_key_env_vars NameError in auxiliary_client.py (variable doesn't exist in that scope)
  • Extended the fix to call_llm_streaming — the original PR only covered call_llm but the same silent fallback existed in the streaming path
  • Applied against current main (original was 116 commits behind)

Three code paths fixed

  1. run_agent.py AIAgent.__init__ — main client initialization
  2. agent/auxiliary_client.py call_llm — sync auxiliary calls
  3. agent/auxiliary_client.py call_llm_streaming — async auxiliary calls (not in original PR)

Verification

  • 5785 passed (26 pre-existing failures on main, confirmed identical)

Credit

Original idea and run_agent.py fix by @StefanIsMe in #2272.

…t OpenRouter fallback

When a non-OpenRouter provider (e.g. minimax, anthropic) is set in
config.yaml but its API key is missing, Hermes silently fell back to
OpenRouter, causing confusing 404 errors.

Now checks if the user explicitly configured a provider before falling
back. Explicit providers raise RuntimeError with a clear message naming
the missing env var. Auto/openrouter/custom providers still fall through
to OpenRouter as before.

Three code paths fixed:
- run_agent.py AIAgent.__init__ — main client initialization
- auxiliary_client.py call_llm — sync auxiliary calls
- auxiliary_client.py call_llm_streaming — async auxiliary calls

Based on PR #2272 by @StefanIsMe. Applied manually to fix a
pconfig NameError in the original and extend to call_llm_streaming.
@teknium1 teknium1 merged commit 306e67f into main Mar 22, 2026
1 check failed
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…t OpenRouter fallback (NousResearch#2445)

When a non-OpenRouter provider (e.g. minimax, anthropic) is set in
config.yaml but its API key is missing, Hermes silently fell back to
OpenRouter, causing confusing 404 errors.

Now checks if the user explicitly configured a provider before falling
back. Explicit providers raise RuntimeError with a clear message naming
the missing env var. Auto/openrouter/custom providers still fall through
to OpenRouter as before.

Three code paths fixed:
- run_agent.py AIAgent.__init__ — main client initialization
- auxiliary_client.py call_llm — sync auxiliary calls
- auxiliary_client.py call_llm_streaming — async auxiliary calls

Based on PR NousResearch#2272 by @StefanIsMe. Applied manually to fix a
pconfig NameError in the original and extend to call_llm_streaming.

Co-authored-by: StefanIsMe <StefanIsMe@users.noreply.github.com>
aashizpoudel pushed a commit to aashizpoudel/hermes-agent that referenced this pull request Mar 30, 2026
…t OpenRouter fallback (NousResearch#2445)

When a non-OpenRouter provider (e.g. minimax, anthropic) is set in
config.yaml but its API key is missing, Hermes silently fell back to
OpenRouter, causing confusing 404 errors.

Now checks if the user explicitly configured a provider before falling
back. Explicit providers raise RuntimeError with a clear message naming
the missing env var. Auto/openrouter/custom providers still fall through
to OpenRouter as before.

Three code paths fixed:
- run_agent.py AIAgent.__init__ — main client initialization
- auxiliary_client.py call_llm — sync auxiliary calls
- auxiliary_client.py call_llm_streaming — async auxiliary calls

Based on PR NousResearch#2272 by @StefanIsMe. Applied manually to fix a
pconfig NameError in the original and extend to call_llm_streaming.

Co-authored-by: StefanIsMe <StefanIsMe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants