Python: Bug: streaming chunk merge adds an item to every matching item, duplicating text
メンテナーはふだん 3 日以内に返信
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 20/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
The issue identifies semantic_kernel/contents/streaming_content_mixin.py and the regression test file tests/unit/contents/test_streaming_chat_message_content.py. Read _merge_items_lists and reproduce the example in the issue; done means the incoming item is merged into only one compatible item and the regression test passes. A linked pull request is already open.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When two streaming chunks are added, StreamingContentMixin._merge_items_lists merges each incoming item into every compatible item in the list, not just the first one. The inner loop sets added = True after a successful item + other_item, but it doesn't break, so it keeps going and adds the same incoming item to every later item of the same type that accepts it.
This happens whenever a merged message holds two items of the same type that can both take the next chunk. One case is two StreamingTextContent items with the same choice_index, which the Google AI connector builds when a candidate has more than one text part (google_ai_chat_completion.py#L366-L376). Another is two FunctionCallContent items whose id/index don't tell them apart. Then the next chunk's text or arguments are copied into both.
To Reproduce
semantic-kernel 1.47.0. The file is the same on main (25bd1bb6).
from semantic_kernel.contents import AuthorRole, StreamingChatMessageContent, StreamingTextContent
c1 = StreamingChatMessageContent(role=AuthorRole.ASSISTANT, choice_index=0, items=[
StreamingTextContent(choice_index=0, text="Part one. "),
StreamingTextContent(choice_index=0, text="Part two. "),
])
c2 = StreamingChatMessageContent(role=AuthorRole.ASSISTANT, choice_index=0, items=[
StreamingTextContent(choice_index=0, text="tail"),
])
print([i.text for i in (c1 + c2).items])
Output:
['Part one. tail', 'Part two. tail']
Expected behavior
The incoming item is merged into one item only, so the text isn't duplicated: ['Part one. tail', 'Part two. '].
Platform
- Language: Python
- Source: semantic-kernel 1.47.0 (pip) /
mainat 25bd1bb6 - AI model: n/a (no model call needed)
- IDE: n/a
- OS: Windows 11, Python 3.12
Additional context
The fix is a break after added = True. I have it with a regression test in tests/unit/contents/test_streaming_chat_message_content.py and will open a PR.
- 主要言語
- C#
- スター
- 28.8k
- フォーク
- 4.9k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 48
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/semantic-kernel のほかの issue
-
Python: Bug: ChatMessageContent.from_element drops AudioContent and BinaryContent into raw TextContent対応中かも @halcyon-past が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
microsoft/semantic-kernel#14824 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Python: Bug: Redis search returns None for every field that declares a storage_name, because RETURN lists the declared name対応中かも @wasim-builds が 9 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/semantic-kernel#14753 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23対応中かも @nightcityblade が 46 日前に担当しました。 オープン.NET triage
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
microsoft/semantic-kernel#14526 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)対応中かも @VANDRANKI が 48 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/semantic-kernel#14522 ·
メンテナーはふだん 3 日以内に返信
-
.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URI対応中かも @Laurianti が 48 日前に担当しました。 オープン.NET triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/semantic-kernel#14518 ·
メンテナーはふだん 3 日以内に返信
microsoft/semantic-kernel の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
Support Flux ignore rules (drift detection ignore paths) in Microsoft.KubernetesConfiguration schemaオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Azure/azure-resource-manager-schemas#3921 ·
メンテナーはふだん 1 日以内に返信
-
text-align: justify is ignored in HTML to PDF conversion対応中かも @PrzemyslawKlys が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
asyncapi/modelina#2709 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信