diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.py index 3ec29b6387a..4a77a638709 100644 --- a/litellm/completion_extras/litellm_responses_transformation/transformation.py +++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py @@ -745,14 +745,12 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge): last_msg_choice.message.content = "" last_msg_choice.finish_reason = "tool_calls" needs_reasoning_content_backfill = ( - reasoning_content is not None - and getattr(last_msg_choice.message, "reasoning_content", None) is None + reasoning_content is not None and getattr(last_msg_choice.message, "reasoning_content", None) is None ) if needs_reasoning_content_backfill: last_msg_choice.message.reasoning_content = reasoning_content needs_reasoning_items_backfill = ( - pending_reasoning_item is not None - and getattr(last_msg_choice.message, "reasoning_items", None) is None + pending_reasoning_item is not None and getattr(last_msg_choice.message, "reasoning_items", None) is None ) if needs_reasoning_items_backfill: last_msg_choice.message.reasoning_items = cast( diff --git a/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py b/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py index ed6bc06183a..f688c014ff7 100644 --- a/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py +++ b/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py @@ -1,8 +1,7 @@ import json import os -import unittest -from typing import TYPE_CHECKING, Final, List, Literal, Optional, Tuple, get_args -from unittest.mock import ANY, MagicMock, Mock, patch +from typing import TYPE_CHECKING, Final, Literal, get_args +from unittest.mock import MagicMock, Mock, patch import httpx import pytest @@ -1590,20 +1589,6 @@ def test_map_reasoning_effort_adds_summary_detailed(monkeypatch): assert result_dict["effort"] == "high" assert result_dict["summary"] == "custom_summary" - # Test 5: every REASONING_EFFORT level reaches the provider, and anything else (a typo, an - # unshipped level, "default") is dropped so the request still succeeds at the provider default - from litellm.types.llms.openai import Reasoning - - for effort in ("max", "xhigh", "none"): - result_passthrough = handler._map_reasoning_effort(effort) - assert result_passthrough == Reasoning(effort=effort) - for dropped in ("ultra", "hgih", "unknown_value", "", "default"): - assert handler._map_reasoning_effort(dropped) is None - - print( - "✓ All reasoning_effort behaviors work correctly with flag/env var control" - ) - finally: # Restore original values litellm.reasoning_auto_summary = original_flag @@ -4011,8 +3996,8 @@ async def test_acompletion_bridge_normalizes_tool_choice_on_the_wire( def _make_incomplete_responses_api_response( - incomplete_reason: Optional[str], - output: "List[ResponseOutputItem]", + incomplete_reason: str | None, + output: "list[ResponseOutputItem]", status: Literal["completed", "incomplete"] = "incomplete", empty_incomplete_details: bool = False, ) -> "ResponsesAPIResponse":