fix(responses): share GPT-5 effort capability gate

This commit is contained in:
Onat Özmen 2026-08-30 20:28:23 +03:00
parent 7dc5ae4d27
commit 96a9fb6e1a
2 changed files with 11 additions and 10 deletions

View file

@ -156,6 +156,15 @@ class OpenAIGPT5Config(OpenAIGPTConfig):
key=f"supports_{level}_reasoning_effort",
)
@classmethod
def is_reasoning_effort_unsupported(cls, model: str, level: str | None) -> bool:
"""Return whether GPT-5 capability metadata rejects this effort level."""
if level == "xhigh":
return not cls._supports_reasoning_effort_level(model, level)
if level in ("minimal", "low"):
return cls._is_reasoning_effort_level_explicitly_disabled(model, level)
return False
@classmethod
def effort_resolves_to_none(cls, model: str, effective_effort: str | None) -> bool:
"""Whether this request's reasoning effort ends up as "none", which is the single

View file

@ -84,17 +84,9 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
@staticmethod
def _is_unsupported_reasoning_effort(model: str, effort: str | None) -> bool:
"""Apply the GPT-5 reasoning-effort capability flags used by chat completions."""
from litellm.router_utils.reasoning_effort_capability import (
declared_reasoning_efforts_for_model,
)
from litellm.llms.openai.chat.gpt_5_transformation import OpenAIGPT5Config
lookup_model: Final = model.removeprefix("openai/")
declared: Final = declared_reasoning_efforts_for_model(lookup_model, "openai")
if effort == "xhigh":
return declared is None or effort not in declared
if effort in ("minimal", "low"):
return declared is not None and effort not in declared
return False
return OpenAIGPT5Config.is_reasoning_effort_unsupported(model, effort)
@staticmethod
def _enforce_min_max_output_tokens(max_output_tokens: "int | None") -> "int | None":