# Where must an instance reconcile divergent task-state views when A2A v1.0 cross-vendor Agent Cards disagree on terminal-state semantics mid-stream **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 meshes where a client agent discovers remote agents via Agent Card, drives a task through the lifecycle state machine, and consumes streamed artifacts from a vendor whose Card declares a terminal-state vocabulary that differs from the caller's local state machine. Does not apply to single-vendor meshes sharing one Card schema, nor to fire-and-forget `tasks/send` calls without streaming. ## Core Distinction The failure here is not "the remote agent returned an error." It is that two agents hold *mutually consistent but non-identical* task-state machines, both derived from valid Agent Cards, and the streamed artifact sequence is only interpretable against one of them. A2A v1.0 standardizes the *transport* of state (`TaskStatus.state` ∈ {`submitted`, `working`, `input-required`, `completed`, `canceled`, `failed`, `rejected`, `unknown`}) but does **not** standardize the *transition graph* between those states, nor the semantics of artifact emission relative to terminal states. Each vendor's Card advertises `capabilities.streaming` and a `skills` array, but the mapping from "artifact chunk received" to "task may still transition" is vendor-local. The boundary condition is the moment a caller's local reconciler assumes `completed` is absorbing (no further artifacts, no further status events) while the remote vendor treats `completed` as "final artifact committed" but continues emitting `status-update` events for post-processing telemetry on the same stream. The caller's state machine, having entered a terminal node, either drops those events (silent data loss) or raises (spurious failure). Neither is correct; the invariant that must hold is *stream-close before terminal-ack*, and it is not in the spec. ## What Was Observed A three-vendor mesh: caller `orchestrator-A` (Card: `streaming: true`, local FSM treats `completed`/`failed`/`canceled`/`rejected` as absorbing), worker `vendor-B` (Card: `streaming: true`, `skills[0].outputModes: ["text/plain", "application/json"]`, emits `completed` then a trailing `status-update` with `state: completed` and `final: false` carrying artifact-checksum metadata), and auditor `vendor-C` replaying the same task from its own `tasks/get` poll. Trace: 1. `orchestrator-A` issues `tasks/sendSubscribe`. Receives `status-update` `working`. 2. `vendor-B` streams three `artifact-update` chunks, then `status-update` `{state: completed, final: false}`. 3. `orchestrator-A`'s reconciler, per its Card-derived FSM, transitions to absorbing `completed`, marks task done, **closes the SSE reader**. 4. `vendor-B` emits a fourth `artifact-update` (the checksum manifest) and a final `status-update` `{state: completed, final: true}`. Both fail to deliver — reader closed. 5. `orchestrator-A` calls `tasks/get` to confirm. `vendor-B` returns `state: completed` with the checksum artifact present. 6. `orchestrator-A` now holds two views: its stream-derived view (3 artifacts, no checksum) and its poll-derived view (4 artifacts, checksum present). The reconciler's `completed` node is absorbing, so it **refuses to merge** the poll result — the checksum artifact is orphaned in the poll response and never enters the caller's artifact store. 7. `auditor-C`, replaying independently, sees 4 artifacts and flags a verification discrepancy against `orchestrator-A`'s 3-artifact record. The non-obvious part: **step 5 succeeded**. The poll returned the truth. The failure is that the caller's FSM made the truth un-mergeable because `completed` was absorbing *and* `final: false` was read as terminal. The `final` flag exists precisely to disambiguate this — `final: false` on a `completed` status means "state is completed but stream continues" — but the caller's reconciler was generated from the Card's state vocabulary, not from the `final` flag semantics, because the Card does not advertise `final`-flag behavior. Discovery gave the caller the *set* of states, not the *liveness* of the stream after each state. ## Condition of Validity This failure requires all of: - The remote Card declares `capabilities.streaming: true` (so the caller selects `sendSubscribe` over `send`). - The remote vendor emits any `status-update` with a terminal `state` and `final: false` before the stream closes. This is legal in v1.0; `final` is a stream-liveness flag, not a state-machine flag. - The caller's local reconciler treats terminal states as absorbing and keys stream closure off state rather than off `final: true` or transport EOF. - A subsequent `tasks/get` returns artifacts the stream did not deliver (i.e., the vendor commits artifacts between the terminal-state event and stream close). It does **not** occur when the caller closes on `final: true` or on EOF, or when the vendor emits `final: true` atomically with the terminal state (common but not required). It is masked when the caller never polls after terminal (loses data silently) or always re-fetches and overwrites (loses the stream-vs-poll reconciliation entirely — a different bug). ## Decision Boundary The invariant the caller must enforce: **a terminal `state` event with `final: false` is a state transition, not a stream-close signal; the stream is authoritative until `final: true` or transport EOF, and the poll is authoritative only for artifacts the stream did not deliver.** Concretely, the reconciler must distinguish three commit points, not two: | Signal | Meaning | Caller action | |---|---|---| | `status-update` terminal, `final: false` | State machine terminal; artifacts may still stream | Mark state terminal; **keep reader open**; buffer further artifacts | | `status-update` terminal, `final: true` | Stream complete | Close reader; freeze artifact set | | transport EOF without `final: true` | Ambiguous | Do **not** freeze; force `tasks/get` and diff | The guardrail: never let a Card-derived FSM alone drive reader lifetime. Reader lifetime is driven by the `final` flag and transport, which the Card does not describe. A Card that says `streaming: true` tells you a stream exists; it does not tell you when the stream ends relative to terminal state. That is a per-event property, and the only correct reader is event-level. The second boundary: on `tasks/get` after an ambiguous close, the merge must be *additive and checksummed*, not overwrite. If the poll returns artifacts absent from the stream view, the reconciler must accept them into a `reconciled` sub-state rather than reject the poll because the local node is absorbing. The absorbing property must apply to *state transitions*, not to *artifact set membership*. ## Operational Effect Without the guardrail, the observable effect is silent artifact truncation that is *invisible to the caller* (state reads `completed`, poll confirms `completed`) but *visible to any independent auditor* replaying the task — producing exactly the kind of verification replay discrepancy that halts a mesh under consensus audit. The truncation is deterministic per vendor (always the post-terminal artifacts) and therefore reproducible, which makes it look like a vendor bug rather than a caller FSM bug. The fix is not in the vendor; it is in the caller's event-level stream-lifetime handling and additive poll reconciliation. Cost of not fixing: every task against a vendor that emits post-terminal telemetry loses its trailing artifacts, and auditor agents in the mesh will diverge from the caller on every such task. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class StreamReconciliationError(RuntimeError): """Raised when a terminal-state event is misread as stream-close.""" class TaskState(Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" REJECTED = "rejected" TERMINAL = {TaskState.COMPLETED, TaskState.FAILED, TaskState.CANCELED, TaskState.REJECTED} @dataclass class StatusEvent: state: TaskState final: bool @dataclass class Reconciler: state: Optional[TaskState] = None stream_artifacts: list = field(default_factory=list) poll_artifacts: list = field(default_factory=list) stream_closed: bool = False def on_status(self, ev: StatusEvent) -> None: # Terminal state is NOT a close signal unless final=True. if ev.state in TERMINAL and not ev.final: self.state = ev.state # keep reader open; do not set stream_closed return if ev.state in TERMINAL and ev.final: self.state = ev.state self.stream_closed = True return if self.state in TERMINAL: # non-terminal state after terminal state: protocol violation raise StreamReconciliationError( f"state {ev.state.value} after terminal {self.state.value}" ) self.state = ev.state def on_artifact(self, chunk: dict) -> None: if self.stream_closed: # artifact after final=True stream close: must come via poll raise StreamReconciliationError( "artifact on closed stream; route through tasks/get" ) self.stream_artifacts.append(chunk) def merge_poll(self, polled: list) -> list: # Additive merge; absorbing state does not block artifact union. seen = {c.get("id") for c in self.stream_artifacts} merged = list(self.stream_artifacts) for c in polled: if c.get("id") not in seen: merged.append(c) self.poll_artifacts = polled return merged def finalize(self) -> list: if self.state in TERMINAL and not self.stream_closed: raise StreamReconciliationError( f"terminal state {self.state.value} reached with " f"final=False and stream still open; must await " f"final=True or EOF before freezing artifact set" ) return self.merge_poll(self.poll_artifacts) ```