From 435b103b6977c0797661202442b0e34d4d4d3c51 Mon Sep 17 00:00:00 2001 From: kime541200 Date: Fri, 24 Apr 2026 12:41:29 +0800 Subject: [PATCH] fix(anthropic): drop output_config for Azure Prevent the Anthropic pass-through adapter from forwarding output_config after it has already been translated to reasoning_effort for Azure calls. Add a regression test for azure/gpt-5.2-chat adaptive thinking so the translated reasoning parameter is preserved without leaking the unsupported output_config field. Made-with: Cursor --- .../adapters/handler.py | 2 +- .../test_reasoning_effort_fields.py | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py index d16f5afb45c..c34e08f92b0 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py @@ -225,7 +225,7 @@ class LiteLLMMessagesToCompletionTransformationHandler: "include_usage": True, } - excluded_keys = {"anthropic_messages"} + excluded_keys = {"anthropic_messages", "output_config"} extra_kwargs = extra_kwargs or {} for key, value in extra_kwargs.items(): if ( diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/test_reasoning_effort_fields.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/test_reasoning_effort_fields.py index d42d109f21b..48a6514d363 100644 --- a/tests/test_litellm/llms/anthropic/experimental_pass_through/test_reasoning_effort_fields.py +++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/test_reasoning_effort_fields.py @@ -261,6 +261,30 @@ class TestAdapterAdaptiveThinking: else: assert re == "high" + def test_messages_handler_does_not_forward_output_config_to_azure(self): + """Adaptive thinking should translate output_config for Azure without leaking it.""" + from litellm.llms.anthropic.experimental_pass_through.adapters.handler import ( + LiteLLMMessagesToCompletionTransformationHandler, + ) + + completion_kwargs, _ = ( + LiteLLMMessagesToCompletionTransformationHandler._prepare_completion_kwargs( + max_tokens=1024, + messages=[{"role": "user", "content": "hello"}], + model="azure/gpt-5.2-chat", + thinking={"type": "adaptive"}, + extra_kwargs={ + "api_version": "2025-01-01-preview", + "drop_params": True, + "output_config": {"effort": "high"}, + }, + ) + ) + + assert completion_kwargs["reasoning_effort"] == "high" + assert completion_kwargs["api_version"] == "2025-01-01-preview" + assert "output_config" not in completion_kwargs + def test_responses_adapter_adaptive_with_output_config(self): """Responses adapter: adaptive thinking + output_config.effort.""" from litellm.llms.anthropic.experimental_pass_through.responses_adapters.transformation import (