fix(auxiliary): propagate explicit_api_key to _try_openrouter()#18341
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(auxiliary): propagate explicit_api_key to _try_openrouter()#18341liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
When resolve_provider_client() passes explicit_api_key for OpenRouter auxiliary tasks, _try_openrouter() now accepts and honors this parameter instead of silently ignoring it and falling back to OPENROUTER_API_KEY env var. Root cause: _try_openrouter() had no explicit_api_key parameter, so even when callers wanted to pass a runtime credential pool key, it could not be used. Fix: - Add explicit_api_key: str = None parameter to _try_openrouter() - Prioritize explicit_api_key over pool key and env var - Update resolve_provider_client() call site to pass explicit_api_key Regression coverage: - Test that explicit_api_key is passed to OpenAI client when provided - Test that fallback to OPENROUTER_API_KEY still works when explicit_api_key is None Closes NousResearch#18338
Collaborator
Collaborator
|
Fix PR for #18338. |
Contributor
Author
Contributor
Closed
3 tasks
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
explicit_api_keyparameter to_try_openrouter()and honor itresolve_provider_client()to passexplicit_api_keywhen calling_try_openrouter()Root cause
_try_openrouter()had noexplicit_api_keyparameter, so whenresolve_provider_client()received anexplicit_api_keyand routed to OpenRouter,the explicit key was silently ignored and the function fell back to the
OPENROUTER_API_KEYenvironment variable (or pool entry).This caused auth failures when auxiliary tasks used runtime credential pool keys
for OpenRouter fallback — the pool key was passed to
resolve_provider_client()but not to
_try_openrouter().Fix
explicit_api_key: str = Noneparameter to_try_openrouter()explicit_api_keyover pool key and env var in the non-pool pathresolve_provider_client()call site:_try_openrouter(explicit_api_key=explicit_api_key)Testing
tests/agent/test_auxiliary_client.pypassexplicit_api_keyis passed to OpenAI client when providedOPENROUTER_API_KEYstill works whenexplicit_api_keyis NoneAffected files
agent/auxiliary_client.py-_try_openrouter()signature and logictests/agent/test_auxiliary_client.py- Regression testsCloses #18338