[Feat]: Add streaming-aware helper for artifact updates
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- backend-api-design
Línea de trabajo
El helper debe añadirse a a2a/utils/artifact.py. Empieza examinando la función new_text_artifact existente y la clase TaskArtifactUpdateEvent. El nuevo ArtifactStreamer debe generar un UUID estable, gestionar el estado y producir eventos con los flags append y last_chunk correctos. Actualiza el ejemplo travel_planner_agent para usar el nuevo helper como paso final.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
When implementing streaming text output via TaskArtifactUpdateEvent, the current new_text_artifact utility generates a fresh UUID for artifact_id on every call. This makes it impossible to use append=True correctly, since append semantics require a stable artifact_id across chunks.
The sample travel_planner_agent demonstrates this problem — it calls new_text_artifact in a loop:
async for event in self.agent.stream(query):
message = TaskArtifactUpdateEvent(
contextId=context.context_id,
taskId=context.task_id,
artifact=new_text_artifact(
name='current_result',
text=event['content'],
),
)
await event_queue.enqueue_event(message)
Each iteration produces a new artifact_id, so clients cannot merge chunks into a single artifact. This results in N separate artifact cards in the UI instead of one progressively streamed response.
Describe the solution you'd like
Add a stateful streaming helper to a2a.utils that:
- Generates a stable artifact_id once on construction
- Provides an append(text) method that returns a
TaskArtifactUpdateEventwithappend=True,last_chunk=False - Provides a finalize() method that returns a TaskArtifactUpdateEvent with append=True, last_chunk=True
Example API:
from a2a.utils import ArtifactStreamer
streamer = ArtifactStreamer(context_id, task_id, name="response")
async for chunk in llm.stream(prompt):
await event_queue.enqueue_event(streamer.append(chunk))
await event_queue.enqueue_event(streamer.finalize())
This would live in a2a/utils/artifact.py alongside the existing new_text_artifact and new_artifact helpers.
Describe alternatives you've considered
No response
Additional context
- The travel_planner_agent sample should also be updated to use this helper once available.
- The A2A spec defines append on
TaskArtifactUpdateEventas: "If true, the content of this artifact should be appended to a previously sent artifact with the same ID.". So the currentnew_text_artifactusage in a streaming loop is a misuse of the spec's intent.
Code of Conduct
- I agree to follow this project's Code of Conduct
- Lenguaje dominante
- Python
- Estrellas
- 2.2k
- Forks
- 496
- Merge medio
- 2 d 6 h
- PR fusionados (30 d)
- 19
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 a2aproject/a2a-python
-
component: server status:awaiting response
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
a2aproject/a2a-python#1237 · 2 comentarios · 1 asignado ·
-
[Bug]: In-memory push store keeps the caller object so later mutations rewrite stored webhooks Abiertocomponent: server status:awaiting response status:stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
a2aproject/a2a-python#1215 · 2 comentarios · 1 asignado ·
-
component: server status:awaiting response status:stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
a2aproject/a2a-python#1205 · 3 comentarios · 1 asignado ·
-
component: server status:awaiting response status:stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
a2aproject/a2a-python#1204 · 2 comentarios · 1 asignado ·
-
component: server
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
a2aproject/a2a-python#1192 · 3 comentarios · 1 asignado ·
Todos los issues de a2aproject/a2a-python
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
huggingface/Repo2RLEnv#163 · 1 comentario ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NousResearch/hermes-agent#121143 ·