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
This commit is contained in:
ec-jt 2026-03-02 14:20:38 +00:00
parent b4a5e51668
commit da4f5cd9ed

View file

@ -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