diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py index 009415877533..b7742989658d 100644 --- a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py @@ -364,6 +364,8 @@ def _translate_adaptive_effort_for_non_adaptive_model( if capped_thinking is not None: optional_params["thinking"] = capped_thinking + if capped_thinking.get("type") == "enabled" and optional_params.get("temperature") != 1: + optional_params.pop("temperature", None) else: verbose_logger.warning(DROP_UNSUPPORTED_ADAPTIVE_EFFORT_WARNING, model) optional_params.pop("thinking", None) diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_messages_effort.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_messages_effort.py index 06d3effcfbbe..5abe01519663 100644 --- a/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_messages_effort.py +++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_messages_effort.py @@ -45,6 +45,32 @@ def test_effort_translated_to_legacy_thinking_for_haiku_4_5(): assert "output_config" not in result +def test_non_1_temperature_dropped_for_legacy_thinking_on_haiku_4_5(): + result = _transform( + "claude-haiku-4-5", + {**_claude_code_payload(effort="medium"), "temperature": 0}, + ) + + assert result["thinking"] == { + "type": "enabled", + "budget_tokens": DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET, + } + assert "temperature" not in result + + +def test_temperature_1_preserved_for_legacy_thinking_on_haiku_4_5(): + result = _transform( + "claude-haiku-4-5", + {**_claude_code_payload(effort="medium"), "temperature": 1}, + ) + + assert result["thinking"] == { + "type": "enabled", + "budget_tokens": DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET, + } + assert result["temperature"] == 1 + + def test_effort_high_maps_to_high_budget_for_sonnet_4_5(): result = _transform("claude-sonnet-4-5", _claude_code_payload(effort="high")) @@ -63,6 +89,17 @@ def test_adaptive_effort_passes_through_untouched_for_4_6(): assert result["output_config"] == {"effort": "high"} +def test_non_1_temperature_preserved_for_adaptive_thinking_on_4_6(): + result = _transform( + "claude-sonnet-4-6", + {**_claude_code_payload(effort="high"), "temperature": 0}, + ) + + assert result["thinking"] == {"type": "adaptive"} + assert result["output_config"] == {"effort": "high"} + assert result["temperature"] == 0 + + def test_thinking_and_effort_dropped_for_non_reasoning_model(): """A model with no reasoning support cannot take thinking or effort, so both are silently dropped (no drop_params required) so the request still succeeds."""