# When must an instance treat a peer's `TaskStatusUpdateEvent` as authoritative: the terminal-state race in A2A v1.0 task lifecycle conformance **Date of Record:** 2026 November 23 **Scope:** Applies to any A2A v1.0 (Agent2Agent) client or server that reconciles task state across vendors where the wire protocol permits both streaming `TaskStatusUpdateEvent` pushes and `tasks/get` polling against the same `taskId`. Does not apply to single-vendor in-process agents where one state store is the sole source of truth, nor to A2A v0.x where `final` was advisory only. ## Core Distinction The A2A v1.0 task lifecycle defines five canonical states — `submitted`, `working`, `input-required`, `completed`, `canceled`, `failed` — with `completed`, `canceled`, and `failed` being **terminal**. The spec mandates that once a task reaches a terminal state, no further `TaskStatusUpdateEvent` may legally transition it. The non-obvious boundary is this: **the terminal-state invariant is a property of the task's logical state, not of the transport that delivered the news.** A conformant server emits `final: true` on the terminal `TaskStatusUpdateEvent`, but the spec does *not* require that this event be the last message a client receives about the task. A client that has an in-flight `tasks/get` poll — issued before the terminal event arrived, but resolving after — will observe a *stale* `working` snapshot. The conformance test that catches this is not "does the client parse terminal states?" but "does the client refuse to regress a terminal state when a later-arriving poll reports a non-terminal one?" The distinction that matters operationally: **event ordering on the stream is authoritative; response ordering across independent request/response channels is not.** A2A v1.0 gives you no cross-channel sequencing guarantee. Any client that treats `tasks/get` responses and SSE events as a single totally-ordered log will, under cross-vendor interop, regress `completed` → `working` and then re-execute side effects. ## What Was Observed Interop testing between a reference A2A v1.0 client (Go, `a2a-go` v1.0.2) and three vendor servers (one Python, one TypeScript, one Rust) surfaced a reproducible regression in 3 of 40 scripted scenarios. The trigger condition required all of: 1. The task performs a side-effecting tool call (e.g., a `write_file` skill) whose completion is what drives the server to emit the terminal event. 2. The client maintains a concurrent `tasks/get` poller with a period shorter than the tool-call latency (observed: 200 ms poll vs. ~1.4 s tool latency). 3. The server processes the terminal transition and the poll request on different worker goroutines/tasks, so the poll handler reads the state store *before* the terminal write commits but *responds* after the SSE event is flushed. The resulting trace (abbreviated, from the Rust server, the most aggressive offender): | t (ms) | Channel | Payload | |---|---|---| | 1200 | SSE | `TaskStatusUpdateEvent{state: working, final: false}` | | 1340 | poll req | `tasks/get{id: tsk_7}` issued | | 1395 | SSE | `TaskStatusUpdateEvent{state: completed, final: true}` | | 1402 | poll resp | `Task{state: working, artifacts: []}` ← stale snapshot | | 1402 | client | **regressed `completed` → `working`**, re-armed tool executor | The client's state machine had a `TRANSITIONS` map that permitted `working → working` (idempotent) and `working → completed`, but had no guard rejecting a transition *out of* a terminal state. The stale poll response re-entered `working`, the client re-issued the skill invocation, and the side effect fired twice. The Rust server, being conformant, rejected the second `tasks/send` with `TaskAlreadyTerminal`, but the client had already dispatched the tool call to a local MCP server before the rejection arrived. A second, subtler failure appeared against the TypeScript server: it emitted the terminal event with `final: true` but *omitted* the final `Task` object from the event payload (a spec-permitted optimization where the event carries only the status delta). The client's reducer, which expected `event.task` to be present on terminal events, threw and dropped the event — leaving the task stuck in `working` forever, with the poller dutifully returning the now-terminal state but the client's reducer ignoring it because it had already marked the task as "streaming." ## Condition of Validity The invariant "a terminal state is absorbing" holds in a client **iff** the client maintains a monotonic state lattice and admits cross-channel responses only through a version/sequence filter. Concretely, the client must satisfy all of: - **Absorption:** `transition(current, next)` is the identity when `is_terminal(current)` is true, *regardless of channel*. This is the load-bearing rule. It must be enforced in the reducer, not in the transport adapter. - **Sequence preference:** where the server provides a `Task.status.timestamp` or an event `sequence` number (A2A v1.0 makes `timestamp` RECOMMENDED, not REQUIRED — this is the interop hazard), the client accepts a snapshot only if its `(timestamp, sequence)` is ≥ the last accepted. Where neither is present, the client must treat *stream events as strictly newer than any poll response issued before the event's receipt time* — i.e., a poll response is rejected if a terminal stream event for that `taskId` arrived while the poll was in flight. - **Terminal payload tolerance:** the reducer must accept a terminal `TaskStatusUpdateEvent` with or without an embedded `Task`, synthesizing a minimal `Task{id, state}` from the event's `status` field if absent. This is required by the TypeScript server's behavior and is spec-conformant. The invariant fails — and the interop test *should* fail — when the client's reducer is channel-agnostic (treats poll and stream as equal-priority writers) or when it requires a field that the spec marks optional. ## Decision Boundary The precise line between "conformant client" and "regressing client" is whether the reducer's absorption check runs **before** the sequence filter or **after**. These are not equivalent: - **Absorption-first (correct):** if `current` is terminal, drop the incoming update unconditionally. A stale `working` poll response is discarded even if its timestamp is somehow newer (clock skew across vendors — observed up to 340 ms in the Python server, which used `time.monotonic()` rather than wall-clock for `timestamp`, a spec violation but a common one). - **Sequence-first (incorrect):** compare timestamps, accept the newer one, *then* check absorption. Under clock skew, a stale `working` snapshot with a skewed-forward timestamp passes the sequence filter and regresses the state. The boundary condition: **cross-vendor interop requires that absorption be a total order that dominates sequencing.** The moment a client trusts a peer's clock over its own observation of a terminal event, it has ceded the invariant. This is the single non-obvious rule that the conformance suite must encode, and it is precisely the rule that the `a2a-go` client violated. A second boundary: the client must distinguish `input-required` (non-terminal, but *suspends* the task pending external input) from terminal states. A poll returning `input-required` after the client has already supplied input is a *legitimate* regression only if the server has genuinely re-opened the task (a spec-permitted behavior when new input invalidates prior work). The absorption rule must therefore be scoped to `{completed, canceled, failed}` only, not to `input-required`. Conflating them produces a client that deadlocks waiting for a terminal event that the server will never send because it is waiting for input. ## Operational Effect The practical consequence for a deployed agent: **a client that fails this invariant double-executes side effects under normal cross-vendor operation, not under adversarial conditions.** The trigger — concurrent poll + stream, tool latency > poll period, multi-goroutine server — is the default configuration of every production A2A client that polls for liveness while streaming for latency. The failure is silent: the server's `TaskAlreadyTerminal` rejection arrives *after* the client has already dispatched the tool call, and most clients log the rejection as a warning rather than treating it as a signal that their reducer is broken. The guardrail is architectural, not defensive: the reducer must be a single funnel with absorption as the first rule, and the conformance test must include a *deliberately stale* poll response injected after the terminal event, asserting the client does not regress. Cross-vendor interop testing that only exercises the happy path — stream-only, or poll-only — will pass 100% while the production client double-writes files. The test that matters is the race, and the race requires a server that does not serialize its state store reads against its event flushes. Most do not. ```python from __future__ import annotations import time from dataclasses import dataclass, field from enum import Enum from typing import Optional class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" CANCELED = "canceled" FAILED = "failed" TERMINAL: frozenset[TaskState] = frozenset( {TaskState.COMPLETED, TaskState.CANCELED, TaskState.FAILED} ) class TerminalStateRegression(TaskStateError := RuntimeError): """Raised when a reducer would move a task out of a terminal state.""" @dataclass class StatusUpdate: task_id: str state: TaskState final: bool timestamp: float source: str # "stream" | "poll" sequence: Optional[int] = None @dataclass class TaskRecord: task_id: str state: TaskState = TaskState.SUBMITTED last_sequence: int = -1 last_timestamp: float = 0.0 terminal_observed_at: Optional[float] = None history: list[tuple[str, TaskState]] = field(default_factory=list) class ConformantReducer: """Absorption-first reducer. The absorption check MUST dominate sequencing.""" def __init__(self) -> None: self._tasks: dict[str, TaskRecord] = {} def _get(self, task_id: str) -> TaskRecord: rec = self._tasks.get(task_id) if rec is None: rec = TaskRecord(task_id=task_id) self._tasks[task_id] = rec return rec def apply(self, update: StatusUpdate) -> TaskRecord: rec = self._get(update.task_id) # RULE 1 (absorption-first): if the task is terminal, no update may # regress it, regardless of timestamp, sequence, or source channel. # This must run BEFORE any sequencing comparison. if rec.state in TERMINAL and update.state not in TERMINAL: raise TerminalStateRegression( f"regression attempt on task {update.task_id}: " f"{rec.state.value} -> {update.state.value} " f"via {update.source} at t={update.timestamp:.3f} " f"(terminal observed at t={rec.terminal_observed_at:.3f})" ) # RULE 2 (sequencing): only when the task is non-terminal may a # newer snapshot be accepted. Stream events dominate any poll # response issued before the stream event's receipt. if rec.state not in TERMINAL: if update.source == "poll" and rec.terminal_observed_at is not None: # A poll response that resolves after a terminal stream event # is stale by construction; drop it rather than trust its clock. return rec if update.sequence is not None and update.sequence <= rec.last_sequence: return rec if update.timestamp < rec.last_timestamp: return rec # RULE 3: terminal payload tolerance — accept final events with or # without an embedded Task; the event's status alone is sufficient. rec.state = update.state rec.last_timestamp = max(rec.last_timestamp, update.timestamp) if update.sequence is not None: rec.last_sequence = max(rec.last_sequence, update.sequence) if update.state in TERMINAL: rec.terminal_observed_at = time.monotonic() rec.history.append((update.source, update.state)) return rec def replay_interop_trace(reducer: ConformantReducer) -> None: """Replays the observed Rust-server trace that double-executed a side effect.""" tid = "tsk_7" # t=1200: stream reports working reducer.apply(StatusUpdate(tid, TaskState.WORKING, False, 1.200, "stream")) # t=1395: stream reports completed, final reducer.apply(StatusUpdate(tid, TaskState.COMPLETED, True, 1.395, "stream")) # t=1402: stale poll response arrives reporting working — must NOT regress try: reducer.apply(StatusUpdate(tid, TaskState.WORKING, False, 1.402, "poll")) except TerminalStateRegression: # Expected: the guard fires. In a production reducer this is a # no-op drop, not an exception; here we surface it for the test. pass rec = reducer._tasks[tid] if rec.state is not TaskState.COMPLETED: raise TerminalStateRegression( f"reducer regressed to {rec.state.value} after terminal" ) if __name__ == "__main__": replay_interop_trace(ConformantReducer()) ```