Conversation
…c_messages providers When provider is minimax/alibaba/etc and MINIMAX_API_KEY is not set, the code fell back to resolve_anthropic_token() sending Anthropic OAuth credentials to third-party endpoints, causing 401 errors. Now only provider=="anthropic" triggers the fallback. Generalizes the Alibaba-specific guard from #1739 to all non-Anthropic providers.
Follow-up for cherry-picked PR #2383 — existing tests didn't set agent.provider, which the new guard requires to allow Anthropic token refresh.
2 tasks
outsourc-e
pushed a commit
to outsourc-e/hermes-agent
that referenced
this pull request
Mar 26, 2026
…s providers (salvage NousResearch#2383) (NousResearch#2389) * fix: prevent Anthropic token fallback leaking to third-party anthropic_messages providers When provider is minimax/alibaba/etc and MINIMAX_API_KEY is not set, the code fell back to resolve_anthropic_token() sending Anthropic OAuth credentials to third-party endpoints, causing 401 errors. Now only provider=="anthropic" triggers the fallback. Generalizes the Alibaba-specific guard from NousResearch#1739 to all non-Anthropic providers. * fix: set provider='anthropic' in credential refresh tests Follow-up for cherry-picked PR NousResearch#2383 — existing tests didn't set agent.provider, which the new guard requires to allow Anthropic token refresh. --------- Co-authored-by: 0xbyt4 <35742124+0xbyt4@users.noreply.github.com>
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
Salvage of PR #2383 by @0xbyt4, cherry-picked onto current main.
When a non-Anthropic provider uses
anthropic_messagesAPI mode (MiniMax, Alibaba, etc.) and the provider's own API key is missing,resolve_anthropic_token()fallback was sending Anthropic OAuth credentials to third-party endpoints, causing 401 errors.Generalizes the Alibaba-specific guard from #1739 to all non-Anthropic providers by flipping the logic: only
provider == "anthropic"triggers the Anthropic token fallback. Three code paths fixed:AIAgent.__init__— initial credential resolution_try_refresh_anthropic_client_credentials— credential refresh guard_try_activate_fallback— fallback activation path (had NO protection before)Follow-up fix
3 existing tests (
TestAnthropicCredentialRefresh,TestOAuthFlagAfterCredentialRefresh) neededagent.provider = "anthropic"added since the new guard checks this field.Verification
Credit
Original work by @0xbyt4 in #2383. Contributor authorship preserved via cherry-pick.