[Feat]: Add streaming-aware helper for artifact updates
Maintainer thường phản hồi trong vòng 2 ngày
@kevinlu310 đang làm issue này rồi.
Từ ngày 31/3/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Helper này nên được thêm vào a2a/utils/artifact.py. Trước tiên, hãy xem xét hàm new_text_artifact hiện có và class TaskArtifactUpdateEvent. ArtifactStreamer mới cần tạo một UUID ổn định, quản lý trạng thái và tạo các event với các flag append và last_chunk chính xác. Cập nhật sample travel_planner_agent để sử dụng helper mới như bước cuối cùng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 2.2k
- Fork
- 509
- Merge trung bình
- 3 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 44
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của a2aproject/a2a-python
-
[Bug]: REST task/request id sanitizationCó thể đã có người làm @Linux2010 đã nhận 103 ngày trước. Đang mởmaintainers-only
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
a2aproject/a2a-python#805 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Feat]: Cluster mode: detect and recover tasks abandoned by a crashed replica (heartbeat/lease)Có thể đã có người làm @rohityan đã nhận 2 ngày trước. Đang mở
a2aproject/a2a-python#1324 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug]: Cluster mode: SubscribeToTask on a replica holding a paused ActiveTask returns a stale INPUT_REQUIRED snapshot and closesCó thể đã có người làm @rohityan đã nhận 2 ngày trước. Đang mởcomponent: server
a2aproject/a2a-python#1323 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug]: After a streamed task is cancelled, its background producer never finishesCó thể đã có người làm @rohityan đã nhận 2 ngày trước. Đang mởcomponent: server status:awaiting response
a2aproject/a2a-python#1322 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
v0.3 gRPC and REST SendMessage without configuration run non-blockingCó thể đã có người làm @rohityan đã nhận 3 ngày trước. Đang mởquestion status:awaiting response
a2aproject/a2a-python#1321 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của a2aproject/a2a-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
UKGovernmentBEIS/inspect_ai#5802 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
no-human-ai/no_human#660 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add a Security Insights v2 fileĐang mởdocumentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation need help question
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 66/100
phonology024/babelscribe#26 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100