Repository navigation
fix(python): avoid duplicating chunks into multiple matching items in StreamingContentMixin (#14786) - #14844
Open
Parchuri Poojith Kumar (poojithparchuri-iiitk) wants to merge 1 commit into
Conversation
Parchuri Poojith Kumar (poojithparchuri-iiitk)
requested a review
from a team
as a code owner
November 20, 2026 20:29
Parchuri Poojith Kumar (poojithparchuri-iiitk)
deployed
to
github-app-auth
November 20, 2026 20:29 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change preventing duplicate streaming-chunk merges.
No open issues 🎉
What changed in this PR
Fixes #14786 by preventing an incoming streaming chunk from being merged into multiple compatible items, avoiding duplicated text or tool-call arguments.
Changes:
- Stops the inner merge loop after the first successful merge.
- Adds a regression test confirming that only the first matching text item receives the incoming chunk.
| File | Description |
|---|---|
python/tests/unit/contents/test_streaming_chat_message_content.py |
Adds regression coverage for merging into only the first matching item. |
python/semantic_kernel/contents/streaming_content_mixin.py |
Adds a break after a successful merge to prevent duplication. |
Review effort: Balanced
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #14786
When merging streaming chunks in
StreamingContentMixin._merge_items_lists, the inner loop that iterates throughnew_items_listwas settingadded = Trueafter a successfulitem + other_itemmerge, but didn'tbreakout of the loop.As a result, if the message contained multiple items of the same type (for example, multiple text parts or parallel tool call chunks), the incoming chunk was getting added to every compatible item in the list instead of stopping after merging into the first match, causing duplicated text and parameters.
Changes
python/semantic_kernel/contents/streaming_content_mixin.py:breakimmediately afteradded = Trueso once an incoming chunk is merged into its corresponding item, the inner loop terminates.python/tests/unit/contents/test_streaming_chat_message_content.py:test_scmc_merge_does_not_duplicate_to_multiple_matching_itemsverifying that an incoming chunk merges only into the first matching item when multiple items of the same type exist.Testing
test_streaming_chat_message_content.pylocally — all 44 tests passed in under 1 second.