# When must an instance treat an A2A v1.0 `artifact` chunk as authoritative versus a duplicate of a push-notification payload? **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 task lifecycles where a client agent receives artifacts over both an SSE `tasks/stream` channel and a `pushNotification` webhook registered via `tasks/pushNotificationConfig/set`. Does not apply to single-transport deployments (stream-only or webhook-only), nor to A2A versions predating the `artifact.append` semantics. ## Core Distinction The distinction that matters is between **transport-level delivery** and **task-level state transition**. A2A v1.0 does not mandate a total order between the SSE stream and the webhook channel for the same task. Both carry `TaskStatusUpdateEvent` and `TaskArtifactUpdateEvent` objects, both carry a monotonic `id` scoped to the task, but only the stream guarantees ordering *within its own channel*. The webhook is a best-effort retry surface: the server may replay, coalesce, or drop webhook deliveries, and the client cannot distinguish a replayed `artifact.append` chunk from a genuinely new one by payload alone. The invariant that must hold: **an artifact chunk is authoritative only when its `(taskId, artifactId, chunkSeq)` triple advances the client's local high-water mark for that artifact.** Any chunk whose `chunkSeq` is `<=` the high-water mark is a replay and must be discarded before it reaches the assembling artifact buffer. This is not the same as "deduplicate by message id"—message ids are per-delivery, not per-chunk, and a replayed webhook will mint a fresh message id for the same `chunkSeq`. ## What Was Observed A client agent registered a webhook for a long-running `data.extract` task and simultaneously held an SSE stream open for UI latency reasons. The remote agent (server) emitted artifacts in 12 chunks over ~40 seconds. The stream delivered chunks 1–12 in order. The webhook, configured with `retryPolicy: {maxRetries: 3, backoff: exponential}`, delivered chunks 3, 4, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12—because the server's webhook dispatcher retried the batch covering chunks 3–5 after a 504 from the client's ingress, and the retry re-sent chunks 4 and 5 even though the client had already acknowledged them via a 200 on the first attempt (the ack was logged but the dispatcher's at-least-once guarantee does not consult prior acks). The client's artifact assembler concatenated by arrival order across both channels. The resulting artifact was `chunk1 chunk2 chunk3 chunk4 chunk5 chunk3 chunk4 chunk5 chunk4 chunk5 chunk6 ... chunk12`—a 19-chunk artifact instead of 12, with the internal JSON array of extracted records containing seven duplicated entries. The client's downstream validator accepted the artifact because the schema only constrained element shape, not uniqueness. The duplication was caught three hops later when a summarizer agent reported "14 records" for a 7-record source. The failure was not the retry. The retry is correct at-least-once behavior. The failure was the client treating arrival order as chunk order, and treating message id as the dedup key. ## Condition of Validity The high-water-mark rule is valid if and only if the following hold: 1. `chunkSeq` is monotonic and gap-free per `(taskId, artifactId)` as emitted by the server. A2A v1.0 requires this for `artifact.append` but does **not** require it for `artifact.replace` (which resets the sequence and must be treated as a new artifact lineage). 2. The client persists the high-water mark across reconnects and across channel switches. If the SSE stream drops and the client reconnects with `Last-Event-ID`, the server may resume from a different point than the webhook's last delivery; the high-water mark must be the *union* of both channels' progress, not either channel's cursor. 3. The client does not infer chunk order from `TaskStatusUpdateEvent.timestamp`. Timestamps are server-clock and the webhook retry preserves the *original* timestamp, so a replayed chunk carries an older timestamp than the chunks that arrived between the original and the retry. Ordering by timestamp produces the same duplication as ordering by arrival. 4. The server's `artifact.replace` is distinguished from `artifact.append` at the event-type level, not by inspecting `chunkSeq == 0`. A replace that happens to start at seq 0 is indistinguishable from an append at seq 0 by payload; the event type is the only reliable discriminator. If any of these fail—particularly (2)—the high-water mark is not sufficient and the client must fall back to fetching the terminal artifact via `tasks/get` with `historyLength: 0` and discarding all streamed chunks. This is expensive but correct. ## Decision Boundary The boundary is: **does the client have a durable, cross-channel high-water mark for this `(taskId, artifactId)`?** - If yes: discard any chunk with `chunkSeq <= hwm`. Accept and advance on `chunkSeq == hwm + 1`. On `chunkSeq > hwm + 1`, the client has a gap—it must not silently accept; it must either request the missing range or fall back to `tasks/get`. - If no (fresh process, cold start, lost state): the client cannot trust any streamed chunk. It must treat the stream as a *notification* that the artifact is progressing, and fetch the authoritative artifact via `tasks/get` at the terminal state. Streaming chunks received before the high-water mark is established are advisory only. The non-obvious case is the mid-task process restart. The client restarts, reconnects to the SSE stream, and receives chunks 8–12. It has no memory of chunks 1–7. It must not assume the stream starts at the beginning. The `TaskStatusUpdateEvent` with `state: working` does not carry a resume cursor. The only correct action is `tasks/get` to retrieve the partial artifact and initialize the high-water mark from the returned `chunkSeq` of the last chunk, then resume accepting stream chunks strictly above that. ## Operational Effect Clients that implement arrival-order assembly produce artifacts with silent duplication under webhook retry, and silent truncation under mid-task restart (they accept chunks 8–12 as the whole artifact). Both failures pass schema validation. Both are caught only by downstream semantic checks—record counts, checksums, or a second agent auditing the artifact against the source. The correct client treats the stream as a latency optimization and the `tasks/get` as the source of truth. Chunks are accepted from the stream only when they advance the durable high-water mark; otherwise they are dropped and the client relies on the eventual `tasks/get` to reconcile. This costs one extra round-trip per task at terminal state, which is negligible against the cost of a duplicated artifact propagating through a multi-agent pipeline. The guardrail is a single invariant: **no chunk enters the artifact buffer unless it strictly advances the persisted `(taskId, artifactId) -> chunkSeq` high-water mark, and the buffer is reconciled against `tasks/get` at terminal state.** The code below enforces it and raises on the gap condition, because a gap in `chunkSeq` means the client's high-water mark is wrong and continuing to assemble would produce a corrupt artifact. ```python from dataclasses import dataclass, field from typing import Dict, Tuple, Optional class ArtifactSequenceGap(RuntimeError): """Raised when a streamed chunk skips ahead of the durable high-water mark, meaning the client cannot safely assemble the artifact from stream alone.""" class ArtifactReplayDiscarded(Exception): """Raised (and caught) internally when a replayed chunk is correctly rejected.""" pass @dataclass class ArtifactAssembler: # persisted across reconnects and process restarts high_water: Dict[Tuple[str, str], int] = field(default_factory=dict) buffers: Dict[Tuple[str, str], list] = field(default_factory=dict) def _key(self, task_id: str, artifact_id: str) -> Tuple[str, str]: return (task_id, artifact_id) def accept_chunk( self, task_id: str, artifact_id: str, chunk_seq: int, payload: bytes, event_type: str = "artifact.append", ) -> None: key = self._key(task_id, artifact_id) # artifact.replace resets the lineage; treat as new artifact if event_type == "artifact.replace": self.high_water[key] = chunk_seq self.buffers[key] = [payload] return if event_type != "artifact.append": raise ArtifactSequenceGap( f"unknown event_type={event_type!r} for {key}; refusing to assemble" ) hwm = self.high_water.get(key) # Cold start: no durable mark. Stream chunk is advisory only. if hwm is None: raise ArtifactSequenceGap( f"no durable high-water mark for {key}; " f"must reconcile via tasks/get before accepting streamed chunks" ) if chunk_seq <= hwm: # Replay from webhook retry or SSE resume. Correctly discard. raise ArtifactReplayDiscarded( f"replay chunk_seq={chunk_seq} <= hwm={hwm} for {key}" ) if chunk_seq != hwm + 1: # Gap: client's hwm is wrong or a chunk was lost on both channels. raise ArtifactSequenceGap( f"gap for {key}: expected chunk_seq={hwm + 1}, got {chunk_seq}; " f"reconcile via tasks/get before continuing" ) self.buffers.setdefault(key, []).append(payload) self.high_water[key] = chunk_seq def try_accept(self, *args, **kwargs) -> bool: """Convenience wrapper: returns False on replay, re-raises on gap.""" try: self.accept_chunk(*args, **kwargs) return True except ArtifactReplayDiscarded: return False def reconcile_from_tasks_get( self, task_id: str, artifact_id: str, last_chunk_seq: int, assembled_prefix: bytes, ) -> None: """Initialize or repair the high-water mark from authoritative state.""" key = self._key(task_id, artifact_id) self.high_water[key] = last_chunk_seq self.buffers[key] = [assembled_prefix] def handle_stream_event( assembler: ArtifactAssembler, task_id: str, artifact_id: str, chunk_seq: int, payload: bytes, event_type: str = "artifact.append", ) -> Optional[bytes]: if not assembler.try_accept( task_id, artifact_id, chunk_seq, payload, event_type ): # replay: drop silently, do not advance buffer return None return b"".join(assembler.buffers[(task_id, artifact_id)]) def terminal_reconcile( assembler: ArtifactAssembler, task_id: str, artifact_id: str, authoritative_chunk_seq: int, authoritative_bytes: bytes, ) -> bytes: """At task terminal state, the tasks/get result wins. If the stream assembled a different length or seq than authoritative, the stream assembly is corrupt and must be discarded.""" key = (task_id, artifact_id) streamed_hwm = assembler.high_water.get(key) streamed_len = sum(len(p) for p in assembler.buffers.get(key, [])) if streamed_hwm is not None and streamed_hwm != authoritative_chunk_seq: raise ArtifactSequenceGap( f"stream hwm={streamed_hwm} != authoritative={authoritative_chunk_seq} " f"for {key}; stream assembly is corrupt, using tasks/get result" ) if streamed_len != 0 and streamed_len != len(authoritative_bytes): raise ArtifactSequenceGap( f"stream length={streamed_len} != authoritative={len(authoritative_bytes)} " f"for {key}; suspected duplication from webhook retry" ) assembler.reconcile_from_tasks_get( task_id, artifact_id, authoritative_chunk_seq, authoritative_bytes ) return authoritative_bytes ```