From 6a9f9642be5507380587d9861dfbc4a623acb401 Mon Sep 17 00:00:00 2001 From: AxelRay <110029405+axelray-dev@users.noreply.github.com> Date: Sun, 13 Sep 2026 05:00:17 +0800 Subject: [PATCH] fix(messages): preserve adaptive passthrough parameters --- .../llms/openai_like/messages/transformation.py | 6 ++++++ ...ai_like_anthropic_messages_transformation.py | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/litellm/llms/openai_like/messages/transformation.py b/litellm/llms/openai_like/messages/transformation.py index ac99617521c..b03aa62cb1f 100644 --- a/litellm/llms/openai_like/messages/transformation.py +++ b/litellm/llms/openai_like/messages/transformation.py @@ -65,6 +65,12 @@ class OpenAILikeAnthropicMessagesConfig(AnthropicMessagesConfig): def supports_cache_control_ttl(self) -> bool: return self._cache_control_ttl + @staticmethod + def _translate_adaptive_effort_for_non_adaptive_model( + model: str, optional_params: dict, max_tokens: int | None, custom_llm_provider: str + ) -> None: + """Keep native Anthropic adaptive fields intact for opted-in deployments.""" + def transform_anthropic_messages_request( self, model: str, diff --git a/tests/test_litellm/llms/openai_like/messages/test_openai_like_anthropic_messages_transformation.py b/tests/test_litellm/llms/openai_like/messages/test_openai_like_anthropic_messages_transformation.py index 67a56fdcd79..643033735ea 100644 --- a/tests/test_litellm/llms/openai_like/messages/test_openai_like_anthropic_messages_transformation.py +++ b/tests/test_litellm/llms/openai_like/messages/test_openai_like_anthropic_messages_transformation.py @@ -94,6 +94,23 @@ def test_request_stays_in_anthropic_shape(config): assert openai_only_keys.isdisjoint(payload.keys()) +def test_request_preserves_adaptive_thinking_and_effort(config): + payload = config.transform_anthropic_messages_request( + model="my-model", + messages=[{"role": "user", "content": "hi"}], + anthropic_messages_optional_request_params={ + "max_tokens": 256, + "thinking": {"type": "adaptive"}, + "output_config": {"effort": "high"}, + }, + litellm_params=GenericLiteLLMParams(), + headers={}, + ) + + assert payload["thinking"] == {"type": "adaptive"} + assert payload["output_config"] == {"effort": "high"} + + def test_request_requires_max_tokens(config): with pytest.raises(AnthropicError, match="max_tokens is required"): config.transform_anthropic_messages_request(