From 28d1c8f155b2849e529f077c27509fed8bb1631f Mon Sep 17 00:00:00 2001 From: Vineeth Sai Date: Wed, 28 Oct 2026 12:44:18 -0400 Subject: [PATCH] test(streaming): pin that reasoning_items are concatenated across chunks The reasoning_items fix landed upstream. Its test puts every item in the last chunk, so an aggregation that read only the first or last chunk would still pass. Add one case with an item in each of two chunks and expect both, in order. --- .../test_streaming_chunk_builder_utils.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/unit/litellm_core_utils/test_streaming_chunk_builder_utils.py b/tests/unit/litellm_core_utils/test_streaming_chunk_builder_utils.py index 28587bf4749..419c88f1e7e 100644 --- a/tests/unit/litellm_core_utils/test_streaming_chunk_builder_utils.py +++ b/tests/unit/litellm_core_utils/test_streaming_chunk_builder_utils.py @@ -2661,3 +2661,44 @@ def test_stream_chunk_builder_counts_a_custom_named_deployments_missing_usage_wi model="my-gpt-6", messages=messages ) assert built.usage.prompt_tokens == litellm.token_counter(model=counted_as, messages=messages) + + +def test_stream_chunk_builder_concatenates_reasoning_items_from_every_chunk(): + from litellm.types.utils import Delta, ModelResponseStream, StreamingChoices + + first: Final = {"type": "reasoning", "id": "rs_1", "summary": [], "encrypted_content": "enc_1"} + second: Final = {"type": "reasoning", "id": "rs_2", "summary": [], "encrypted_content": "enc_2"} + chunks: Final = [ + ModelResponseStream( + id="chatcmpl-rs", + created=1, + model="gpt-5.5", + object="chat.completion.chunk", + choices=[ + StreamingChoices( + finish_reason=None, + index=0, + delta=Delta(content="Hello", role="assistant", reasoning_items=[first]), + ) + ], + ), + ModelResponseStream( + id="chatcmpl-rs", + created=1, + model="gpt-5.5", + object="chat.completion.chunk", + choices=[ + StreamingChoices( + finish_reason="stop", + index=0, + delta=Delta(content=" world", role="assistant", reasoning_items=[second]), + ) + ], + ), + ] + + response: Final = stream_chunk_builder(chunks=list(chunks)) + + assert response is not None + assert response.choices[0].message.content == "Hello world" + assert response.choices[0].message.reasoning_items == [first, second]