Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(anthropic): map the dangerous-tool-use beta for Bedrock Mantle so safeguards never reach it without the beta

mateo-berri61fcfd986d7d
diff --git a/litellm/anthropic_beta_headers_config.json b/litellm/anthropic_beta_headers_config.json
index 2e82b2a759f..917bfbd5ae9 100644
--- a/litellm/anthropic_beta_headers_config.json
+++ b/litellm/anthropic_beta_headers_config.json
@@ -147,6 +147,7 @@
"computer-use-2025-11-24": "computer-use-2025-11-24",
"context-1m-2025-08-07": "context-1m-2025-08-07",
"context-management-2025-06-27": "context-management-2025-06-27",
+ "dangerous-tool-use-2026-09-03": "dangerous-tool-use-2026-09-03",
"effort-2025-11-24": "effort-2025-11-24",
"fast-mode-2026-02-01": null,
"files-api-2025-04-14": null,
diff --git a/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_messages_transformation.py b/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_messages_transformation.py
index 6bacf8f3d94..5f69b36c87a 100644
--- a/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_messages_transformation.py
+++ b/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_messages_transformation.py
@@ -439,6 +439,19 @@ class TestBetaHeadersOnTheWire:
assert _sent_betas(route) == ["context-1m-2025-08-07", "context-management-2025-06-27"]
assert _sent_body(route)["context_management"] == {"edits": [{"type": "clear_tool_uses_20250919"}]}
+ @pytest.mark.asyncio
+ @respx.mock
+ async def test_safeguards_reach_mantle_with_the_dangerous_tool_use_beta(self):
+ """Mantle answers 400 "safeguards: Extra inputs are not permitted" when the field
+ arrives without dangerous-tool-use-2026-09-03 (probed 2026-09-21), so the beta
+ has to ride along even when the client never sent the header."""
+ safeguards = [{"type": "dangerous_tool_use", "classifier_context": {"v": 1, "permission_mode": "auto"}}]
+
+ route = await self._send(safeguards=safeguards)
+
+ assert _sent_betas(route) == ["dangerous-tool-use-2026-09-03"]
+ assert _sent_body(route)["safeguards"] == safeguards
+
@pytest.mark.asyncio
@respx.mock
async def test_betas_and_version_never_travel_in_the_body(self):
diff --git a/tests/test_litellm/test_anthropic_beta_headers_filtering.py b/tests/test_litellm/test_anthropic_beta_headers_filtering.py
index cbdde79a66a..19b26120672 100644
--- a/tests/test_litellm/test_anthropic_beta_headers_filtering.py
+++ b/tests/test_litellm/test_anthropic_beta_headers_filtering.py
@@ -443,13 +443,13 @@ class TestAnthropicBetaHeadersFiltering:
assert filtered == ["thinking-binding-controls-2026-08-01"]
- @pytest.mark.parametrize("provider", ["anthropic", "bedrock", "vertex_ai"])
+ @pytest.mark.parametrize("provider", ["anthropic", "bedrock", "bedrock_mantle", "vertex_ai"])
def test_dangerous_tool_use_forwarded(self, provider):
"""Claude Code's server-side auto-mode classifier sends `safeguards` together with
- dangerous-tool-use-2026-09-03. Bedrock Invoke and Vertex rawPredict both answer
- "safeguards: Extra inputs are not permitted" when the body field arrives without
- the beta (probed 2026-09-21), so dropping the header turned every auto-mode turn
- into a 400 on Vertex and silently disabled the classifier on Bedrock."""
+ dangerous-tool-use-2026-09-03. Bedrock Invoke, Bedrock Mantle, and Vertex rawPredict
+ all answer "safeguards: Extra inputs are not permitted" when the body field arrives
+ without the beta (probed 2026-09-21), so dropping the header turned every auto-mode
+ turn into a 400 on Vertex and silently disabled the classifier on Bedrock."""
filtered = filter_and_transform_beta_headers(
beta_headers=["dangerous-tool-use-2026-09-03"],
provider=provider,