Skip to content

Commit cb95e26

Browse files
committed
fix(logging): exclude per-chunk results from assembled stream check
_is_assembled_stream_success is documented as detecting the final assembled stream export, but the previous logic returned True for any streaming call with a non-None result, including per-chunk ModelResponseStream values. This created a fragile contract where a future caller passing a chunk to dispatch_success_handlers would prematurely set the has_dispatched_final_stream_success dedup guard and silently suppress the real final stream log. Tighten the check to treat only non-ModelResponseStream results as assembled responses.
1 parent f770d8e commit cb95e26

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

litellm/litellm_core_utils/litellm_logging.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,10 +1624,17 @@ def _is_sync_litellm_request(litellm_params: dict) -> bool:
16241624
)
16251625

16261626
def _is_assembled_stream_success(self, result=None) -> bool:
1627-
"""Final assembled stream export (not a per-chunk success call)."""
1627+
"""Final assembled stream export (not a per-chunk success call).
1628+
1629+
Per-chunk callers pass a ``ModelResponseStream`` (or ``None``); the
1630+
final assembled response is any other non-``None`` value (typically a
1631+
``ModelResponse``). Treating a chunk as the assembled response would
1632+
prematurely set the ``has_dispatched_final_stream_success`` dedup
1633+
guard and silently suppress the real final stream log.
1634+
"""
16281635
if self.stream is not True:
16291636
return False
1630-
if result is not None:
1637+
if result is not None and not isinstance(result, ModelResponseStream):
16311638
return True
16321639
return (
16331640
"async_complete_streaming_response" in self.model_call_details

0 commit comments

Comments
 (0)