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]

test(bedrock-converse): cover adaptive-thinking drop when max_tokens too small

Abhimanyu Kapura5b0f32a84be
diff --git a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py
index fe06933e249..fc12ead36a1 100644
--- a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py
+++ b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py
@@ -5816,3 +5816,24 @@ def test_adaptive_thinking_passes_through_on_46_plus_converse(model):
)
assert optional_params.get("thinking") == {"type": "adaptive"}
+
+
+def test_adaptive_thinking_dropped_when_max_tokens_too_small_converse():
+ """When max_tokens can't fit even the minimum thinking budget, the raw
+ adaptive block must be dropped entirely rather than translated, so the
+ Bedrock Converse request still succeeds."""
+ from litellm.constants import ANTHROPIC_MIN_THINKING_BUDGET_TOKENS
+
+ config = AmazonConverseConfig()
+
+ optional_params = config.map_openai_params(
+ non_default_params={
+ "thinking": {"type": "adaptive"},
+ "max_tokens": ANTHROPIC_MIN_THINKING_BUDGET_TOKENS,
+ },
+ optional_params={},
+ model="bedrock/converse/us.anthropic.claude-sonnet-4-5",
+ drop_params=False,
+ )
+
+ assert "thinking" not in optional_params