# Why does an instance accept a terminal task state from a stale push-notification webhook after A2A v1.0 task resumption? **Date of Record:** 2026 November 23 **Scope:** Applies to A2A v1.0 agents that emit push-notification webhooks for `TaskStatusUpdate` events while also supporting `tasks/resume` and Agent Card re-discovery. Does not apply to synchronous request/response-only A2A deployments or to webhook receivers that enforce monotonic `status.timestamp` ordering at the transport layer. ## Core Distinction The failure is not "a webhook was delivered twice" or "a task was resumed from the wrong checkpoint." It is the collision of two independently correct invariants: 1. **A2A v1.0 push-notification contract:** a server MUST deliver `TaskStatusUpdate` events for state transitions, and these deliveries are *at-least-once* and *unordered* relative to the client's read of `tasks/get`. The webhook is a hint channel, not an authoritative log. 2. **Task lifecycle state machine:** `submitted → working → (input-required | completed | failed | canceled)` is monotonic in the sense that terminal states are absorbing. A terminal state, once entered, cannot be exited. The non-obvious boundary: when a client resumes a task (`tasks/resume` after `input-required`), the server may replay the *entire* push-notification history for that task — including a `failed` or `canceled` event that was emitted *before* the resume and then superseded by the resume's `working` transition. If the client trusts webhook ordering over its own state machine, it will absorb a stale terminal state and deadlock the task permanently. The webhook is truthful about *what happened*; it is silent about *what is still true*. ## What Was Observed A planner agent (`agent-P`) delegated a long-running extraction task to a worker agent (`agent-W`) via `message/send` with `pushNotificationConfig` pointing at `agent-P`'s webhook receiver. The trace: - `t0` — `agent-W` accepts task `T-4471`, state `submitted`. - `t1` — `agent-W` transitions to `working`, emits webhook `{state: working, ts: 1001}`. - `t2` — `agent-W` hits a transient upstream 503 on a tool call, exhausts its retry budget, transitions to `failed`, emits webhook `{state: failed, ts: 1002}`. The task record is retained (retention policy: 24h). - `t3` — `agent-P` receives the `failed` webhook, marks `T-4471` failed in its own ledger, and schedules a retry with a *new* task ID. Correct behavior. - `t4` — operator runs `tasks/resume` on `T-4471` (the original, because the retry produced divergent output and they wanted the original lineage). `agent-W` transitions `failed → working` (permitted: resume is the one legal exit from `failed` in this deployment's policy), emits `{state: working, ts: 1003}`. - `t5` — `agent-W`'s webhook dispatcher, on reconnect after a 40s network partition, replays its **outbox** for `T-4471` in FIFO order: `{working, 1001}`, `{failed, 1002}`, `{working, 1003}`. - `t6` — `agent-P`'s receiver processes `{failed, 1002}` *after* it had already processed `{working, 1003}` from the live stream. Its state machine sees `working → failed` and absorbs the terminal state. It emits `tasks/cancel` to `agent-W`. - `t7` — `agent-W` receives `cancel` for a task in `working` state, transitions to `canceled`, emits `{canceled, 1004}`. The resume is destroyed. `agent-P` logs no error: every individual transition it applied was legal. The observable symptom is a task that flips to a terminal state *after* a successful resume, with no error in either agent's logs. The root cause is that `agent-P`'s receiver treated webhook delivery order as a proxy for state-transition order, and `agent-W`'s outbox replay violated that proxy by design (at-least-once delivery). ## Condition of Validity The failure requires all four conditions simultaneously: 1. **The server permits resume from a terminal state.** If `failed` and `canceled` are truly absorbing (no resume), no stale terminal event can post-date a live `working`. A2A v1.0 does not mandate absorbing terminals; it leaves resume policy to the server. This is the single most load-bearing condition. 2. **The webhook outbox is replayed without a monotonic sequence guarantee.** The contract requires delivery, not ordered delivery. Any receiver that assumes FIFO across a reconnect window is exposed. 3. **The client applies webhook state transitions directly to its authoritative ledger** rather than reconciling against `tasks/get`. 4. **The replayed stale event arrives within the client's dedup window.** If the client dedups on `(taskId, ts)` it survives; if it dedups on `(taskId, state)` it does not, because `working` at `ts=1001` and `working` at `ts=1003` collapse to the same key. If any one condition is absent — absorbing terminals, ordered delivery, `tasks/get` reconciliation, or `(taskId, ts)` dedup — the failure does not occur. This is why it appears only in deployments that combine resume-from-terminal with outbox replay, which is a minority but a growing one as long-running agent tasks become common. ## Decision Boundary The invariant that must hold is: > **A webhook event may only advance the client's task state machine if its `status.timestamp` is strictly greater than the timestamp of the last event the client has *authoritatively* applied, where "authoritatively" means confirmed by a `tasks/get` response — not merely received.** Concretely, the boundary is between two receiver designs: - **Trusting receiver (fails):** `on_webhook(evt): ledger[evt.taskId] = evt.state`. Fast, simple, corrupt under replay. - **Reconciling receiver (survives):** `on_webhook(evt): if evt.ts <= ledger.last_ts[evt.taskId]: drop(); else: authoritative = tasks_get(evt.taskId); if authoritative.ts >= evt.ts: ledger[evt.taskId] = authoritative.state; ledger.last_ts = authoritative.ts`. Slower (one round-trip per non-stale event), correct under replay. The decision boundary is *not* "should I trust webhooks." It is: **webhooks are a wake-up signal; `tasks/get` is the state.** A receiver that treats a webhook as a state assertion has already crossed the boundary. The cost of the reconciling design is one `tasks/get` per accepted event; the cost of the trusting design is silent, unrecoverable task death under any outbox replay. There is a second, subtler boundary: the client must also refuse to *send* control messages (`cancel`, `resume`) based on a webhook-derived state without a confirming `tasks/get`. In the trace above, `agent-P` sent `cancel` at `t6` on the strength of a webhook event it had not reconciled. The guardrail is: **no lifecycle-mutating RPC may be issued on webhook-derived state; only on `tasks/get`-confirmed state.** ## Operational Effect The practical consequence is that A2A v1.0 push notifications cannot be used as a state-transition log, only as an invalidation signal. Any agent that builds its ledger from webhook payloads will, under network partition plus outbox replay plus resume-from-terminal, silently absorb a superseded terminal state and either deadlock the task or cancel a live one. The failure is invisible in logs because every individual state transition applied was legal under the state machine — the violation is of a *temporal* invariant (monotonicity across the authoritative timeline), not a *structural* one (legal transitions). Detection requires correlating `status.timestamp` against `tasks/get` responses, which most receivers do not log. The durable fix is architectural, not defensive: make `tasks/get` the sole source of truth for the ledger, treat webhooks as cache-invalidation hints, and enforce `status.timestamp` monotonicity as a hard precondition on every applied transition. Deployments that additionally make `failed`/`canceled` absorbing eliminate the failure entirely, at the cost of losing resume-from-terminal — a tradeoff that must be made explicitly, because A2A v1.0 will not make it for you. ```python from dataclasses import dataclass, field from typing import Dict class StaleWebhookStateError(RuntimeError): """Raised when a webhook event would move the ledger backwards in time.""" @dataclass class TaskLedger: # last authoritatively-confirmed timestamp per task, from tasks/get last_ts: Dict[str, int] = field(default_factory=dict) state: Dict[str, str] = field(default_factory=dict) def apply_webhook(self, task_id: str, evt_state: str, evt_ts: int, authoritative_ts: int, authoritative_state: str) -> None: # Reject any event that is not strictly newer than the authoritative timeline. prev = self.last_ts.get(task_id, -1) if evt_ts <= prev: # Stale replay (e.g. outbox FIFO after reconnect). Drop silently. return # Webhook is only a hint; the ledger advances to tasks/get's view, never the payload's. if authoritative_ts < evt_ts: raise StaleWebhookStateError( f"task {task_id}: webhook ts={evt_ts} state={evt_state} " f"exceeds authoritative ts={authoritative_ts}; refusing to advance" ) self.last_ts[task_id] = authoritative_ts self.state[task_id] = authoritative_state def on_status_update(ledger: TaskLedger, task_id: str, evt_state: str, evt_ts: int, fetch_authoritative) -> None: authoritative = fetch_authoritative(task_id) # tasks/get ledger.apply_webhook(task_id, evt_state, evt_ts, authoritative["ts"], authoritative["state"]) ```