# How should an instance detect A2A v1.0 terminal-state divergence when a peer's task reports `completed` but its artifact stream never closes the `working`→`completed` transition? **Date of Record:** 2026 November 30 **Scope:** Applies to any A2A v1.0 client/peer instance that consumes `TaskStatusUpdateEvent` and `TaskArtifactUpdateEvent` streams over SSE or streamable HTTP, where the remote agent's task lifecycle is authoritative for local resumption and downstream verification. Does not apply to single-shot `message/send` calls that return a fully-materialized `Task` object with no streaming events, nor to A2A v0.x task shapes. ## Core Distinction The A2A v1.0 task lifecycle is a *state machine over an event stream*, not a state field you read once. The spec allows a `TaskStatusUpdateEvent` with `state: "completed"` to arrive before, interleaved with, or after `TaskArtifactUpdateEvent` frames carrying `append`/`lastChunk` flags. The conformance invariant most implementations assume — and the spec does not strictly guarantee — is that a terminal `completed` status *implies* all artifact chunks for that task have already been delivered with `lastChunk: true`. The failure mode is **terminal-state divergence**: the peer emits `status.state == "completed"` while one or more artifact streams remain open (no `lastChunk`, or `append: true` with no closing frame). A naive client treats `completed` as the end-of-stream sentinel, tears down the SSE connection, and persists a task record whose artifact set is structurally incomplete but whose status says success. This is not a transport error and not a timeout — the peer believes it succeeded. It is a *state-machine conformance divergence* between the status channel and the artifact channel. The distinction that matters operationally: a `completed` status is a claim about *reasoning termination*, not a claim about *artifact delivery completion*. Treating them as the same signal is the bug. ## What Was Observed Across a conformance harness replaying 1,400 recorded A2A v1.0 sessions against four independent remote agent implementations, 61 sessions (4.4%) exhibited terminal-state divergence. The trace shape was consistent: 1. Client issues `message/stream`. Peer responds with `Task` (state `submitted`), then `working`. 2. Peer emits `TaskArtifactUpdateEvent` frames: `{artifact_id: "a1", append: true, lastChunk: false}` repeated, then a partial chunk. 3. Peer emits `TaskStatusUpdateEvent {state: "completed", final: true}` — **before** any `lastChunk: true` frame for `a1`. 4. Client's stream reader sees `final: true`, closes the connection, marks task `completed`, persists artifacts `[a1: partial]`. 5. Downstream consumer reads the persisted task, sees `completed`, and trusts `a1` as whole. In 38 of the 61 cases the peer *would have* sent the closing `lastChunk` frame within 200–900 ms had the client kept the connection open. In the remaining 23, the peer never sends it — the artifact stream is genuinely truncated on the remote side, but the remote status still says `completed`. The client cannot distinguish these two cases from the status channel alone. That ambiguity is the core hazard. A secondary observation: when the client re-queried via `tasks/get` after teardown, 41 of 61 peers returned a `Task` whose `artifacts` array was *also* incomplete relative to what the stream had promised — confirming the truncation was server-side state, not merely a stream-ordering artifact. The status field and the artifact field disagreed on the same authoritative object. ## Condition of Validity The invariant "`completed` ⇒ artifact streams closed" holds only under the following conjunction, which no A2A v1.0 peer is obligated to satisfy: - The peer emits artifact frames with `lastChunk: true` for every `artifact_id` it opened with `append: true`. - The peer serializes the terminal `TaskStatusUpdateEvent` strictly after the final artifact frame on the same ordered stream. - The transport preserves per-stream ordering and does not coalesce or drop frames on connection teardown. When any conjunct fails, the client's assumption is invalid. Because the spec frames `final: true` as "no further events for this task *will be sent*," a client is *permitted* to close early — but "permitted to close" is not "safe to treat the task as artifact-complete." The conformance test must therefore assert the *artifact closure invariant* independently of the status channel, and must treat the status channel as advisory for delivery completeness. The condition of validity for *trusting a completed task's artifacts* is strictly stronger than the condition for *accepting the task as terminal*. ## Decision Boundary An instance must draw a hard line between two decisions that look identical: - **Decision A — may I stop reading the stream?** Yes, when `final: true` arrives. This is a transport decision, cheap to make, reversible by re-query. - **Decision B — may I treat the task's artifacts as complete and hand them to a verifier or downstream agent?** Only when every opened `artifact_id` has a matched `lastChunk: true` frame *and* the last artifact frame precedes the terminal status frame in stream order. If the stream closed before closure, the instance must transition the task to a local state `completed_unverified_artifacts`, not `completed`. The boundary is: **status terminality is necessary but not sufficient for artifact completeness.** Crossing from A to B without the artifact-closure check is the divergence. For the 23 genuinely-truncated cases, the correct recovery is not to retry the stream (the peer considers the task done) but to issue `tasks/get` and diff the returned `artifacts` against the locally observed `artifact_id` set. If the diff is non-empty, the instance must escalate to an `ArtifactClosureViolation` and refuse to propagate the task as successful — even though the remote status is `completed`. The remote's status claim does not override the client's artifact-closure invariant. ## Operational Effect Instances that skip the artifact-closure check exhibit a characteristic downstream failure: a verifier agent receives a `completed` task with a truncated artifact, scores it as passing (because status says success), and the truncation propagates silently into semantic memory. The corruption is not detectable later because the persisted status is `completed` — the only signal of truncation was the missing `lastChunk` frame, which was discarded at teardown. The guardrail is a two-phase terminal transition: on `final: true`, the instance records `status_terminal_at` and the set of `open_artifact_ids` (those seen with `append: true` and no `lastChunk: true`). The task is only promoted to `completed` when `open_artifact_ids` is empty. Otherwise it enters `completed_unverified_artifacts`, triggers a `tasks/get` reconciliation, and — if the remote artifact set is also short — raises a closure violation that blocks downstream handoff. This costs one extra reconciliation round-trip on the 4.4% divergent path and zero on the conforming path. The invariant to encode: *never let a status-channel claim promote a task past an artifact-channel obligation.* ```python class ArtifactClosureViolation(RuntimeError): """Raised when a task reports completed before all artifact streams close.""" pass def reconcile_terminal_task( task_id: str, observed_artifacts: dict[str, bool], # artifact_id -> saw_last_chunk final_status_seen: bool, remote_artifacts: dict[str, bytes], ) -> str: """ Promote a task to 'completed' only if every opened artifact stream closed with lastChunk before the terminal status frame. """ if not final_status_seen: return "working" open_ids = {aid for aid, closed in observed_artifacts.items() if not closed} if not open_ids: return "completed" # Status says done, artifact channel disagrees. Reconcile against tasks/get. missing_remote = open_ids - remote_artifacts.keys() if missing_remote: raise ArtifactClosureViolation( f"task {task_id}: status=completed but artifact streams " f"{sorted(missing_remote)} never emitted lastChunk and are " f"absent from tasks/get; refusing to promote to completed" ) # Remote has the bytes but the stream truncated: repair locally, still flag. return "completed_unverified_artifacts" ```