fix(auxiliary): forward explicit_api_key to _try_openrouter for credential pool fallback#18618
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(auxiliary): forward explicit_api_key to _try_openrouter for credential pool fallback#18618liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…ntial pool fallback resolve_provider_client() receives explicit_api_key from the credential pool but _try_openrouter() never accepted or used it, causing OpenRouter fallback to silently ignore runtime pool keys and fall through to OPENROUTER_API_KEY (often empty). Now _try_openrouter() accepts an optional explicit_api_key parameter and uses it directly when provided, bypassing the pool/env lookup. Closes NousResearch#18338
Contributor
|
Closing in favour of the narrower fix in #18768 (salvage of your earlier #18341). #18341's approach — threading |
Cyrene963
pushed a commit
to Cyrene963/hermes-agent
that referenced
this pull request
May 3, 2026
Community PRs applied: - NousResearch#18596: Enable secret redaction by default (SECURITY) - NousResearch#18650: Sanitize malformed tool messages + auto-recover on API 400 - NousResearch#18607: Emergency compression before max_iterations exhaustion - NousResearch#18603: Compression fallback to main model on 413 rate limit - NousResearch#18638: Pass threshold_percent on model switch - NousResearch#18663: Strip extra_content from tool_calls for strict APIs - NousResearch#18618: Forward explicit_api_key to OpenRouter - NousResearch#18632: Show cache tokens in /insights breakdown - NousResearch#18614: Add idempotency guard for patch duplicate loops - NousResearch#18600: Raise ValueError when HERMES_HOME unset in profile mode - NousResearch#18616: Allow ZWJ emoji in context files - NousResearch#18582: Reload .env on /restart - NousResearch#18547: Stabilize system prompt prefix for KV cache reuse - NousResearch#18692: Strip FTS5 operators from session search truncation terms Fix: Add order_by_last_active=True to list_sessions_rich call (pre-existing commit 142b4bf code sync)
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolve_provider_client()receivesexplicit_api_keyfrom the credential pool and correctly propagates it to most downstream provider calls. However, when routing to OpenRouter, it calls_try_openrouter()without passingexplicit_api_key, silently ignoring it.This causes auth failures when the auxiliary client falls back to OpenRouter using a runtime API key from the credential pool — the key is available but never reaches the OpenRouter client constructor.
Root Cause
In
agent/auxiliary_client.py, the OpenRouter branch ofresolve_provider_client()(line ~2058):_try_openrouter()only checked the credential pool andOPENROUTER_API_KEYenv var — it never accepted an explicit key parameter.Fix
explicit_api_keyparameter to_try_openrouter(). When provided, it's used directly (bypassing pool/env lookup).resolve_provider_client()now passesexplicit_api_keyto_try_openrouter().Test Plan
test_explicit_api_key_used_for_openrouter— RED on main, GREEN with fixtest_auxiliary_client.pytests pass (107 passed, 5 pre-existing failures unrelated to this change)tests/agent/(2290 passed vs 2289 on main — +1 is the new test)Closes #18338