From 0cf91d0a9c4faeba4e9850cfd13808ccf0b2de9f Mon Sep 17 00:00:00 2001 From: milan Date: Thu, 20 Aug 2026 15:34:38 +0000 Subject: [PATCH] fix(responses bridge): satisfy lint gates for incomplete finish reason mapping Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../transformation.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.py index fa0e607fafd..30412ee840b 100644 --- a/litellm/completion_extras/litellm_responses_transformation/transformation.py +++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py @@ -786,7 +786,9 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge): handle_raw_dict_callback=self._handle_raw_dict_response_item, ) - choices: Final = converted_choices or [_empty_incomplete_choice(raw_response, output_items)] + choices: Final = converted_choices or [ # mutable-ok: ModelResponse.choices expects a mutable list + _empty_incomplete_choice(raw_response, output_items) + ] setattr(model_response, "choices", choices) @@ -1426,11 +1428,12 @@ class OpenAiResponsesToChatCompletionStreamIterator(BaseModelResponseIterator): if isinstance(item, dict) ) - incomplete_details: Final = (response_data.get("incomplete_details") or {}) if response_data else {} + incomplete_details: Final = response_data.get("incomplete_details") if response_data else None + incomplete_reason: Final = ( + incomplete_details.get("reason") if isinstance(incomplete_details, dict) else None + ) terminal_finish_reason: Final = ( - "stop" - if event_type == "response.completed" - else _incomplete_reason_to_finish_reason(incomplete_details.get("reason")) + "stop" if event_type == "response.completed" else _incomplete_reason_to_finish_reason(incomplete_reason) ) finish_reason: Final = "tool_calls" if has_function_calls else terminal_finish_reason