fix(fallback): pass explicit credentials from fallback config to provider router - #2705
Closed
tannerfokkens-maker wants to merge 1 commit into
Closed
Conversation
…ider router
When fallback_model is configured with a custom provider (base_url + api_key),
_try_activate_fallback() was calling resolve_provider_client() without forwarding
the explicit base_url and api_key from the fallback config. This caused the
provider router to fall through to environment variable resolution (OPENAI_BASE_URL,
OPENAI_API_KEY), which typically point at the primary/exhausted endpoint — silently
defeating the fallback mechanism for custom providers.
Now passes fb.get("base_url") and fb.get("api_key") as explicit_base_url and
explicit_api_key, which resolve_provider_client() already supports but were
never being used from this call site.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Thanks for the contribution @tannerfokkens-maker! This fix has since been implemented independently on This is an automated hermes-sweeper review. Evidence that the fix is already on main:
|
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
_try_activate_fallback()was ignoringbase_urlandapi_keyfrom thefallback_modelconfig when callingresolve_provider_client(). For custom providers, this caused the router to fall through to environment variable resolution (OPENAI_BASE_URL/OPENAI_API_KEY), which typically still point at the primary (exhausted) endpoint — silently defeating the entire fallback mechanism.fb.get("base_url")andfb.get("api_key")asexplicit_base_urlandexplicit_api_key, parameters thatresolve_provider_client()already supports but were never used from this call site.Reproduction
Configure a custom fallback provider in
config.yaml:Exhaust the primary model's quota. Before this fix, fallback activation would fail because the provider router never received the custom endpoint credentials — it tried env vars instead, which either pointed at the primary or weren't set.
Test plan
base_url/api_keyareNonein configtests/test_fallback_model.pysuite🤖 Generated with Claude Code