Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Feat]: Add streaming-aware helper for artifact updates

Đang mở
#833 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

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.

  • #834 của @kevinlu310 — đã đóng, không merge
  • #942 của @mtsmyassin — đang mở

Đá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ả

component: core help wanted
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:

  1. Generates a stable artifact_id once on construction
  2. Provides an append(text) method that returns a TaskArtifactUpdateEvent with append=True, last_chunk=False
  3. 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 TaskArtifactUpdateEvent as: "If true, the content of this artifact should be appended to a previously sent artifact with the same ID.". So the current new_text_artifact usage 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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của a2aproject/a2a-python

Tất cả issue của a2aproject/a2a-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.