Skip to content

fix(azure-foundry): send Bearer auth to anthropic_messages, keep 1M beta (salvage #27022)#28084

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-84f3d03a
May 18, 2026
Merged

fix(azure-foundry): send Bearer auth to anthropic_messages, keep 1M beta (salvage #27022)#28084
teknium1 merged 2 commits into
mainfrom
hermes/hermes-84f3d03a

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvages @sharziki's #27022 and fixes a hidden side-effect.

Summary

Azure AI Foundry's /anthropic endpoint requires Authorization: Bearer instead of x-api-key. Without this, requests return HTTP 401.

Changes

  • agent/anthropic_adapter.py::_requires_bearer_auth — add azure.com (sharziki's fix(auth): send Bearer auth for Azure Foundry anthropic_messages endpoints #27022).
  • agent/anthropic_adapter.py::_common_betas_for_base_url — guard the beta-strip on a new _is_minimax_anthropic_endpoint predicate instead of _requires_bearer_auth. Otherwise, folding Azure into the bearer-auth branch silently triggered the MiniMax-specific strip of fine-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-version query param plumbing, and context-1m-2025-08-07 survives.

Validation

  • scripts/run_tests.sh tests/agent/ → 3073/3073 passing (no regressions).
  • New test exercises the exact azure.com host shape end-to-end through build_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

sharziki and others added 2 commits May 18, 2026 09:21
…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.
@teknium1 teknium1 merged commit f0c6d59 into main May 18, 2026
14 of 15 checks passed
@teknium1 teknium1 deleted the hermes/hermes-84f3d03a branch May 18, 2026 16:27
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-84f3d03a vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8787 on HEAD, 8787 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4617 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder provider/anthropic Anthropic native Messages API P3 Low — cosmetic, nice to have labels May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P3 Low — cosmetic, nice to have provider/anthropic Anthropic native Messages API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Azure Foundry provider sends x-api-key instead of Bearer auth for anthropic_messages endpoints (HTTP 401)

3 participants