Python: Bug: streaming chunk merge adds an item to every matching item, duplicating text
Los mantenedores suelen responder en 3 días
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 20/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- backend-api-design
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 28.8k
- Forks
- 4.9k
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 48
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/semantic-kernel
-
Python: Bug: ChatMessageContent.from_element drops AudioContent and BinaryContent into raw TextContentPosiblemente ocupada @halcyon-past la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoft/semantic-kernel#14824 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
Python: Bug: Redis search returns None for every field that declares a storage_name, because RETURN lists the declared namePosiblemente ocupada @wasim-builds la tomó hace 9 días. Abiertopython triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/semantic-kernel#14753 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23Posiblemente ocupada @nightcityblade la tomó hace 46 días. Abierto.NET triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
microsoft/semantic-kernel#14526 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)Posiblemente ocupada @VANDRANKI la tomó hace 48 días. Abiertopython triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
microsoft/semantic-kernel#14522 ·
Los mantenedores suelen responder en 3 días
-
.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URIPosiblemente ocupada @Laurianti la tomó hace 48 días. Abierto.NET triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
microsoft/semantic-kernel#14518 ·
Los mantenedores suelen responder en 3 días
Todos los issues de microsoft/semantic-kernel
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Support Flux ignore rules (drift detection ignore paths) in Microsoft.KubernetesConfiguration schemaAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Azure/azure-resource-manager-schemas#3921 ·
Los mantenedores suelen responder en 1 día
-
text-align: justify is ignored in HTML to PDF conversionPosiblemente ocupada @PrzemyslawKlys la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
asyncapi/modelina#2709 · 1 comentario ·
Los mantenedores suelen responder en 1 día