Repository navigation
fix(anthropic): forward the dangerous-tool-use beta to Azure AI Foundry - #43934
Conversation
Map dangerous-tool-use-2026-09-03 for azure_ai in the beta header config so the Claude Code auto mode beta reaches Foundry instead of being stripped, matching the anthropic, bedrock, and vertex_ai entries
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ded5957. Configure here.
TLDR
Problem this solves:
dangerous-tool-use-2026-09-03forazure_aisafeguardsand the client'santhropic-betato Foundry, that beta is stripped, so Foundry answers 400How it solves it:
azure_ai, so Foundry gets the header next tosafeguardswhenever the gateway forwards itazure_aifor the dangerous-tool-use betaWhat it does not solve: at a default config (no
general_settings.forward_client_headers_to_llm_api) the proxy never handsazure_aithe client'santhropic-betaheader, so Claude Code auto mode through Foundry is unchanged on main by this PR alone. The real Claude Code legs below show it. The default-config fix is #43955 (LIT-8284), which adds the beta from thesafeguardsbody fieldUser Flow
Before: a Claude Code user in auto mode whose gateway routes Claude to Azure AI Foundry runs every tool call without the server-side classifier
azure_ai/claude-sonnet-4-6deployment on a Foundry/anthropicbase and setsforward_client_headers_to_llm_api: trueANTHROPIC_BASE_URLat the gateway and--permission-mode auto, then asks it to read a file and run a shell commandsafeguards: [{"type": "dangerous_tool_use", ...}]andanthropic-beta: ...,dangerous-tool-use-2026-09-03safeguardsbut drops that beta, and Foundry answers 400safeguards: Extra inputs are not permittedsafeguards, the Bash tool runs with noAllowed by auto mode classifierline, and/statusshowsAuto mode server: DisabledAfter, with
forward_client_headers_to_llm_api: true: the same session runs its tool calls through the classifiersafeguardsand the betasafeguards, and Foundry answers 200 withsafeguard_results("outcome": "not_flagged"), streaming includedAllowed by auto mode classifierand/statusshowsAuto mode server: EnabledAfter, at a default config: steps 1 to 5 of Before, unchanged, until #43955 lands
Relevant issues
Needed by #43662, the v1.103.x backport of the safeguards passthrough: every proxy fetches this map from main at boot, so its Foundry case answers 400 until this lands
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
#43934 alone does not cure Claude Code auto mode through Azure AI Foundry on main. At a default config, real Claude Code behaves the same before and after this PR: the first tool-call request gets a 400 from the gateway, Claude Code retries it without
safeguards, the tool runs on the client-side classifier only, and/statusreportsAuto mode server: Disabled. The map change itself works, which the third leg shows withforward_client_headers_to_llm_api: trueon. What is left is the proxy's header scoping, fixed in #43955 (LIT-8284)QA ran on ed4caeb, this PR's squash commit on main; the PR branch tip ded5957 carries the same product diff. The earlier curl-only proof at ded5957 is replaced by this run, since a curl is not the request shape Claude Code sends
Setup, shared by all three legs
The client is real Claude Code v2.1.286 driven in a tmux pane, the way a developer uses it. Each proxy ran on its own from the tree named by the leg, with
--num_workers 2, no database, on port 51823, one at a time, withLITELLM_LOCAL_ANTHROPIC_BETA_HEADERS=Trueso it reads the beta map checked out in its own tree instead of fetching main's. The default config is this file, with nothing undergeneral_settings:Claude Code was started in an empty directory holding one
notes.txt:Each leg then sends the prompt
Read notes.txt, then use the Bash tool to run: echo hello from the gateway, waits for the turn to finish, and runs/statusBefore (b41715b, default config)
Allowed by auto mode classifierline. The gateway's access log shows the firstPOST /v1/messages?beta=trueanswered 400 and the retry answered 200/statusreportsAuto mode server: DisabledAfter (ed4caeb, default config): unchanged
Allowed by auto mode classifierline, and the gateway's access log shows the same 400 then 200 pair/statusstill reportsAuto mode server: DisabledAfter (ed4caeb,
forward_client_headers_to_llm_api: true): classifier ongeneral_settings: {forward_client_headers_to_llm_api: true}, start Claude Code as above, send the promptAllowed by auto mode classifier, and everyPOST /v1/messages?beta=truein the gateway's access log answered 200/statusreportsAuto mode server: EnabledThe same setting on b41715b still answers 400 (the second row of the curl table below), so the map change is necessary for the classifier on main and the setting alone does nothing
Secondary check: curl
Run against each proxy right after its Claude Code leg, with
$BODYbeing the JSON below,"stream"flipped per case, and the control case withsafeguardsremoved:{"model":"claude-sonnet-4-6","max_tokens":256,"stream":false,"safeguards":[{"type":"dangerous_tool_use","classifier_context":{"v":1,"permission_mode":"auto"}}],"tools":[{"name":"Bash","description":"Runs a shell command","input_schema":{"type":"object","properties":{"command":{"type":"string"}},"required":["command"]}}],"messages":[{"role":"user","content":"Use the Bash tool to run: echo hello"}]}req_011CfaXvAbfj7TmQzszjCPYmmsg_011CfaXvF92VNmvsiRAfeoFyreq_011CfaW8LKfV6vpQjQcJT1Bamsg_011CfaW8Qg79i9nsXv5APn8breq_011CfaYLzuxKi5r5gke94AXNmsg_011CfaYM6QcKryXAN9yKc714msg_011CfaYaS88kH8L5EEVJhUYLmsg_011CfaYapdUCXJ21uL2y1hCQThe 400 body is Foundry's, passed through:
safeguards: Extra inputs are not permitted. The two 200s with safeguards carrysafeguard_results("outcome": "not_flagged"), in the message body when not streaming and in themessage_deltaevent when streaming. The second row ran earlier on the same tree through aclaude-haiku-4-5deployment on port 61287; the rest ran on port 51823 throughclaude-sonnet-4-6Observations from the run:
Type
🐛 Bug Fix
Caveats (if any)
Medium
azure_ainever receives the client'santhropic-betaheader, so Claude Code auto mode through Foundry is unchanged by this PR alone, shown by the After leg aboveforward_client_headers_to_llm_api: truegets it to Foundry todaysafeguards(fix(anthropic): backport #42152 and #42288 to stable/1.103.x #43662); fix(anthropic): add the dangerous-tool-use beta when a /v1/messages request carries safeguards #43955 does the same on main (LIT-8284)safeguardsrequest whose client leaves out the beta still gets Foundry's 400 on main; Claude Code always sends the beta next tosafeguards, so its flow is covered once the header reaches FoundryLow
LITELLM_LOCAL_ANTHROPIC_BETA_HEADERS=Trueon its next upgradeFinal Attestation