From 3ff4ac3de3fc2fb013ed2ecbe4b5b82304d43fe1 Mon Sep 17 00:00:00 2001 From: Xianzong Xie Date: Tue, 17 Mar 2026 11:21:26 -0700 Subject: [PATCH] Capture incomplete terminal error in background streaming Committed-By-Agent: codex Co-authored-by: codex --- litellm/proxy/response_polling/background_streaming.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/response_polling/background_streaming.py b/litellm/proxy/response_polling/background_streaming.py index 5ec0aac8e2..17ee101549 100644 --- a/litellm/proxy/response_polling/background_streaming.py +++ b/litellm/proxy/response_polling/background_streaming.py @@ -258,8 +258,8 @@ async def background_streaming_task( # noqa: PLR0915 ), ) - # Extract error for failed responses - if event_type == "response.failed": + # Extract error for failed and incomplete responses + if event_type == "response.failed" or event_type == "response.incomplete": terminal_error = response_data.get("error") # Core response fields @@ -337,7 +337,7 @@ async def background_streaming_task( # noqa: PLR0915 ) verbose_proxy_logger.info( - f"Finished background streaming for {polling_id}, status={final_status}, output_items={len(output_items)}" + f"Finished background streaming for {polling_id}, status={final_status}, error={terminal_error}, output_items={len(output_items)}" ) except Exception as e: