Assemble a complete Artifact from A2A streaming events
Merge artifactUpdate events by artifactId, append and lastChunk, then reconcile with the task's final state.
Prerequisites and input · Engineering checks · 1. Freeze the event log and task scope
At a glance
In an A2A streaming response, a task's output can arrive as several TaskArtifactUpdateEvent objects, and the client has to decide how to merge them into one Artifact. This note follows the A2A specification snapshot read on 2026-11-12 and lays out a manual checking procedure that processes an event sequence by artifactId, append and lastChunk. The specification defines the field meanings and event ordering but does not give a full merge algorithm, so wherever it is silent the procedure asks you to write down your own local policy.
Runtime and applicability
- Article type
- Engineering practice
- Verified
- Applies to
- A2A Assemble a complete Artifact from A2A streaming events
Execution locations and responsibilities
- A2A client and remote agent Use the workflow below to distinguish responsibilities of the caller, runtime, and external actions.
Arrows show the order of checks in the guide. Follow each step’s prerequisites, branches and stop conditions; unexecuted steps are not completed work.
When to use
- Check task ownership first. StreamResponse contains exactly one of task, message, statusUpdate or artifactUpdate. The artifacts in a task snapshot can provide the existing-content baseline, followed by ordered TaskArtifactUpdateEvent updates; an update requires taskId, contextId and artifact. Do not use Message as task output or merge status events into Artifact parts.
When not to use
- The specification does not define merge semantics when
appendis missing or false for an existing ID; this note only asks you to record a policy and does not fill that gap. - Events you missed during a disconnect are not guaranteed to be replayed; use
GetTaskorSubscribeToTaskto regain state instead of inferring missing chunks from the local buffer. - A
urlPart is only a reference to content; this procedure does not download or validate what the address points to.
Prerequisites and input
- The remote Agent Card shows
capabilities.streamingas true; otherwiseSendStreamingMessageandSubscribeToTaskreturnUnsupportedOperationError. - You hold a saved
StreamResponseevent log in arrival order, taken from any one of the JSONRPC, GRPC or HTTP+JSON bindings. - You know the
taskIdand can callGetTaskafter the stream ends to compare against the task snapshot.
Engineering checks
Layer 1: event ownership — Check task ownership first. StreamResponse contains exactly one of task, message, statusUpdate or artifactUpdate. The artifacts in a task snapshot can provide the existing-content baseline, followed by ordered TaskArtifactUpdateEvent updates; an update requires taskId, contextId and artifact. Do not use Message as task output or merge status events into Artifact parts.
Layer 2: concatenation by ID — artifactId is unique within a task and serves as the merge key. append set to true means the content should be appended to a previously sent Artifact with the same ID, and lastChunk set to true marks the final chunk. Events must be delivered in generation order without reordering, so processing in arrival order is enough and no extra sorting is needed. The specification does not say whether a missing or false append on an existing ID means replace or error, so record that as a local policy.
Layer 3: reconcile with task state — A fully assembled Artifact does not mean the task is finished. A lifecycle stream closes when the task reaches a terminal state: TASK_STATE_COMPLETED, TASK_STATE_FAILED, TASK_STATE_CANCELED or TASK_STATE_REJECTED. A client that disconnects and reconnects may miss events, so the artifacts returned by GetTask should be the reference for the final comparison.
1. Freeze the event log and task scope
Where: the A2A client. Input: arrival-ordered events, target taskId and any existing Task snapshot. Check the single top-level member. For a task event validate Task.id, then establish or synchronize per-artifactId content baselines from its artifacts; do the same for the initial current Task after resubscription. For artifactUpdate validate required taskId, contextId and artifact and the target task; quarantine other tasks. Completion: record baseline provenance and update order without merging Message or status events into content. Stop an invalid event. If only deltas exist with no established baseline, mark that Artifact incomplete pending GetTask instead of assuming completeness.
2. Group by artifactId
Where: a local client buffer. Input: the artifactUpdate events kept in the previous step. Action: group by artifact.artifactId, keeping arrival order inside each group. The specification's streaming sample shows an Artifact without artifactId, while the Artifact object defines it as required; treat a missing value as a protocol violation and do not invent an ID. Completion check: every event is in a group or in the anomaly list with a reason. Stop condition: if most events lack artifactId, stop assembling and go back to check the remote agent's implementation.
3. Apply the append rule per group
Where: the local client buffer. Input: the ordered events of each group. Action: for an event with append true, add its parts after the snapshot or opening-chunk content already held for that ID; otherwise follow the local policy you recorded, for example treating it as the opening chunk. Each Artifact must keep at least one Part, and each Part stays as received, as one of text, raw, url or data, without conversion while merging. Completion check: each group yields an ordered Part list and the policy note states how a missing append is handled. Stop condition: if append is true but no established snapshot baseline or earlier chunk exists, mark the group incomplete and stop processing it.
4. Close groups with lastChunk
Where: the local Artifact table. Input: same-ID updates and lastChunk. lastChunk=true records event sealing. When absent record sealing unobserved, without inferring permanent incompleteness because the field is optional. A completed GetTask snapshot with reconciled content can independently confirm completeness. Completion: event sealing and snapshot verification are separate fields. Stop conflicting order/content as incomplete; a missing lastChunk alone proceeds to snapshot reconciliation instead of blocking valid success.
5. Reconcile with the final state and snapshot
Where: a GetTask call from the client to the remote agent. Input: the taskId. Action: read status.state, then compare the snapshot's artifacts with your local result one artifactId at a time. If the task is still non-terminal you can resubscribe with SubscribeToTask, whose first event is the current Task; subscribing to a terminal task returns UnsupportedOperationError. Completion check: the ID sets, parts content and order match, other delivery-relevant Artifact fields are reconciled, and the state is terminal; matching IDs with differing content remain incomplete. Stop condition: if the state is TASK_STATE_FAILED, TASK_STATE_CANCELED or TASK_STATE_REJECTED, do not treat the assembled content as a successful result.
6. Record the hand-off and stop reasons
Where: delivery. Input: the local table and GetTask reconciliation. Deliver under local policy when an Artifact is event-sealed or its complete content is confirmed by a successful GetTask snapshot, recording which evidence path applies. Matching completed snapshot content does not wait forever for an optional absent lastChunk. Failed/canceled/rejected tasks do not become successful results, and missing or differing content remains incomplete. Completion: each delivered item has content reconciliation and task-outcome evidence. Stop delivery with a recorded gap when neither content nor snapshot can be confirmed.
Task example
Unexecuted synthetic walkthrough: the initial TASK_STATE_WORKING Task has no artifacts. A report-1 opening event has one Part and append=false. Two further events have append=true with one Part each, and the last has lastChunk=true. Under this example’s recorded opening-chunk policy, expect three ordered Parts. After completion use GetTask to compare IDs, actual Part content and order, and other delivery-relevant fields. If the initial Task after reconnect already holds report-1 content, reconstruct its baseline before later deltas. An append=true without any baseline remains incomplete. These are expectations, not observed artifacts.
Completion checks
- Check task ownership, shape and arrival order for Task-snapshot baselines and artifactUpdate deltas; keep status events and Message out of content.
- Record event sealing separately from successful-snapshot completeness; a missing lastChunk can be resolved by full content reconciliation with a COMPLETED GetTask snapshot, without turning an optional field into a requirement.
- Reconcile IDs, parts content and order and other delivery fields against GetTask; record terminal task state separately from Artifact completeness and never mark differing content complete.
Verification scope
This note was written from reading the A2A specification snapshot read on 2026-11-12. No SDK was installed, no service was logged into, and no API call was executed or its output verified; the example above is a hypothetical scenario. Field names and binding names (JSONRPC, GRPC, HTTP+JSON) follow that snapshot, and no SDK behavior beyond it is covered.
Sources
All links are official pages; verification dates are listed per source, and links point to the version checked.