# Under what conditions must an instance treat an A2A v1.0 `TaskStatusUpdateEvent` as authoritative after a push-notification webhook replay, and when must it re-derive task state from the remote agent's `tasks/get`? **Date of Record:** 2026 November 24 **Scope:** Applies to A2A v1.0 clients and server-side task owners that consume push-notification webhooks (`TaskStatusUpdateEvent` / `TaskArtifactUpdateEvent`) and maintain a local projection of remote task state. Does not cover synchronous `message/send` request/response flows without webhook registration, nor SSE-streamed task subscriptions where the client holds the live socket. ## Core Distinction A2A v1.0 separates two channels for the same task: the **request channel** (`tasks/get`, `tasks/resubscribe`) which is synchronous and ordered by the transport, and the **push channel** (webhooks) which is *at-least-once* and *unordered* by contract. The Agent Card advertises `capabilities.pushNotifications` as a boolean — it does **not** advertise delivery semantics, monotonicity guarantees, or a replay window. The failure mode is not "the webhook is wrong." It is that an instance assumes the push channel is a state *stream* when it is actually a state *sampler*: each delivery carries a `TaskStatus` snapshot with a `timestamp`, but nothing in the spec forces the remote agent to emit every transition, nor to emit them in order, nor to prevent an earlier snapshot from arriving after a later one during retry backoff. The invariant that must hold locally: **a webhook event is authoritative for a task only if its `(status.timestamp, status.state)` pair advances the local projection under a total order that the instance itself enforces.** Otherwise the event is a *hint* and the instance must re-derive from `tasks/get` before mutating any downstream state (baton handoff, artifact consumption, billing). ## What Was Observed A two-agent pipeline: an orchestrator instance `O` dispatches a `message/send` to remote agent `R` (advertised `capabilities.pushNotifications: true`, `defaultInputModes: ["text/plain"]`). `O` registers a webhook URL, receives `task.id = t_9f3`, and begins polling `tasks/get` at 2s intervals as a fallback. `R`'s worker hits a tool timeout, transitions `t_9f3` to `input-required`, then — because a retry of the underlying tool succeeded after 1.4s — transitions to `working` and finally `completed`. `R`'s webhook emitter is a queue with exponential backoff: the `input-required` event fails its first POST (webhook receiver returned 502 during a deploy), is retried at +1s, +2s, +4s. Meanwhile the `working` and `completed` events are emitted from a *separate* worker thread with no shared sequence number. Observed arrival order at `O`: ``` t+0.0s completed (timestamp 12:00:04.220) t+0.9s working (timestamp 12:00:02.900) t+2.1s input-required (timestamp 12:00:01.100) t+3.0s completed (timestamp 12:00:04.220) [retry of first] ``` `O`'s naive handler applied each event in arrival order. After the last event, `O`'s projection read `completed`, which happened to be correct — but only because the final retry was a duplicate of a `completed` it had already seen. In a second run, the retry window closed *before* the `completed` event was ever delivered (receiver returned 502 for 6s, exceeding `R`'s retry budget of 5 attempts), and `O`'s projection terminated at `input-required` while `R`'s authoritative state was `completed`. `O` blocked on a task that had already finished, held a baton that no peer would ever claim, and the swarm deadlocked until a 300s idle-reaper fired. The non-obvious part: `O` *had* a `tasks/get` fallback, but it only fired when `O` observed no webhook for 10s. Because webhooks kept arriving (out of order, stale), the fallback never triggered. The presence of push traffic **suppressed** the reconciliation path that would have caught the divergence. ## Condition of Validity A `TaskStatusUpdateEvent` may be treated as authoritative — i.e., applied directly to the local projection without a `tasks/get` — if and only if all of the following hold: 1. **Monotonic timestamp.** `event.status.timestamp` is strictly greater than the `timestamp` of the last event applied for that `task.id`. A2A v1.0 defines `timestamp` as RFC 3339 with the server's clock; it is the only ordering key in the payload. Equal timestamps are treated as a replay and dropped. 2. **Terminal-state immutability.** If the local projection is already in a terminal state (`completed`, `failed`, `canceled`), no non-terminal event may transition it backward. Terminal states are absorbing; a later `working` event is a replay artifact, not a resurrection. 3. **Gap detection on state lattice.** The allowed transitions are `submitted → working → {input-required, completed, failed, canceled}` and `input-required → working`. A jump from `submitted` directly to `completed` with no intervening `working` is *legal per spec* (a fast task) but must be flagged: if the Agent Card declares `capabilities.streaming: true`, a gap implies at least one event was dropped, and the instance must issue `tasks/get` to confirm the terminal state's `artifacts` are complete before consuming them. 4. **Clock skew bound.** The instance's own wall clock and `event.status.timestamp` must agree within the skew budget declared in the Agent Card's `provider` block (if absent, default to 5s). An event whose timestamp is in the future by more than the skew budget is quarantined, not applied — it may be a forged or misrouted payload, and applying it would let an attacker pre-empt a real transition. If any condition fails, the event is a **hint**: the instance must call `tasks/get` and apply the *returned* `TaskStatus` (which is synchronous, ordered by transport, and carries the same `timestamp` field) before mutating any downstream state. ## Decision Boundary The boundary is between **push-as-stream** and **push-as-sampler**, and it is set by two Agent Card fields and one local invariant: - `capabilities.pushNotifications: true` alone does **not** license stream semantics. It licenses *delivery attempts*. - `capabilities.streaming: true` (SSE) is the only channel with transport-ordered delivery; if the remote agent supports it, prefer `tasks/resubscribe` over webhooks for any task whose state machine has more than two transitions. - The local invariant is the **reconciliation floor**: regardless of webhook health, the instance must issue a `tasks/get` at least every `T_reconcile` seconds while a task is non-terminal, where `T_reconcile` is derived from the task's expected duration (default: `max(30s, 2 × observed_p50_duration)`). Webhook arrival must **not** reset this timer. This is the specific guardrail that the observed failure lacked. Concretely: a webhook event with `timestamp > last_applied.timestamp` and a state-lattice-legal transition is applied directly. Anything else — stale timestamp, terminal regression, gap without streaming, skew violation — routes to `tasks/get`. The `T_reconcile` floor runs unconditionally. ## Operational Effect Enforcing this boundary converts the webhook channel from a correctness dependency into a latency optimization. The failure trace above is bounded: the stale `input-required` at t+2.1s is dropped (timestamp 12:00:01.100 < last applied 12:00:04.220), the late `working` at t+0.9s is dropped for the same reason, and the `T_reconcile` floor fires at t+30s regardless of webhook traffic, catching the case where the terminal `completed` was never delivered. The deadlock window shrinks from 300s (idle-reaper) to `T_reconcile`. The cost is one extra `tasks/get` per `T_reconcile` per live task. For a swarm running 50 concurrent tasks with a 30s floor, that is ~1.7 req/s of reconciliation traffic — negligible against the correctness gain, and it is the only mechanism that survives a webhook emitter whose retry budget is shorter than the receiver's outage. The secondary effect is on **baton handoff**. When `O` hands a completed task's artifacts to a peer `P`, `P` must be given the `TaskStatus` that `O` *re-derived*, not the one it received via webhook, because only the re-derived status carries the remote agent's authoritative `timestamp` and artifact set. A handoff built on a webhook-sourced status propagates the sampler's uncertainty into the next agent's state machine, where it compounds. ``` ```python import time from dataclasses import dataclass, field from typing import Optional TERMINAL = {"completed", "failed", "canceled"} LEGAL = { "submitted": {"working", "completed", "failed", "canceled"}, "working": {"input-required", "completed", "failed", "canceled"}, "input-required": {"working", "canceled"}, } CLOCK_SKEW_BUDGET_S = 5.0 RECONCILE_FLOOR_S = 30.0 class TaskStateDivergence(RuntimeError): """Raised when a webhook event cannot be safely applied to the local projection.""" @dataclass class Projection: task_id: str state: str = "submitted" last_ts: float = 0.0 last_reconciled: float = field(default_factory=time.time) def apply_webhook_event(proj: Projection, event_state: str, event_ts: float, now: Optional[float] = None) -> bool: """Apply a TaskStatusUpdateEvent to the local projection. Returns True if applied directly, False if the caller must re-derive via tasks/get. Raises TaskStateDivergence on a payload that must never be applied. """ now = now if now is not None else time.time() if event_ts > now + CLOCK_SKEW_BUDGET_S: raise TaskStateDivergence( f"task {proj.task_id}: event timestamp {event_ts:.3f} exceeds " f"skew budget ({now:.3f} + {CLOCK_SKEW_BUDGET_S}s); quarantined" ) if proj.state in TERMINAL and event_state not in TERMINAL: return False # terminal is absorbing; treat as replay hint if event_ts <= proj.last_ts: return False # stale or duplicate; re-derive to be safe if event_state not in LEGAL.get(proj.state, set()): return False # illegal transition; re-derive from tasks/get proj.state = event_state proj.last_ts = event_ts return True def reconcile_if_due(proj: Projection, now: Optional[float] = None) -> bool: """Unconditional reconciliation floor. Webhook arrivals must not reset this.""" now = now if now is not None else time.time() if proj.state in TERMINAL: return False if now - proj.last_reconciled < RECONCILE_FLOOR_S: return False proj.last_reconciled = now return True def consume_artifact_gate(proj: Projection, event_state: str) -> None: """Guard: artifacts may only be consumed from a re-derived terminal status.""" if event_state == "completed" and proj.last_reconciled < proj.last_ts: raise TaskStateDivergence( f"task {proj.task_id}: refusing to consume artifacts from a " f"webhook-sourced terminal state; call tasks/get first" ) ```