Fix _supports_reasoning_effort_level for responses bridge

This commit is contained in:
Sameer Kankute 2026-03-13 13:29:39 +05:30
parent 92d39c308c
commit a5bec4911f
2 changed files with 34 additions and 7 deletions

View file

@ -1356,6 +1356,13 @@ def completion( # type: ignore # noqa: PLR0915
api_key=api_key,
)
## RESPONSES API BRIDGE LOGIC ## - check early and normalize model name
responses_api_model_info, model = responses_api_bridge_check(
model=model,
custom_llm_provider=custom_llm_provider,
web_search_options=web_search_options,
)
if not _should_allow_input_examples(
custom_llm_provider=custom_llm_provider, model=model
):
@ -1591,14 +1598,8 @@ def completion( # type: ignore # noqa: PLR0915
timeout=timeout,
)
## RESPONSES API BRIDGE LOGIC ## - check if model has 'mode: responses' in litellm.model_cost map
model_info, model = responses_api_bridge_check(
model=model,
custom_llm_provider=custom_llm_provider,
web_search_options=web_search_options,
)
if model_info.get("mode") == "responses":
if responses_api_model_info.get("mode") == "responses":
from litellm.completion_extras import responses_api_bridge
return responses_api_bridge.completion(

View file

@ -1454,3 +1454,29 @@ def test_gpt_5_web_search():
for chunk in response:
print("chunk: ", chunk)
def test_responses_gpt54_with_xhigh_reasoning():
"""
Ensure chat->responses bridge sends the correct request payload for
openai/responses/gpt-5.4 with reasoning_effort="xhigh".
"""
with patch("litellm.responses") as mock_responses:
# Stop execution right after request generation to avoid external API calls.
mock_responses.side_effect = RuntimeError("stop_after_request_build")
with pytest.raises(Exception):
litellm.completion(
model="openai/responses/gpt-5.4",
messages=[{"role": "user", "content": "What is 2+2?"}],
reasoning_effort="xhigh",
max_tokens=100,
)
mock_responses.assert_called_once()
request_body = mock_responses.call_args.kwargs
# The responses prefix should be stripped before routing.
assert request_body["model"] == "gpt-5.4"
# chat-completions reasoning_effort must map to Responses API reasoning.
assert request_body["reasoning"] == {"effort": "xhigh"}