fix(anthropic): honor model.api_key from config.yaml - #11713
Closed
konsisumer wants to merge 1 commit into
Closed
Conversation
The anthropic provider paths in resolve_runtime_provider() hardcoded API key resolution to resolve_anthropic_token(), which only reads env vars and credential files. Users who configure model.api_key in config.yaml (common with self-hosted proxies like LiteLLM/OneAPI) were forced to also set ANTHROPIC_API_KEY as an environment variable, inconsistent with every other provider. Both the main anthropic branch and the explicit-override branch now read model.api_key (gated on model.provider == "anthropic" so unrelated keys don't leak) before falling back to resolve_anthropic_token().
This was referenced Apr 27, 2026
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
model.api_keyinconfig.yaml, forcing users to duplicate their key as an env var. Inconsistent with every other provider.model.api_key(and theapialias used elsewhere) before falling back toresolve_anthropic_token().model.provider == "anthropic"so an unrelated key configured for a different provider can't leak into Anthropic requests — mirrors the existingcfg_base_urlguard.Test plan
model.api_keyis used andresolve_anthropic_token()is not called when config hasprovider: anthropic+api_key.model.api_keyis ignored whenmodel.provideris a different provider (no cross-provider key leak).--base-urloverride combined withconfig.yaml api_keyresolves correctly.tests/hermes_cli/test_runtime_provider_resolution.py+test_anthropic_oauth_flow.py+test_anthropic_provider_persistence.pypass (75 tests) viascripts/run_tests.sh.