From da4f5cd9edc613b75dfb371348cd8f586eef119a Mon Sep 17 00:00:00 2001 From: ec-jt Date: Mon, 2 Mar 2026 14:20:38 +0000 Subject: [PATCH] fix: add reasoning field check to is_chunk_non_empty for streaming This fixes the issue where streaming responses from vLLM/SGLang backends were missing reasoning_content. The backend sends 'reasoning' field but LiteLLM's is_chunk_non_empty() was only checking for 'reasoning_content', causing chunks with only reasoning content to be filtered out. Fixes: BerriAI/litellm#20246 --- litellm/litellm_core_utils/streaming_handler.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index 6e991e6911b..51d7b9f10d3 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -794,6 +794,11 @@ class CustomStreamWrapper: "reasoning_content" in model_response.choices[0].delta and model_response.choices[0].delta.reasoning_content is not None ) + or ( + "reasoning" in completion_obj + and completion_obj["reasoning"] is not None + and len(str(completion_obj["reasoning"])) > 0 + ) or (model_response.choices[0].delta.provider_specific_fields is not None) or ( "provider_specific_fields" in model_response