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
refactor: extract summary_disabled logic into shared helper and add missing env var test
Chesars3e9ea6f49bf9
diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.pyindex a0954d765c1..e7effb77cac 100644--- a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py+++ b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py@@ -1,4 +1,3 @@-import osfrom typing import (TYPE_CHECKING,Any,@@ -13,6 +12,9 @@ from typing import ()import litellm+from litellm.llms.anthropic.experimental_pass_through.utils import (+ is_default_reasoning_summary_disabled,+)from litellm.llms.anthropic.experimental_pass_through.adapters.transformation import (AnthropicAdapter,)@@ -78,10 +80,7 @@ class LiteLLMMessagesToCompletionTransformationHandler:# Prefix model with "responses/" to route to OpenAI Responses APIcompletion_kwargs["model"] = f"responses/{model}"- summary_disabled = (- litellm.disable_default_reasoning_summary- or os.getenv("LITELLM_DISABLE_DEFAULT_REASONING_SUMMARY", "false").lower() == "true"- )+ summary_disabled = is_default_reasoning_summary_disabled()reasoning_effort = completion_kwargs.get("reasoning_effort")summary = thinking.get("summary")diff --git a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.pyindex ec855acd237..5b4f2a19f26 100644--- a/litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.py+++ b/litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.py@@ -6,10 +6,12 @@ path used for OpenAI and Azure models."""import json-import osfrom typing import Any, Dict, List, Optional, Union, castimport litellm+from litellm.llms.anthropic.experimental_pass_through.utils import (+ is_default_reasoning_summary_disabled,+)from litellm.types.llms.anthropic import (AllAnthropicToolsValues,@@ -244,10 +246,7 @@ class LiteLLMAnthropicToResponsesAPIAdapter:effort = "low"else:effort = "minimal"- summary_disabled = (- litellm.disable_default_reasoning_summary- or os.getenv("LITELLM_DISABLE_DEFAULT_REASONING_SUMMARY", "false").lower() == "true"- )+ summary_disabled = is_default_reasoning_summary_disabled()result: Dict[str, Any] = {"effort": effort}summary = thinking.get("summary")if summary:diff --git a/litellm/llms/anthropic/experimental_pass_through/utils.py b/litellm/llms/anthropic/experimental_pass_through/utils.pynew file mode 100644index 00000000000..4a40e4629e2--- /dev/null+++ b/litellm/llms/anthropic/experimental_pass_through/utils.py@@ -0,0 +1,12 @@+import os++import litellm+++def is_default_reasoning_summary_disabled() -> bool:+ """Check whether the default 'summary: detailed' injection should be suppressed."""+ return (+ litellm.disable_default_reasoning_summary+ or os.getenv("LITELLM_DISABLE_DEFAULT_REASONING_SUMMARY", "false").lower()+ == "true"+ )diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.pyindex 384c4a97c19..0bc28cc0869 100644--- a/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py+++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py@@ -322,6 +322,31 @@ class TestThinkingSummaryPreservation:finally:litellm.disable_default_reasoning_summary = original+ def test_summary_excluded_when_env_var_set(self):+ """When LITELLM_DISABLE_DEFAULT_REASONING_SUMMARY env var is true, summary is not added."""+ import litellm+ from litellm.llms.anthropic.experimental_pass_through.adapters.handler import (+ LiteLLMMessagesToCompletionTransformationHandler,+ )++ original = litellm.disable_default_reasoning_summary+ try:+ litellm.disable_default_reasoning_summary = False+ os.environ["LITELLM_DISABLE_DEFAULT_REASONING_SUMMARY"] = "true"+ completion_kwargs = {+ "model": "responses/gpt-5.2",+ "custom_llm_provider": "openai",+ "reasoning_effort": "high",+ }+ LiteLLMMessagesToCompletionTransformationHandler._route_openai_thinking_to_responses_api_if_needed(+ completion_kwargs, thinking={"type": "enabled", "budget_tokens": 10000}+ )+ assert completion_kwargs["reasoning_effort"] == {"effort": "high"}+ assert "summary" not in completion_kwargs["reasoning_effort"]+ finally:+ litellm.disable_default_reasoning_summary = original+ os.environ.pop("LITELLM_DISABLE_DEFAULT_REASONING_SUMMARY", None)+def test_user_provided_summary_preserved_even_when_flag_off(self):"""When user already set summary in dict reasoning_effort, it's preserved regardless of flag."""import litellm