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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(bedrock): upgrade legacy thinking after the invoke response_format stub model swap
Devin AI0346bb265934
diff --git a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.pyindex 2a4c38e71ea..07ddf6570f2 100644--- a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py+++ b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py@@ -107,6 +107,11 @@ class AmazonAnthropicClaudeConfig(AmazonInvokeConfig, AnthropicConfig):# Restore original model namemodel = original_model+ # The stub model hides the original model from the parent's legacy thinking upgrade+ AnthropicModelInfo.translate_legacy_thinking_for_adaptive_model(+ model=original_model, optional_params=optional_params, custom_llm_provider="bedrock"+ )+# The stub model hides the original model from the parent's forced-tool-use backstopresponse_format_tool_choice: Final = optional_params.get("tool_choice")if (diff --git a/tests/test_litellm/llms/bedrock/chat/invoke_transformations/test_bedrock_chat_invoke_transformations_anthropic_claude3_transformation.py b/tests/test_litellm/llms/bedrock/chat/invoke_transformations/test_bedrock_chat_invoke_transformations_anthropic_claude3_transformation.pyindex 41d82e4f960..d136cb6450b 100644--- a/tests/test_litellm/llms/bedrock/chat/invoke_transformations/test_bedrock_chat_invoke_transformations_anthropic_claude3_transformation.py+++ b/tests/test_litellm/llms/bedrock/chat/invoke_transformations/test_bedrock_chat_invoke_transformations_anthropic_claude3_transformation.py@@ -671,3 +671,22 @@ def test_bedrock_chat_invoke_fable_5_1_response_format_avoids_forced_tool_choiceassert "output_format" not in resultassert "tools" in resultassert "tool_choice" not in result+++def test_bedrock_chat_invoke_response_format_stub_still_upgrades_legacy_thinking(local_model_cost_map):+ """Regression: the tool-based ``response_format`` path swaps in a Claude 3 stub+ model before the shared Anthropic mapping, which hid the adaptive-only model+ from the legacy ``thinking`` upgrade and left ``type=enabled`` on the wire."""+ result = AmazonAnthropicClaudeConfig().map_openai_params(+ non_default_params={+ "response_format": {"type": "json_object"},+ "thinking": {"type": "enabled", "budget_tokens": 4096},+ "max_tokens": 8192,+ },+ optional_params={},+ model="us.anthropic.claude-fable-5-1",+ drop_params=False,+ )++ assert result["thinking"] == {"type": "adaptive"}+ assert result["output_config"] == {"effort": "high"}