feat(anthropic): add opt-out flag for default reasoning summary#22904
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds a Critical issues found:
Confidence Score: 1/5
|
litellm/llms/anthropic/experimental_pass_through/adapters/handler.py
Outdated
Show resolved
Hide resolved
Add `litellm.disable_default_reasoning_summary` flag (default False) and env var `LITELLM_DISABLE_DEFAULT_REASONING_SUMMARY` to allow users to opt out of the automatic `summary="detailed"` injection when routing Anthropic thinking requests to OpenAI's Responses API. Default behavior is preserved (summary="detailed" is always added), but users who don't want to pay for summary tokens can now disable it. https://claude.ai/code/session_01VJU9EwVvgvmeCe3Yu1aULa
…issing env var test - Extract duplicated summary_disabled evaluation from handler.py and transformation.py into a shared is_default_reasoning_summary_disabled() helper in utils.py to prevent future divergence. - Add test_summary_excluded_when_env_var_set to handler test class to close env-var test coverage gap flagged by Greptile.
0e59ad8 to
3e9ea6f
Compare
c9e60d9
into
BerriAI:litellm_oss_staging_03_05_2026
| guardrail_name_config_map: Dict[str, GuardrailItem] = {} | ||
| include_cost_in_streaming_usage: bool = False | ||
| reasoning_auto_summary: bool = False | ||
| disable_default_reasoning_summary: bool = False |
There was a problem hiding this comment.
Backwards-incompatible default behavior change
Setting disable_default_reasoning_summary to False (the default) means summary: "detailed" is now injected into every request that previously received no summary. Before this PR, translate_thinking_to_reasoning({"type": "enabled", "budget_tokens": 5000}) returned {"effort": "medium"}; after this PR it returns {"effort": "medium", "summary": "detailed"} by default, silently altering all existing callers' API payloads.
Per the repository guidelines on backwards compatibility (rule b48b7341), behavioral changes like this should be opt-in, not opt-out — meaning the old behavior should remain the default and users explicitly set the flag to enable the new behavior. The flag should either:
Option 1: Default to True to preserve old behavior:
| disable_default_reasoning_summary: bool = False | |
| disable_default_reasoning_summary: bool = True |
Option 2: Rename to make the opt-in nature explicit:
enable_default_reasoning_summary: bool = Falseand update the helper in utils.py accordingly.
Context Used: Rule from dashboard - What: avoid backwards-incompatible changes without user-controlled flags
Why: This breaks current ... (source)
Relevant issues
Allows users to disable the automatic
"summary": "detailed"injection when LiteLLM translates Anthropicthinkingparameters to OpenAIreasoning_effort.Pre-Submission checklist
tests/test_litellm/directorymake test-unit@greptileaiType
🆕 New Feature
Changes
litellm.disable_default_reasoning_summaryflag (defaultFalse) inlitellm/__init__.pyLITELLM_DISABLE_DEFAULT_REASONING_SUMMARYenv var as alternativeadapters/handler.pyto skip injecting"summary": "detailed"when flag is active (both string and dictreasoning_effort)responses_adapters/transformation.pyto respect the flag intranslate_thinking_to_reasoning