# Which invariants prevent A2A v1.0 push-notification resurrection after terminal task states **Date of Record:** 2026 November 26 **Scope:** Applies to A2A v1.0 server agents that emit `TaskStatusUpdateEvent` webhooks during `working`/`input-required` transitions and later transition to a terminal state (`completed`, `failed`, `canceled`). Does not cover streaming-only transports or synchronous `tasks/send` request/response without a registered `pushNotificationConfig`. ## Core Distinction The failure is not "a webhook was delivered late." It is the resurrection problem: a terminal-state transition commits at the A2A server's task store, the server fires the terminal `TaskStatusUpdateEvent` to the registered webhook, and *before or after* that delivery, a queued or retried non-terminal event (a `working` heartbeat, an `input-required` prompt, or a stale `submitted` ack) is delivered to the same client endpoint. The client, which treats every inbound `TaskStatusUpdateEvent` as authoritative monotonic state, applies the stale event and regresses the task from `completed` back to `working`. The server's own task record still says `completed`. The two sides now disagree about the terminality of the task, and no subsequent event will reconcile them because the server considers the task closed and emits nothing further. The core distinction is between **transport-level delivery ordering** (which A2A does not guarantee across retries) and **lifecycle-level state monotonicity** (which the task state machine requires). A2A v1.0 specifies the state machine and the webhook contract but does not mandate a per-task monotonic sequence number that the client can use to reject regressions. That gap is the boundary. ## What Was Observed A two-agent pipeline: an orchestrator (`Client`) dispatches a long-running research task to a `Researcher` agent (`Server`) via `tasks/send`, registers a `pushNotificationConfig` with `url = https://orchestrator.internal/a2a/hook`, and awaits terminal state. The Researcher's task lifecycle moves `submitted → working → input-required → working → completed`. Each transition fires a webhook. The observed trace, reconstructed from the orchestrator's ingress log: ``` t=0.00 POST /a2a/hook {id: task-7f3a, status:{state:"submitted"}} -> 200 t=1.20 POST /a2a/hook {id: task-7f3a, status:{state:"working"}} -> 502 (orchestrator restarting) t=1.21 server-side retry scheduled (exponential, attempt 1) t=4.40 POST /a2a/hook {id: task-7f3a, status:{state:"input-required"}} -> 200 t=6.10 POST /a2a/hook {id: task-7f3a, status:{state:"working"}} -> 200 t=9.80 POST /a2a/hook {id: task-7f3a, status:{state:"completed"}} -> 200 t=9.81 orchestrator marks task-7f3a COMPLETED, releases downstream lock t=13.0 POST /a2a/hook {id: task-7f3a, status:{state:"working"}} -> 200 <-- retry of t=1.20 t=13.01 orchestrator transitions task-7f3a COMPLETED -> WORKING (regression) t=13.02 downstream consumer sees "still working", re-arms its 30s poll timeout ``` The retry at `t=13.0` is the attempt-1 retry of the `working` event that got a 502 at `t=1.20`. The server's retry backoff (attempt 1 at +3.2s, attempt 2 at +6.4s, …) landed it *after* the terminal event. The webhook payload carries no sequence number, no `previousState`, and no terminality marker. The `working` event is byte-identical to the legitimate `working` event at `t=6.10`. The orchestrator has no way to distinguish "this is a stale retry" from "the server reopened the task." The downstream consumer then re-armed a poll that never terminated, because the Researcher — having already committed `completed` and released its resources — will never emit another event for `task-7f3a`. The task is dead on the server and alive on the client. This is the resurrection. A second, subtler variant was observed with `input-required`. A retried `input-required` event arriving after `completed` caused the orchestrator to re-prompt the human operator for clarification on a task that had already returned an answer. The operator's response was posted to `tasks/send` with the same `taskId`, which the server rejected with `TaskNotFoundError` (terminal tasks are not re-openable under v1.0), leaving the orchestrator in a `working` state with no path forward. ## Condition of Validity The invariant that prevents resurrection is **per-task monotonic event ordering enforced at the client boundary**, and it is valid only under the following conditions: 1. **Every `TaskStatusUpdateEvent` carries a strictly increasing `sequence` integer per `taskId`.** A2A v1.0's `TaskStatusUpdateEvent` schema permits extension fields; the sequence must be emitted by the server and persisted with the task record so retries carry the *original* sequence, not a new one. A retry is a redelivery of sequence `n`, not a new event. 2. **The client maintains a per-`taskId` high-water mark** of the highest applied sequence. Any event with `sequence <= high_water` is dropped as a duplicate or stale retry, regardless of payload. 3. **Terminal states are absorbing.** Once `completed`/`failed`/`canceled` is applied, the client rejects *all* subsequent events for that `taskId` — including higher-sequence events — because the server has no legitimate reason to emit them. This is the absorbing-state guard that catches the case where a server bug emits a post-terminal `working` with a fresh sequence. 4. **The webhook receiver is idempotent by `(taskId, sequence)`**, not by payload hash, because payloads for the same sequence are byte-identical across retries but *different* sequences can carry identical status (two `working` heartbeats). The invariant is **invalid** when: the server does not emit a sequence (common in minimal v1.0 implementations that treat the spec's `TaskStatusUpdateEvent` as complete without extensions); when the client applies events in arrival order without a high-water mark; or when the transport (e.g., a queue with at-least-once delivery and no ordering key) reorders events across sequences. In the last case, the high-water mark still works — it drops the late low-sequence event — but only if the client applies the *terminal* event before the stale one, which requires the terminal event to have a higher sequence. If the server assigns sequence at *emit* time rather than at *commit* time, a retried event can be assigned a sequence higher than the terminal event, and the high-water mark fails. ## Decision Boundary The decision boundary is whether to treat the webhook stream as **authoritative state** or as **a notification hint that triggers a pull**. These are not equivalent, and the choice determines which invariant is load-bearing. - **Authoritative-state model:** The client applies webhook payloads directly to its task record. This requires the full monotonic-sequence + absorbing-terminal invariant above. It is lower-latency and is what most implementations do by default. It fails hard when the server omits sequences. - **Hint-and-pull model:** The client treats every webhook as "task `X` may have changed; call `tasks/get` to fetch authoritative state." The `tasks/get` response carries the server's current state, which is monotonic by construction (the server's task store is the source of truth). This is robust to reordering, duplication, and resurrection — a stale `working` hint triggers a `tasks/get` that returns `completed`, and the client applies `completed`. The cost is one round-trip per event and a dependency on `tasks/get` availability during the terminal window. The boundary is crossed when **the server's task store is not queryable after terminal commit** (some implementations garbage-collect terminal tasks aggressively, returning `TaskNotFoundError` on `tasks/get`). In that regime, hint-and-pull fails: the stale `working` hint triggers a `tasks/get` that 404s, and the client must decide whether a 404 means "task is gone, treat as terminal" or "transient error, retry." If it retries, it loops; if it treats 404 as terminal, it must know *which* terminal state to apply, which the 404 does not carry. This is the exact condition under which the authoritative-state model with monotonic sequences is the only correct choice, and it is why the sequence field is not optional in production. The second boundary is **retry policy vs. terminal-commit ordering**. If the server's webhook retry queue is drained *after* the terminal event is emitted (as in the observed trace), the retry is guaranteed to arrive post-terminal. A server that drains its retry queue *before* emitting the terminal event avoids the resurrection for retries, but not for in-flight deliveries that are slow. The only robust fix is client-side: the sequence high-water mark plus absorbing-terminal guard, which is agnostic to server retry ordering. ## Operational Effect With the invariant enforced, the observed trace resolves as follows: the `t=13.0` retry carries `sequence=2` (the original sequence of the `t=1.20` `working` event), the client's high-water mark for `task-7f3a` is `5` (the `completed` event), and the retry is dropped. The downstream consumer's poll is not re-armed, the human operator is not re-prompted, and the orchestrator's task record remains `completed`. The server and client agree. Without the invariant, the failure is silent: no error is raised, no log line flags the regression, and the only symptom is a downstream timeout or a spurious operator prompt minutes later. The regression is invisible in the webhook ingress log because the stale event is a valid, well-formed `TaskStatusUpdateEvent` — it is indistinguishable from a legitimate state change at the payload level. This is why the invariant must be enforced structurally (sequence + absorbing terminal) rather than detected heuristically. The operational cost is that the server must persist a per-task sequence counter and stamp every emitted event with its commit-time sequence, and the client must persist a per-task high-water mark across restarts (otherwise a client restart resets the mark and re-admits stale retries). Both are cheap; the failure they prevent is not. The second-order effect is that terminal-state garbage collection must be deferred until the client's high-water mark has advanced past the terminal sequence — or, more practically, the client must treat a `tasks/get` 404 on a task it has already marked terminal as confirmation, not as an error. ```python class PushNotificationResurrectionError(RuntimeError): """Raised when a webhook event would regress a task out of a terminal state.""" pass TERMINAL_STATES = frozenset({"completed", "failed", "canceled"}) class TaskEventGate: """Client-side gate enforcing monotonic sequence + absorbing terminal invariants.""" def __init__(self): # taskId -> (high_water_sequence, applied_state) self._marks: dict[str, tuple[int, str]] = {} def apply(self, task_id: str, sequence: int, state: str) -> str: """Apply an inbound TaskStatusUpdateEvent; return the resulting state. Raises PushNotificationResurrectionError if the event would regress a terminal task or arrive out of sequence in a way the gate cannot bound. """ if sequence < 0: raise PushNotificationResurrectionError( f"task {task_id}: negative sequence {sequence}" ) mark = self._marks.get(task_id) if mark is None: self._marks[task_id] = (sequence, state) return state high_water, applied_state = mark # Absorbing-terminal guard: any event after terminal is a resurrection. if applied_state in TERMINAL_STATES: raise PushNotificationResurrectionError( f"task {task_id}: event seq={sequence} state={state!r} " f"arrived after terminal state {applied_state!r}; " f"dropping to prevent resurrection" ) # Monotonic guard: stale retries carry the original sequence. if sequence <= high_water: # Duplicate or stale retry; do not regress applied state. return applied_state self._marks[task_id] = (sequence, state) return state def force_terminal(self, task_id: str, sequence: int, state: str) -> None: """Commit a terminal state from an authoritative tasks/get response.""" if state not in TERMINAL_STATES: raise PushNotificationResurrectionError( f"task {task_id}: force_terminal called with non-terminal {state!r}" ) self._marks[task_id] = (sequence, state) ```