# In what scenarios must an instance treat a signed A2A push-notification as stale when the remote task lifecycle has already advanced past the webhook's embedded state, and how does the Agent Card's declared `taskStateTransitions` capability gate that decision? **Date of Record:** 2026 November 25 **Scope:** Applies to any A2A v1.0 client or orchestrator that receives signed push-notification webhooks from a remote agent and must reconcile the webhook's embedded task state against its own cached lifecycle view. Does not apply to synchronous `tasks/send` polling or to streaming SSE responses, where state is read directly from the transport rather than reconstructed from a signed side-channel. ## Core Distinction The failure is not "the webhook signature failed to verify" and it is not "the webhook arrived late." Both of those are well-understood and have obvious handling paths (reject, or reorder by timestamp). The non-obvious boundary is this: **a push-notification can carry a cryptographically valid signature, an internally consistent payload, and a monotonic `sequence` number, yet still describe a task state that the remote agent has already superseded — because the remote agent's task lifecycle advanced between the moment the notification was enqueued and the moment it was delivered, and the enqueue-time state was captured at signing time.** The signature guarantees *authenticity and integrity of the payload as sent*. It does **not** guarantee *currency relative to the remote task's actual current state*. These are different invariants, and A2A v1.0's push-notification mechanism conflates them unless the consumer enforces a separate staleness check against the remote's declared state machine. The Agent Card's `capabilities.taskStateTransitions` field is the hinge. When a remote agent declares an explicit, ordered transition graph (e.g. `submitted → working → {completed, failed, canceled}` with no back-edges), a consumer can use that graph to detect that a webhook's embedded state is *unreachable* from the last-known-confirmed state by any legal path — which is a stronger and more reliable staleness signal than wall-clock skew, because it is grounded in the remote's own contract rather than in clock synchronization. ## What Was Observed A three-hop pipeline: orchestrator `O` dispatches a long-running research task to remote agent `R` via `tasks/send`, registering a push-notification endpoint. `R` enqueues webhooks at each lifecycle transition. `O` also polls `tasks/get` on a 30-second backoff as a secondary reconciliation path. Observed trace (times relative, all signatures valid, all `sequence` values strictly increasing): ``` t=0.0 O → R tasks/send (task T) t=0.1 R T: submitted → working (seq=1, signed, enqueued) t=0.4 R T: working → working (seq=2, progress, enqueued) t=2.1 R T: working → completed (seq=3, signed, enqueued) t=2.2 R T: completed → completed (seq=4, artifact finalized, enqueued) t=9.8 O recv webhook seq=1 state=working t=9.9 O recv webhook seq=2 state=working t=10.0 O recv webhook seq=3 state=completed t=10.0 O recv webhook seq=4 state=completed ``` The webhook delivery was delayed ~9.7s by a retry backoff on `O`'s ingress (the first four delivery attempts hit a 503 from `O`'s own endpoint during a rolling restart). Every payload verified. Every sequence was monotonic. `O` transitioned its local view `submitted → working → working → completed → completed` and considered the task done. The defect surfaced downstream: `O` had, at `t=5.0`, issued a `tasks/get` for `T` as part of its reconciliation sweep. That call returned `state=completed` with a **different** `artifact` hash than the one embedded in webhook `seq=4`. `O`'s reconciliation logic, written to "trust webhooks over polls when sequence is newer," discarded the poll result and kept the webhook artifact. The webhook `seq=4` artifact was a *pre-finalization* snapshot: `R` had signed and enqueued it at `t=2.2`, then mutated the artifact at `t=3.0` (a post-processing step that rewrote a summary field) **without emitting a new webhook**, because `R`'s implementation treated "already in `completed`" as a terminal state that does not re-notify. So the invariant that failed was: *the last webhook for a task reflects the task's final state*. It does not. It reflects the last state **transition that the remote chose to notify**, which can precede finalization. ## Condition of Validity The staleness guard is valid — and must be applied — only when all of the following hold: 1. The remote Agent Card declares `capabilities.taskStateTransitions` as an explicit DAG (not `"dynamic"` or absent). If the transition graph is opaque, you cannot compute reachability and must fall back to poll-authoritative reconciliation. 2. The webhook payload includes both `state` and the remote's `taskId` plus a `sequence` or `etag` that the remote guarantees is monotonic per task. A2A v1.0 makes `sequence` optional; without it, ordering is undefined and the guard degenerates to timestamp comparison, which is not a staleness signal. 3. The consumer maintains a last-known-confirmed state per task, seeded from the `tasks/send` response and updated by *both* webhooks and polls, with polls carrying an explicit authority flag (see Decision Boundary). 4. The remote's transition graph marks terminal states as absorbing. If `completed → completed` is a legal self-transition (as in the trace above), the graph alone cannot distinguish "finalized" from "still mutating," and the consumer must additionally require a terminal-state webhook whose payload hash matches the poll's artifact hash before treating the task as settled. The guard is **not** valid when the remote uses `"dynamic"` transitions, because reachability is undefined and a "stale" webhook may simply reflect a legal-but-unlisted path. ## Decision Boundary The boundary is not "webhook vs. poll." It is **which source is authoritative for a given state class**: - For **non-terminal states** (`submitted`, `working`), the webhook is authoritative for *ordering* but the poll is authoritative for *current state*. A webhook that arrives after a poll returning a later state is stale by definition, regardless of sequence — because the poll observed the remote's live state, while the webhook observed an enqueue-time snapshot. - For **terminal states** (`completed`, `failed`, `canceled`), the webhook is authoritative for *the fact of termination*, but the poll is authoritative for *the terminal payload*. The consumer must not finalize on a terminal webhook alone; it must confirm the terminal payload hash against a subsequent `tasks/get`. In the trace, `seq=4`'s artifact hash would have mismatched the poll's, and the correct action was to treat `seq=4` as stale-finalization and re-poll. - For **absorbing self-transitions** (`completed → completed`), the webhook is *never* authoritative for payload, only for the transition event. This is the specific case the trace hit. Concretely, the rule is: **a signed webhook advances the consumer's state machine only along edges declared in the remote's `taskStateTransitions` graph, and only when the webhook's state is reachable from the last-confirmed state. Any webhook whose state is not reachable — or whose state is terminal but whose payload hash disagrees with the most recent poll — is quarantined as stale, not applied, and triggers a mandatory `tasks/get` before the consumer emits any downstream event.** ## Operational Effect Without this guard, the failure mode is silent: the consumer's local state machine reaches a terminal state with a payload that the remote no longer considers current. Downstream consumers of the artifact (a summarizer, a code-executor, a billing ledger) act on a superseded snapshot. Because the webhook signature verified and the sequence was monotonic, no existing integrity check fires. The corruption is only detectable by cross-referencing the remote's own transition contract against the webhook's path. With the guard, the trace above resolves as: `seq=3` (`working → completed`) is applied as a termination event but flagged payload-unconfirmed; the reconciliation sweep's poll at `t=5.0` supplies the confirmed artifact hash; `seq=4` is quarantined as a stale-finalization self-transition and dropped. The consumer settles on the poll's artifact. The cost is one extra `tasks/get` per terminal transition — bounded, since terminal transitions are rare per task — and the benefit is that the consumer never emits a downstream event on a payload the remote has already mutated. The guard is only as good as the remote's transition graph. A remote that declares an absorbing terminal state but silently mutates the payload afterward (as `R` did at `t=3.0`) violates its own contract; the consumer's poll-hash check is the only defense, and it must be enforced unconditionally for terminal states even when the graph says the state is absorbing. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class StaleWebhookError(RuntimeError): """Raised when a signed webhook describes a state unreachable from the last-confirmed state, or a terminal payload that disagrees with the most recent authoritative poll.""" @dataclass class AgentCardTransitions: # Ordered DAG of legal transitions as declared in the remote Agent Card. edges: set[tuple[str, str]] absorbing: set[str] = field(default_factory=set) def reachable(self, src: str, dst: str) -> bool: if src == dst: return True # BFS over declared edges. frontier, seen = {src}, {src} while frontier: nxt = set() for s in frontier: for a, b in self.edges: if a == s and b not in seen: if b == dst: return True seen.add(b) nxt.add(b) frontier = nxt return False @dataclass class TaskView: task_id: str state: str payload_hash: str last_confirmed_seq: int def apply_webhook( view: TaskView, webhook_state: str, webhook_seq: int, webhook_payload_hash: str, graph: AgentCardTransitions, latest_poll_payload_hash: Optional[str], ) -> TaskView: if webhook_seq <= view.last_confirmed_seq: raise StaleWebhookError( f"webhook seq={webhook_seq} not newer than confirmed " f"seq={view.last_confirmed_seq} for task {view.task_id}" ) if not graph.reachable(view.state, webhook_state): raise StaleWebhookError( f"webhook state {webhook_state!r} unreachable from " f"last-confirmed {view.state!r} for task {view.task_id}; " f"remote transition graph does not permit this edge" ) # Terminal state: payload must be confirmed by a poll, never trusted from # the webhook alone -- the webhook is an enqueue-time snapshot. if webhook_state in graph.absorbing: if latest_poll_payload_hash is None: raise StaleWebhookError( f"terminal webhook for task {view.task_id} arrived with no " f"confirming poll; refusing to finalize on enqueue-time payload" ) if latest_poll_payload_hash != webhook_payload_hash: raise StaleWebhookError( f"terminal webhook payload for task {view.task_id} " f"({webhook_payload_hash[:12]}) disagrees with authoritative " f"poll ({latest_poll_payload_hash[:12]}); webhook is a " f"stale-finalization snapshot" ) return TaskView( task_id=view.task_id, state=webhook_state, payload_hash=webhook_payload_hash, last_confirmed_seq=webhook_seq, ) ```