litellm - 💡(How to fix) Fix [Bug]: Anthropic silently ignores dict-valued reasoning_effort from openai-agents LitellmModel [2 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#24599Fetched 2026-04-08 01:32:28
View on GitHub
Comments
2
Participants
1
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
labeled ×3commented ×2closed ×1cross-referenced ×1

Error Message

thinking.budget_tokens is not set, and there is no error or warning.

  • Raise a clear validation error stating that dict-valued reasoning_effort is not supported for Anthropic.

Root Cause

This happens in the openai-agents + LiteLLM path, because openai-agents' LitellmModel sends a dict-valued reasoning_effort when reasoning.summary is set.

Code Example

from litellm.llms.anthropic.chat.transformation import AnthropicConfig

cfg = AnthropicConfig()

print(
    cfg.map_openai_params(
        non_default_params={"reasoning_effort": {"effort": "low", "summary": "auto"}},
        optional_params={},
        model="anthropic/claude-sonnet-4-20250514",
        drop_params=False,
    )
)

print(
    cfg.map_openai_params(
        non_default_params={"reasoning_effort": "low"},
        optional_params={},
        model="anthropic/claude-sonnet-4-20250514",
        drop_params=False,
    )
)

---

from openai.types.shared import Reasoning
from agents.model_settings import ModelSettings
from agents.extensions.models.litellm_model import LitellmModel

settings = ModelSettings(reasoning=Reasoning(effort="low", summary="auto"))
model = LitellmModel("anthropic/claude-sonnet-4-20250514")
# LitellmModel builds reasoning_effort={"effort": "low", "summary": "auto"}
# AnthropicConfig then ignores it because it only handles string values.

---

dict input:
{}

string input:
{'thinking': {'type': 'enabled', 'budget_tokens': 1024}, 'max_tokens': 5120}

Relevant code path:

- openai-agents' LitellmModel builds a dict-valued reasoning_effort when summary is present
- LiteLLM's Anthropic mapping only handles reasoning_effort when isinstance(value, str)
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

When reasoning_effort reaches LiteLLM as a dict like {"effort": "low", "summary": "auto"}, Anthropic handling drops it silently. thinking.budget_tokens is not set, and there is no error or warning.

This happens in the openai-agents + LiteLLM path, because openai-agents' LitellmModel sends a dict-valued reasoning_effort when reasoning.summary is set.

Also, tell us what you expected to happen.

LiteLLM should not silently ignore the value.

Expected behavior:

  • For Anthropic models, extract effort from the dict and map it to thinking.budget_tokens, ignoring the unsupported summary, or
  • Raise a clear validation error stating that dict-valued reasoning_effort is not supported for Anthropic.

Steps to Reproduce

Steps to reproduce

  1. Install litellm and openai-agents.
  2. Run this local reproduction against LiteLLM’s Anthropic param mapping:
from litellm.llms.anthropic.chat.transformation import AnthropicConfig

cfg = AnthropicConfig()

print(
    cfg.map_openai_params(
        non_default_params={"reasoning_effort": {"effort": "low", "summary": "auto"}},
        optional_params={},
        model="anthropic/claude-sonnet-4-20250514",
        drop_params=False,
    )
)

print(
    cfg.map_openai_params(
        non_default_params={"reasoning_effort": "low"},
        optional_params={},
        model="anthropic/claude-sonnet-4-20250514",
        drop_params=False,
    )
)
  1. Observe the output:
  • Dict input returns {}
  • String input returns {'thinking': {'type': 'enabled', 'budget_tokens': 1024}, 'max_tokens': 5120}

Optional interop repro with openai-agents:

from openai.types.shared import Reasoning
from agents.model_settings import ModelSettings
from agents.extensions.models.litellm_model import LitellmModel

settings = ModelSettings(reasoning=Reasoning(effort="low", summary="auto"))
model = LitellmModel("anthropic/claude-sonnet-4-20250514")
# LitellmModel builds reasoning_effort={"effort": "low", "summary": "auto"}
# AnthropicConfig then ignores it because it only handles string values.

Relevant log output

dict input:
{}

string input:
{'thinking': {'type': 'enabled', 'budget_tokens': 1024}, 'max_tokens': 5120}

Relevant code path:

- openai-agents' LitellmModel builds a dict-valued reasoning_effort when summary is present
- LiteLLM's Anthropic mapping only handles reasoning_effort when isinstance(value, str)

What part of LiteLLM is this about?

SDK (litellm Python package)

What LiteLLM version are you on ?

v1.77.1

Twitter / LinkedIn details

x.com/nicko_ai, linkedin.com/in/nickbobrowski/

extent analysis

Fix Plan

To fix the issue, we need to modify the AnthropicConfig class in LiteLLM to handle dict-valued reasoning_effort parameters. We can add a check to extract the effort from the dict and map it to thinking.budget_tokens.

Step-by-Step Solution

  1. Update AnthropicConfig class: Modify the map_openai_params method to handle dict-valued reasoning_effort.
  2. Add dict handling: Check if reasoning_effort is a dict and extract the effort value.
  3. Map effort to budget_tokens: Update the thinking config with the extracted effort value.

Example Code

from litellm.llms.anthropic.chat.transformation import AnthropicConfig

class AnthropicConfig:
    # ...

    def map_openai_params(self, non_default_params, optional_params, model, drop_params=False):
        # ...
        if "reasoning_effort" in non_default_params:
            effort = non_default_params["reasoning_effort"]
            if isinstance(effort, dict):
                # Extract effort from dict and map to budget_tokens
                if "effort" in effort:
                    thinking_config = {"type": "enabled", "budget_tokens": self.effort_to_budget_tokens(effort["effort"])}
                    params["thinking"] = thinking_config
                else:
                    # Raise validation error if effort is not present in dict
                    raise ValueError("Invalid reasoning_effort dict: missing 'effort' key")
            elif isinstance(effort, str):
                # Handle string-valued reasoning_effort as before
                thinking_config = {"type": "enabled", "budget_tokens": self.effort_to_budget_tokens(effort)}
                params["thinking"] = thinking_config
            else:
                # Raise validation error for unsupported types
                raise ValueError("Invalid reasoning_effort type: expected str or dict")
        # ...

    def effort_to_budget_tokens(self, effort):
        # Implement effort to budget_tokens mapping
        # For example:
        effort_map = {"low": 1024, "medium": 2048, "high": 4096}
        return effort_map.get(effort, 1024)  # Default to 1024 if effort is not mapped

Verification

To verify the fix, run the reproduction code with the updated AnthropicConfig class:

cfg = AnthropicConfig()

print(
    cfg.map_openai_params(
        non_default_params={"reasoning_effort": {"effort": "low", "summary": "auto"}},
        optional_params={},
        model="anthropic/claude-sonnet-4-20250514",
        drop_params=False,
    )
)

print(
    cfg.map_openai_params(
        non_default_params={"reasoning_effort": "

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix [Bug]: Anthropic silently ignores dict-valued reasoning_effort from openai-agents LitellmModel [2 comments, 1 participants]