From 0764a0a923bf1e7e3cd6689929baa03b4f6a50a2 Mon Sep 17 00:00:00 2001 From: onatozmenn Date: Mon, 14 Sep 2026 00:12:15 +0300 Subject: [PATCH] fix(responses): dispatch effort capability check by provider and drop test monkeypatching - Azure responses config reads Azure map entry (OpenAI entry disables minimal on gpt-5.4, Azure enables it); temperature revalidation test now uses real gpt-5.1 map data --- .../llms/azure/responses/transformation.py | 9 +++++ .../test_reasoning_effort_capability.py | 40 +++++++++++++++---- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/litellm/llms/azure/responses/transformation.py b/litellm/llms/azure/responses/transformation.py index 7fe12138ebc..696840b0d17 100644 --- a/litellm/llms/azure/responses/transformation.py +++ b/litellm/llms/azure/responses/transformation.py @@ -38,6 +38,15 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig): def _effort_resolves_to_none(model: str, effort: str | None) -> bool: return AzureOpenAIGPT5Config.effort_resolves_to_none(model, effort) + @staticmethod + def _is_unsupported_reasoning_effort(model: str, effort: str | None) -> bool: + """Read the effort capability from the Azure map entry, like the sibling checks above. + + The inherited OpenAI lookup would resolve a bare Azure deployment name (e.g. ``gpt-5.4``) + against the OpenAI entry, which can explicitly disable an effort Azure supports. + """ + return AzureOpenAIGPT5Config.is_reasoning_effort_unsupported(model, effort) + def get_supported_openai_params(self, model: str) -> list: """ Azure Responses API does not support context_management (compaction). diff --git a/tests/test_litellm/llms/openai/responses/test_reasoning_effort_capability.py b/tests/test_litellm/llms/openai/responses/test_reasoning_effort_capability.py index 2eef324eacd..cdb8f3ee4bc 100644 --- a/tests/test_litellm/llms/openai/responses/test_reasoning_effort_capability.py +++ b/tests/test_litellm/llms/openai/responses/test_reasoning_effort_capability.py @@ -1,7 +1,7 @@ import pytest import litellm -from litellm.llms.openai.chat.gpt_5_transformation import OpenAIGPT5Config +from litellm.llms.azure.responses.transformation import AzureOpenAIResponsesAPIConfig from litellm.llms.openai.responses.transformation import OpenAIResponsesAPIConfig @@ -41,18 +41,44 @@ def test_drop_params_removes_only_unsupported_effort() -> None: assert result["reasoning"] == {"summary": "detailed"} -def test_drop_params_revalidates_temperature_after_effort_drop(monkeypatch: pytest.MonkeyPatch) -> None: - config = OpenAIResponsesAPIConfig() +def test_drop_params_revalidates_temperature_after_effort_drop() -> None: + """Dropping an unsupported effort revalidates temperature against the emptied effort. - monkeypatch.setattr(OpenAIGPT5Config, "_supports_reasoning_effort_level", lambda model, level: False) - monkeypatch.setattr(config, "_supports_reasoning_effort_none", lambda model: True) - monkeypatch.setattr(config, "_effort_resolves_to_none", lambda model, effort: effort is None) + `gpt-5.1` really declares `xhigh` unsupported while supporting (and defaulting to) + `none`, so no capability stubbing is needed: the dropped effort resolves to `none` + and a valid non-default temperature survives. + """ + config = OpenAIResponsesAPIConfig() result = config.map_openai_params( response_api_optional_params={"reasoning": {"effort": "xhigh"}, "temperature": 0.5}, - model="gpt-5-test", + model="gpt-5.1", drop_params=True, ) assert "reasoning" not in result assert result["temperature"] == 0.5 + + +def test_azure_config_uses_azure_capability_map_for_effort() -> None: + """A bare Azure deployment name must resolve against the Azure map entry. + + OpenAI's `gpt-5.4` entry explicitly disables `minimal` while Azure's enables it; + the OpenAI lookup would wrongly reject an effort Azure supports. + """ + openai_config = OpenAIResponsesAPIConfig() + with pytest.raises(litellm.UnsupportedParamsError, match="reasoning.effort=minimal"): + openai_config.map_openai_params( + response_api_optional_params={"reasoning": {"effort": "minimal"}}, + model="gpt-5.4", + drop_params=False, + ) + + azure_config = AzureOpenAIResponsesAPIConfig() + result = azure_config.map_openai_params( + response_api_optional_params={"reasoning": {"effort": "minimal"}}, + model="gpt-5.4", + drop_params=False, + ) + + assert result["reasoning"] == {"effort": "minimal"}