Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions litellm/router_utils/reasoning_effort_capability.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,25 @@ def resolve_supported_reasoning_efforts(
unset flag as () would let one custom deployment empty every level its mapped siblings agree
on. deployment_is_mapped is that provenance, and an operator who wants either answer for an
off-map deployment gets it by setting supports_reasoning explicitly.

If supports_reasoning is unset but at least one per-level flag (e.g.
supports_minimal_reasoning_effort) is present, treat it as implicitly True, since the
per-level flags are evidence the model supports reasoning. An explicit False always wins:
it is the operator's escape hatch and must not be overridden by inherited per-level flags.
"""
supports_reasoning: Final = model_info.get("supports_reasoning")
if supports_reasoning is not True:
return () if supports_reasoning is False or deployment_is_mapped else None
if supports_reasoning is False:
return ()
Comment thread
greptile-apps[bot] marked this conversation as resolved.

flags: Final = _declared_effort_flags(model_info)
has_per_level_flag: Final = any(value is not None for value in flags.values())
if supports_reasoning is not True and not has_per_level_flag:
return () if deployment_is_mapped else None

declared: Final = declared_reasoning_efforts(model_info)
if declared is not None:
return declared

flags: Final = _declared_effort_flags(model_info)
if all(value is None for value in flags.values()):
return None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ def test_opt_in_flag_set_false_stays_excluded(self):
)
assert resolved == ("none", "minimal", "low", "medium", "high")

def test_per_level_flag_without_supports_reasoning_treats_as_implicit_true(self):
resolved = resolve_supported_reasoning_efforts(
{
"supports_minimal_reasoning_effort": True,
},
deployment_is_mapped=True,
)
assert resolved == ("none", "minimal", "low", "medium", "high")

def test_explicit_supports_reasoning_false_wins_over_per_level_flags(self):
resolved = resolve_supported_reasoning_efforts(
{
"supports_reasoning": False,
"supports_minimal_reasoning_effort": True,
},
deployment_is_mapped=True,
)
assert resolved == ()


class TestBareModelNameFallback:
def test_a_prefixed_entry_inherits_the_flags_of_its_unprefixed_twin(self):
Expand Down
Loading