Repository navigation
fix(anthropic): add the dangerous-tool-use beta when a /v1/messages request carries safeguards - #43955
Conversation
…equest carries safeguards
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
[Medium impact] The PR appears safe to merge, with no new actionable issues found. SummaryThe PR derives
Reviews (12) · Last reviewed commit: "fix(anthropic): gate safeguards on the b..." · Reviewed by Greptile |
Merging this PR will not alter performance
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…tool-use beta next to safeguards
|
bugbot run |
…pic-compatible providers
|
bugbot run |
…et for the type gate
|
bugbot run |
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
|
@litereview code-review |
…remote map on its own thread
|
@litereview code-review |
|
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 39fc45d. Configure here.
…and gate the derived beta on the map Gate the dangerous-tool-use beta derivation on the beta map the way #43955 does, so GitHub Copilot, DeepSeek, and opt-in passthroughs keep the merge base wire. Recognize /serving-endpoints/anthropic api_bases, fall back to the merge base routing for an api_base path the workspace trim does not know, strip Bedrock invocation metrics from the streamed message_stop, forward client betas to Databricks filtered by the map, and keep tool_choice when a dropped server tool has no name
…es (#46091) * fix(databricks): use the native Anthropic route for Claude /v1/messages Claude models on a Databricks workspace were bridged through chat completions on /v1/messages, which drops the safeguards field and never returns safeguard_results. They now call the workspace's /serving-endpoints/anthropic/v1/messages, the proxy forwards the client's anthropic-beta and anthropic-version headers to Databricks deployments, and the beta header map marks dangerous-tool-use-2026-09-03 as supported there. Any route whose platform does not take that beta drops safeguards together with it instead of answering 400. Non-Claude Databricks models keep the chat completions bridge * fix(databricks): derive the dangerous-tool-use beta from safeguards instead of forwarding client betas A Databricks Claude serving endpoint answers 400 to betas Claude Code sends on every turn, prompt-caching-scope-2026-01-05 among them, so the proxy no longer forwards the client's anthropic-beta header to Databricks deployments. The beta the classifier needs is derived from the safeguards body field, the same way the Azure AI route derives it. The Rust beta-header mirror stops rejecting the Databricks dangerous-tool-use cell so its config-cell test matches the JSON again * fix(databricks): keep the billing block, build the messages route once, and pass the partner user agent * fix(databricks): route Unity Catalog Claude names to the gateway messages route and keep env credentials Unity Catalog model-service names now reach the AI Gateway's native Anthropic route instead of a serving-endpoints path that answers 404 for them, and the native route resolves the key and base through the same order the chat route uses, so environment-only deployments keep working. The native route is limited to Databricks foundation-model Claude names, an unlisted provider forwards safeguards and the beta as sent, and the ten betas the workspace rejects are marked unsupported for Databricks in the beta map and its Rust mirror. * test(rust): expect Databricks to drop the advanced-tool-use beta * fix(databricks): keep passthrough safeguards, partner user agent, and classifier fallback Only the OpenAI-compatible JSON providers drop safeguards now, so a deployment opted into /v1/messages passthrough forwards the field and the beta as sent. When a route drops safeguards and the proxy has a classifier model, the proxy answers the verdict itself, as the chat completions bridge did. The Databricks Messages route also reads the databricks_user_agent param like the chat route. * fix(databricks): drop rejected server tools under drop_params, short-circuit web search, route UC names from a full Messages URL * fix(databricks): drop container on the native Messages route, as the chat completions bridge did * fix(databricks): keep every api_base on a route the workspace serves and gate the derived beta on the map Gate the dangerous-tool-use beta derivation on the beta map the way #43955 does, so GitHub Copilot, DeepSeek, and opt-in passthroughs keep the merge base wire. Recognize /serving-endpoints/anthropic api_bases, fall back to the merge base routing for an api_base path the workspace trim does not know, strip Bedrock invocation metrics from the streamed message_stop, forward client betas to Databricks filtered by the map, and keep tool_choice when a dropped server tool has no name * test(databricks): cover the native Messages route, derived beta and JSON provider safeguards drop on the wire * test(anthropic): expect the dangerous-tool-use beta derived from safeguards next to the client's betas * fix(databricks): send client anthropic headers only on the native Messages route and keep SDK auth Databricks chat completions, called directly or through the Messages bridge, no longer receive the client's anthropic-beta and anthropic-version, as at the merge base. The native Messages route still forwards them, filtered by the beta map, without counting them as caller credentials, so a deployment with no api_key keeps falling back to Databricks SDK auth. A pathless api_base goes to the native route only for Unity Catalog names, matching the chat route. * test(databricks): cover SDK auth with client anthropic headers and a Unity Catalog workspace root on the native route * fix(databricks): keep client anthropic headers off an opted-in passthrough api_base A databricks Claude deployment whose api_base is no workspace route and that opts into /v1/messages with supported_endpoints falls back to the OpenAI-like passthrough. That config does not filter betas through the beta map, yet it received the native-only Databricks header entry, so Claude Code's prompt-caching-scope beta reached the upstream raw and got a 400 where the merge base answered 200. Each Messages config now says whether it is the provider's native route, the OpenAI-like passthrough says no, and the handler passes that answer when it reads provider-specific headers, so native-only entries reach only native configs. * test(databricks): cover client anthropic betas on an opted-in passthrough api_base A databricks Claude deployment whose api_base is no workspace route and whose model_info.supported_endpoints opts into /v1/messages takes the OpenAI-like passthrough. The cell sends Claude Code's prompt-caching-scope and context-1m betas through the proxy and asserts the caller gets the upstream's message and the gateway receives no anthropic-beta, as on the merge base. The scripted gateway answers 400 on the prompt-caching-scope beta, as the real one does * fix(anthropic): keep beta map loads off shared threads and build the safeguards evaluator only when the proxy classifies Unfiltered configs such as first-party Anthropic never read the beta map to decide safeguards support. Filtered configs await the map on its dedicated loader before reading it, on both the native and the MCP paths. The native handler decides after the upstream call and builds the evaluator only when the proxy classifies, so malformed messages keep the upstream 400. The Databricks dispatch tests assert the dispatched route instead of the config class, and the sail and Eden AI wire rows expect safeguards dropped, as JSON providers do. * test(databricks): cover a loaded beta map that marks the safeguards beta unsupported A remote beta map that nulls dangerous-tool-use for databricks while the bundled map allows it must send neither safeguards nor the beta to the serving endpoint, with or without a client beta, and the caller gets a 200 with no verdict. * test(anthropic): annotate the MCP beta map recordings as Final * fix(anthropic): drop safeguards on routes without the classifier only under drop_params A route whose upstream does not answer safeguards (a JSON provider, or a map that marks the dangerous-tool-use beta unsupported) now forwards the field and the beta as the merge base did unless drop_params is set or the proxy runs its own classifier, matching how litellm treats any unsupported param. Databricks keeps dropping both, since its merge base bridge never forwarded the field. --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
…equest carries safeguards (BerriAI#43955) Backport of BerriAI#43955 to stable/1.103.x. Cherry-picked from eb5295b (main). Adapted to the line: the transformation lives under anthropic/experimental_pass_through, the integration tests live under tests/integration/providers, and the CLI-beta wire assertion change is dropped since that test is not on the line. The github_copilot safeguards test uses the line's authenticator mock, since per-user Copilot sessions are not on this line.
…ds wire test imports Backport prerequisite for BerriAI#43955 on stable/1.103.x. Copied from tests/integration/_support/vertex.py on main (added by BerriAI#43900).
…equest carries safeguards (BerriAI#43955) Backport of BerriAI#43955 to stable/1.106.x. Cherry-picked from eb5295b (main). Adapted to the line: the existing CLI-beta wire assertion change is dropped since that test is not on the line.
…equest carries safeguards (BerriAI#43955) Backport of BerriAI#43955 to stable/1.105.x. Cherry-picked from eb5295b (main). Handler import conflict resolved by keeping the line's imports plus aload_beta_headers_config; the CLI-beta wire assertion change is dropped since that test is not on the line.
…equest carries safeguards (BerriAI#43955) * fix(anthropic): add the dangerous-tool-use beta when a /v1/messages request carries safeguards * test(azure_ai): pin the outgoing Foundry request keeps the dangerous-tool-use beta next to safeguards * test(azure_ai): inject the Foundry client and scope the beta cache reset to the test * test(azure_ai): own and close the mock transport client, drop the docstring entry * test(integration): audit the safeguards beta derivation across anthropic-compatible providers * fix(github_copilot): keep safeguards from deriving the dangerous-tool-use beta * test(integration): kill the chaos victim worker through the harness helper * fix(anthropic): derive the dangerous-tool-use beta only where the beta map supports it and honor additional_drop_params The safeguards beta is now added only for providers whose beta map column accepts it, so github_copilot, Eden AI and the OpenAI-compatible JSON providers keep their base wire. additional_drop_params now runs before the provider headers are built, so a dropped param no longer drives its derived beta. * fix(anthropic): load the beta map off the event loop and pin a dropped context_management The first /v1/messages request that needs the remote beta map now loads it in a worker thread, so a slow fetch no longer stalls every other request on the worker. An integration cell pins that a deployment dropping context_management sends neither the field nor its derived beta. * fix(anthropic): load the beta map only for safeguards requests, once per worker * fix(anthropic): gate safeguards on the bundled beta map and load the remote map on its own thread --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> (cherry picked from commit eb5295b)
TLDR
Problem this solves:
anthropic-beta: dangerous-tool-use-2026-09-03never reaches Foundry (azure_ai is not a header-forwarding provider)safeguardsbody field, so Claude Code silently falls back to its client-side classifierforward_client_headers_to_llm_api: truecaseHow it solves it:
safeguardspresent addsdangerous-tool-use-2026-09-03anthropic_beta_headers_config.jsonsupports the beta get it (anthropic, which the Claude Platform on AWS also reads, and azure_ai), so this check never fetches anythingsafeguardsrequest to azure_ai, which filters betas, loads the remote beta map once per worker on its own thread, so a cold burst never holds the threads chat completions use. No other request fetches the map because of this PRadditional_drop_paramsnow applies before the headers are built, so a dropped param such assafeguardsorcontext_managementsends neither the field nor its betaAlternatives considered and the github_copilot decision
Adding azure_ai to the proxy's list of providers whose client
anthropic-*headers are forwarded would push every client anthropic header to every azure_ai deployment, Claude or not, and would still leave the fix dependent on the client sending the header. An azure_ai-only header merge (the shape stable took in #43662) duplicates the merge the shared beta derivation already does and, on main, needs two mutable-collection suppressions, so the check went into the shared derivation instead. The check keys onsafeguardsbeing present and not null, the same test the derivation applies tocontext_managementandoutput_format, so a non-array value now gets the provider's own validation error (safeguards: Input should be a valid array) instead of the unknown-field 400, and an empty array is left to the provider (200 on Foundry). Deriving only for a non-empty array was the alternative and was not taken, since it would hide a client's malformed value behind the pre-fix errorThe derivation is gated on the beta map through
is_beta_header_supported_by_bundled_config, which reads the copy of the map shipped with the release, so a provider gets the derived beta only where the map already says it accepts it. The OpenAI-compatible JSON providers inherit theanthropicprovider name in this code path, so they look up theopenai_likecolumn, which has no entry for the beta. The alternative was a deny list of providers that skip the derivation, which an earlier commit had for github_copilot alone. It was not taken because every provider with no filter (Sail, Meta, Prism, Eden AI, and any JSON provider added later) would start receiving a beta nobody verified they accept. A provider that supports it later gets it by adding its columnThe gate reads the bundled map and not the remote copy the provider filter loads. With the remote copy,
anthropicand the Claude Platform on AWS fetched it on their firstsafeguardsrequest, which the merge base never did, and a slow or blocked GitHub held that request for up to 5 seconds. The cost is that a provider column added only to the remote map reaches the derivation at the next release, while the filter still applies the remote copy, so a beta the remote map removes is still dropped. The alternatives were the remote copy with a fetch for every provider, or switching the filter to the bundled copy too. The first brings the fetch back, and the second changes how every beta is filtered, which this PR does not needThe remote map load for filtering providers runs on a dedicated one-thread executor and not on
asyncio.to_thread. With the shared default executor, each cold request waiting on the load held one of its threads, andlitellm.acompletionruns on those same threads, so 40 cold requests delayed an unrelated chat completion by about 3 seconds. The alternative was a per-worker async lock around the load, which still blocks the event loop when a sync caller holds the lockadditional_drop_paramsused to run after the headers were built, so a deployment that dropssafeguardswould still have sent the derived beta with no field to go with it. Dropping the params first means every derived beta, and every header built from a body param, follows the body that is actually sent. The alternative was to strip the beta again after the drop, which would need a second list of which beta belongs to which param and would miss the next derived betagithub_copilot has no column in the beta map, so a Copilot request with
safeguardsgoes out exactly as it does today:safeguardsin the body and no derived beta header. Nothing on hand can show whether Copilot accepts that beta on its Claude models, since the only Copilot login available is a Copilot Free account that Copilot serves no Claude model to. The alternatives were deriving it for Copilot too and verifying with a teammate's Copilot Pro or Business token, or adding a Copilot column unverified. Neither was taken, because a wrong guess turns a Copilot turn that works today into a 400, while leaving Copilot alone keeps today's behavior and can be widened later by adding its column once a Copilot account with Claude access can verify itsafeguardssent to ananthropic/model over/v1/chat/completionsor/v1/responsesstill goes out without the beta and gets Anthropic's 400, exactly as on the merge base. Deriving the beta there alone would turn that 400 into a 200 that silently loses the verdict, since neither response shape carriessafeguard_resultsyet. The alternatives were deriving the beta on those paths now, or deriving it and mappingsafeguard_resultsinto both response shapes. Neither was taken here, because the reported flow is Claude Code on/v1/messagesand the mapping is its own change, so a follow-up ticket tracks both togetherUser Flow
Before: a developer running Claude Code in auto mode against the proxy's Azure AI Foundry Claude deployment gets the client-side classifier instead of the server one
claude --permission-mode auto --model claude-sonnet-5-5withANTHROPIC_BASE_URL=https://litellm-domainand ask it to readnotes.txtand then runecho hello from the gatewaywith the Bash toolsafeguardsin the body andanthropic-beta: ...,dangerous-tool-use-2026-09-03safeguards: Extra inputs are not permitted, so Claude Code silently retries the same request withoutsafeguardsAllowed by auto mode classifierline, and/statusshowsAuto mode server: DisabledAfter: the same session gets the server-side classifier with no proxy config change
claude --permission-mode auto --model claude-sonnet-5-5withANTHROPIC_BASE_URL=https://litellm-domainand ask it to readnotes.txtand then runecho hello from the gatewaywith the Bash toolsafeguardsin the body andanthropic-beta: ...,dangerous-tool-use-2026-09-03safeguard_resultsin the responseAllowed by auto mode classifierand/statusshowsAuto mode server: EnabledLinear ticket
Part of LIT-8284
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 moreDelays 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
Both legs drive Claude Code in a terminal against the same two-worker proxy config with Foundry Claude deployments, booted from different commits
Rig and commands
Both legs ran on 2026-10-17 the same way: a proxy with
--num_workers 2and no database (127.0.0.1:23901from the merge base aa32e4c,127.0.0.1:48897from 39fc45d), a config with threeazure_aideployments on one Azure AI Foundry resource (claude-sonnet-5-5,claude-opus-5-5,claude-opus-5) and nogeneral_settings(so no client header forwarding), and Claude Code v2.1.299 started in a terminal asclaude --permission-mode auto --model <model>withANTHROPIC_BASE_URL=http://127.0.0.1:<port>, the proxy key asANTHROPIC_AUTH_TOKEN, andANTHROPIC_DEFAULT_HAIKU_MODEL=claude-sonnet-5-5. The prompt isRead notes.txt, then use the Bash tool to run: echo hello from the gateway, followed by/status. The curl sends the request shape Claude Code sends, withsafeguardsin the body and the client'santhropic-betaheader carryingdangerous-tool-use-2026-09-03Allowed by auto mode classifierAllowed by auto mode classifier/status, both modelsAuto mode server: DisabledAuto mode server: Enabledsafeguard_resultssafeguard_resultsBefore (aa32e4c, the merge base)
Boot the proxy from aa32e4c, start Claude Code against it as above, and send the prompt
The Bash tool runs on Claude Code's own classifier with no
Allowed by auto mode classifierline (Sonnet 5.5, then Opus 5.5)/statusshowsAuto mode server: DisabledThe curl: 400 on both models, the error Claude Code swallows before it retries without
safeguardsRaw output, the response body followed by the status code from
-wclaude-sonnet-5-5claude-opus-5After (39fc45d)
Boot the proxy from 39fc45d with the same config, start Claude Code the same way, and send the prompt
The Bash tool output shows
Allowed by auto mode classifier(Sonnet 5.5, then Opus 5.5)/statusshowsAuto mode server: EnabledThe curl: 200 with
safeguard_resultson both modelsRaw output, the response body followed by the status code from
-wclaude-sonnet-5-5claude-opus-5Observations:
/live-pr-risk at 39fc45d: no breaking change, every base 200 stays 200
/live-pr-risk (39fc45d vs its merge base aa32e4c)
Verdict: no dependent path that worked on the base fails on the head. The only outbound difference is the derived
anthropic-betavalue on anthropic, azure_ai, and the Claude Platform on AWS, plus nocontext-managementbeta from a deployment that dropscontext_management, every case sent exactly one upstream request on both sides, and every other vendor's wire is the same as the base'sRig: one proxy per side on a random port with
--num_workers 2, its own Postgres database,PYTHONPATHpinned to its worktree, nogeneral_settings,num_retries: 0, and thirteen deployments, each behind a forwarding recorder in front of the real vendor (mitmproxy for the SigV4 Claude Platform on AWS leg), so every request's headers, body keys, and count were diffed base vs head. Azure AI Foundry and Anthropic direct (bothclaude-sonnet-5-5) ran 12 cases each (with and withoutsafeguards, with and without the Claude Codeanthropic-beta, streaming,null,[], an int, an empty string, a 5 KB string, and a repeat), and every other deployment ran 2 (Claude Code header withsafeguards, andsafeguardsalone), including one Foundry and one Anthropic deployment withadditional_drop_params: [safeguards], plus one Anthropic deployment withadditional_drop_params: [context_management]sent acontext_managementeditazure_ai)safeguardsalonesafeguards: []"", 5 KB stringsafeguards,nullanthropic)safeguardsalonesafeguardscontext_managementResponse ids, vendor messages, and the merge-ref check
Head 200 ids: Foundry
msg_011Cg7LCEFrUtortjAFk2rGs(Claude Code header) andmsg_011Cg7LCW3tFadSZK1XwrJSf(safeguardsalone), Anthropicmsg_011Cg7LDjBgWmgbuKcokiUyd(safeguardsalone) andmsg_011Cg7LDdtwa9aRKMyrkR4Qk(no client beta), Claude Platform on AWSmsg_011Cg7LG4WqGMTiE2jnkKwRt. Base 400s on Foundry, Anthropic, and Claude Platform on AWS all carrysafeguards: Extra inputs are not permittedFor a non-array value the vendor's message changes from
Extra inputs are not permittedtoInput should be a valid array, still a 400 after one attempt. Eden AI, Sail, Meta, Prism, DeepSeek, Tencent, and MiniMax recorded the same headers and body on both sides with noanthropic-beta, so their answers are the base's. The two deployments withadditional_drop_params: [safeguards]sent nosafeguardsfield and no derived beta on either side (the Anthropic one forwards the client's own beta header on both sides, as the base does). The deployment droppingcontext_managementsent the field on neither side, and the base still sentanthropic-beta: context-management-2025-06-27while the head sent no beta (headmsg_011Cg7LGVtKekrLgBwcZowQ4, 200 on both)Merge-ref check: 39fc45d merged clean into current main (d346d76) as a06737d25f, booted the same way against the same recorders, and all 45 cases answered the status the head did with the same recorded headers and body keys. Merge-ref 200 ids: Foundry
msg_011Cg7LkHWhnZEjGjiu6PtPQ, Anthropicmsg_011Cg7Lmj9qd6gUGnWBwW2yN, Claude Platform on AWSmsg_011Cg7LpiMJj58VQY1ySdixU, each withsafeguard_resultsBreaking: none. Every base 200 stays 200 with the same response shape
Backward incompatible: a request carrying
safeguardswith no client beta, or withsafeguards: [], now succeeds on anthropic, azure_ai, and the Claude Platform on AWS where it used to answer 400, and a non-array value now gets the vendor's array validation error instead of the unknown-field one, both the PR's intended change.additional_drop_paramsnow applies before the proxy builds the provider headers on/v1/messages, so a dropped param no longer drives its derived beta. The drop cases above show it forsafeguardsandcontext_management(the base sent thecontext-managementbeta with no field, the head sends neither, both answer 200). A droppedoutput_formatfollows the same code path and was not driven live. A clientworkspace_idon the Claude Platform on AWS is not affected, since the proxy answers 401 to it unless the deployment allows it as a client credential, and thenadditional_drop_paramsnever touches it on either sideRegression risk: none found. Providers with no column for the beta in the beta map (github_copilot, Eden AI, the OpenAI-compatible JSON providers) get no derived beta, matching the base wire
Dependency graph: callers of the shared beta derivation are anthropic, azure_ai, bedrock
claude_platform, deepseek, tencent, minimax, theopenai_likeJSON providers, Eden AI, and github_copilot, all verified live except github_copilot. Callers of the movedadditional_drop_paramsstep are every/v1/messagesdeployment that sets it, verified live on Foundry and Anthropic. Vertex and bedrock invoke derive the beta in their own transformations, so the shared derivation does not reach them, but the movedadditional_drop_paramsstep does, which the X4 and X5 cells cover. The integration suites that mentionsafeguardsran on the head and are listed under the audit belowNot verified: github_copilot live, since no Copilot account with Claude access exists here (its unchanged wire is pinned by the audit's D20 cell); MiniMax and Sail vendor verdicts behind their 402s
Audit round 6 of 3 at 39fc45d: PASS
Audit round 6 of 3 (39fc45d vs merge base aa32e4c, past the cap for the High caveats on the beta map fetch)
Verdict: PASS. Every selected deterministic cell matched the inventory on the base and on both head runs, and every live row ran through the real vendor on both legs
safeguardssends no betasafeguardson vertex_ai sends no betacontext_managementsends no betasafeguardsrequests fetch the beta map, off the shared threadsRuns, node ids, and live rows
Rig: the box lane on this driver node, one leg per rig with its own Postgres and Redis, the owned upstream from
tests/integration/_support/upstream.py, and a two-worker proxy per leg ontests/integration/proxy_config.yamlwith nogeneral_settings. Each lane rantests/integration/run.py providerson the 46 node ids below with 4 pytest workers,--seed 4106601 --order-seed 0,INTEGRATION_PROXY_READY_SECONDS=240, one lane after anotherRuns: base (aa32e4c) 46 collected, 22 passed, 24 failed, every failure an
anthropic-betaassertion except C4, which never sees the map fetch the cold Foundry burst needs (State did not converge: 0); head A (39fc45d) 46 collected, 46 passed; head B (39fc45d) 46 collected, 46 passed, the same collected set and verdicts as head A, no retries. Lane scratch databases are dropped at lane end, so the deterministic rows carry their node ids rather than response idsNode ids, all in
tests/integration/messages_endpoint/providers/anthropic/:test_anthropic_safeguards_beta_wire.py(test_anthropic_messages_derive_the_dangerous_tool_use_beta_from_safeguards[D1 to D6],test_anthropic_sdk_sync_safeguards_derive_the_beta,test_anthropic_sdk_async_stream_safeguards_derive_the_beta_and_log_spend,test_azure_ai_sdk_sync_safeguards_derive_the_beta,test_azure_ai_messages_derive_the_beta_instead_of_forwarding_the_client_header[D9, D11 to D13],test_anthropic_compatible_providers_receive_the_beta_only_where_the_proxy_derives_it[D14 to D19, D21 to D24],test_github_copilot_messages_forward_safeguards_without_deriving_the_beta,test_non_native_deployments_bridge_to_the_responses_api_without_safeguards_or_the_beta,test_chat_completions_forward_safeguards_verbatim_without_deriving_the_beta,test_responses_stream_forwards_safeguards_verbatim_without_deriving_the_beta,test_a_deployment_dropping_safeguards_sends_neither_the_field_nor_the_beta[anthropic, azure_ai, bedrock_claude_platform, vertex_ai](X1, X2, X5, X4),test_a_deployment_dropping_context_management_sends_neither_the_field_nor_its_beta(X3),test_foundry_rejecting_a_non_array_safeguards_value_reaches_the_caller_after_one_attempt[S1 to S3],test_duplicate_safeguards_keys_resolve_to_the_last_value,test_the_same_safeguards_sent_twice_are_two_upstream_calls_with_two_spend_rows,test_upstream_errors_reach_the_caller_with_the_beta_sent_once[S6, S7],test_the_response_cache_serves_the_repeated_request_without_an_upstream_call),test_anthropic_safeguards_beta_chaos.py(C1 to C3, and C4test_cold_workers_fetch_the_beta_map_only_for_filtered_safeguards_requests_off_the_shared_threads), andtest_anthropic_wire.py::test_anthropic_messages_preserves_cli_beta_safeguards_and_result[non_stream, stream](W1, W2)Unit evidence:
test_llm_http_handler.py::test_anthropic_messages_dropped_safeguards_send_neither_the_field_nor_its_betapins the drop-before-headers order at the handler, and the azure_ai, github_copilot, and openai_like transformation tests (test_safeguards_request_carries_the_dangerous_tool_use_beta_without_the_client_header,test_outgoing_azure_request_sends_safeguards_with_the_dangerous_tool_use_beta,test_github_copilot_safeguards_do_not_derive_the_dangerous_tool_use_beta,test_safeguards_reach_an_openai_like_host_with_only_the_client_betas) pin the beta map gate per provider, all passing at the head withtest_anthropic_beta_headers_filtering.pyLive rows are the /live-pr-risk rig above, run once per leg against the real vendors: L1 Foundry, L2 Anthropic direct, and L10 Claude Platform on AWS go 400 to 200 with
safeguard_results(head idsmsg_011Cg7LCW3tFadSZK1XwrJSf,msg_011Cg7LDjBgWmgbuKcokiUyd,msg_011Cg7LG4WqGMTiE2jnkKwRt). L3 DeepSeek, L4 Tencent, and L8 Eden AI answer 200 on both legs with the same wire and no beta, L12 MiniMax and L5 Sail answer 402 on both legs with the same wire, and L6 Meta and L11 Prism reject the body field with the same message on both legs. L13 Foundry and L14 Anthropic withadditional_drop_params: [safeguards]send neither the field nor a derived beta on either leg and answer 200 on both. L15 Anthropic withadditional_drop_params: [context_management]sends no field on either leg, the base still sends thecontext-managementbeta and the head sends none, 200 on both (headmsg_011Cg7LGVtKekrLgBwcZowQ4)Legacy suites: every other integration file naming
safeguardsor the beta (the 15 files inmessages_endpoint/safeguards/,test_anthropic_wire.py, andtest_bedrock_invoke_dangerous_tool_use_beta_wire.py) ran on the head, 135 passed and 3 skipped at 39fc45d, each skip a pre-existingBUG:markerExclusions, set before the run: L7 Vertex partner (the shared derivation does not reach it, and the X4 cell covers the moved drop step that does), L9 github_copilot live (Copilot has no beta map column, D20 pins its wire as unchanged, and no Copilot account with Claude access exists), live bedrock invoke and mantle (not callers of the shared derivation, D23 and D24 pin them)
Behavior changes the audit observed, each the change LIT-8284 asks for and shipped as the PR's design in its TLDR and alternatives:
safeguardswith no client beta, orsafeguards: [], now answers 200 on anthropic, azure_ai, and the Claude Platform on AWS (D1, D4, D7 to D11, D21, L1, L2, L10); a non-array value still answers 400 with the vendor's array message (S1 to S3);additional_drop_paramsnow applies before the provider headers are built, so a dropped param no longer drives its beta (X1 to X5, L13 to L15)Type
🐛 Bug Fix
Caveats (if any)
Low
/v1/messagesroute foranthropicdoes not derive the beta yet, sosafeguardswith no client beta still gets the base's 400 there. Claude Code sends the beta itself, and fix(rust): add the dangerous-tool-use beta when an anthropic /v1/messages request carries safeguards #46102 fixes the Rust sidesafeguardsis unverified and left unchanged on purpose, as the alternatives explainsafeguardson/v1/chat/completionsand/v1/responsesstill gets Anthropic's 400, as on the merge base. Fixing it needssafeguard_resultsin those response shapes, which a follow-up ticket trackssafeguardsrequest's load runs. The merge base does the same, and a follow-up ticket tracks itFinal Attestation
Bugbot summary