fix(azure-foundry): send Bearer auth to anthropic_messages, keep 1M beta (salvage #27022)#28084
Merged
Conversation
…oints Azure AI Foundry's Anthropic-style endpoint requires `Authorization: Bearer` instead of `x-api-key`. Add `azure.com` to `_requires_bearer_auth()` so the existing Bearer path at line 586 fires before the generic third-party branch sets `api_key` (x-api-key). Fixes #26970
Cherry-pick of @sharziki's #27022 routed Azure Foundry through _requires_bearer_auth, which also triggered the MiniMax-specific beta-strip in _common_betas_for_base_url — dropping the 1M-context beta from Azure even though Azure needs it for 1M context. Split the strip predicate: introduce _is_minimax_anthropic_endpoint so the fine-grained-tool-streaming and context-1m strips only fire for MiniMax hosts, leaving Azure's bearer-auth header swap intact without losing 1M context. Also add a regression test that asserts Azure gets Bearer auth, the api-version query param, and the context-1m-2025-08-07 beta.
Contributor
🔎 Lint report:
|
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.
Salvages @sharziki's #27022 and fixes a hidden side-effect.
Summary
Azure AI Foundry's
/anthropicendpoint requiresAuthorization: Bearerinstead ofx-api-key. Without this, requests return HTTP 401.Changes
agent/anthropic_adapter.py::_requires_bearer_auth— addazure.com(sharziki's fix(auth): send Bearer auth for Azure Foundryanthropic_messagesendpoints #27022).agent/anthropic_adapter.py::_common_betas_for_base_url— guard the beta-strip on a new_is_minimax_anthropic_endpointpredicate instead of_requires_bearer_auth. Otherwise, folding Azure into the bearer-auth branch silently triggered the MiniMax-specific strip offine-grained-tool-streaming+context-1m-2025-08-07, killing the 1M context window on Azure Foundry.tests/agent/test_anthropic_adapter.py— regression test: Azure →auth_token(Bearer),api-versionquery param plumbing, andcontext-1m-2025-08-07survives.Validation
scripts/run_tests.sh tests/agent/→ 3073/3073 passing (no regressions).azure.comhost shape end-to-end throughbuild_anthropic_client.Credit
Cherry-picked @sharziki's commit on top of current main; the follow-up fix to keep the 1M beta is on top. Rebase-merge preserves their authorship.
Fixes #26970
Closes #27022