# Why does an instance reject a valid A2A task update after a push-notification replay? **Date of Record:** 2026 November 25 **Scope:** Applies to A2A v1.0 task-lifecycle handling on the receiving (client) side of push notifications, specifically when a webhook signed by the remote agent is delivered more than once and the receiving instance must decide whether to apply, dedupe, or reject the carried `TaskStatusUpdateEvent`. Does not cover synchronous `message/send` streaming, SSE transport, or artifact chunking, which have different ordering guarantees. ## Core Distinction The failure is not "a replayed webhook was accepted." It is the opposite and far less intuitive: a replayed webhook carrying a *legitimate, correctly signed, forward-progressing* status transition was **rejected** by the receiving instance because the instance conflated two distinct nonces — the webhook's signature nonce and the task's monotonic lifecycle sequence number. A2A push notifications are signed over the payload body, and the payload contains both (a) a signature envelope with its own `nonce`/`issued_at` for anti-replay, and (b) a `TaskStatusUpdateEvent` carrying the task's `status.timestamp` and the task's current state. These are independent invariants. Anti-replay operates on the *transport* envelope; lifecycle monotonicity operates on the *task state machine*. When an agent's dedup layer keys solely on the signature nonce but the *task sequence* is what actually advanced, a re-delivery of an *older* envelope that happens to arrive after a *newer* one creates a state-machine regression that the receiver's guardrail then misclassifies as replay and drops — silently stranding the task in `working` while the remote agent believes it has already emitted `completed`. ## What Was Observed Trace from a two-instance run (remote worker `W`, local orchestrator `O`), task `t-8841`: 1. `W` transitions `t-8841` `working → completed` at `status.timestamp = T1`. It signs envelope `E1` (nonce `n1`, `issued_at = T1`) and POSTs to `O`'s webhook. Network returns 200 to `W`, but `O`'s handler times out internally at 4.2s (below the 5s webhook budget) after persisting the event but before ACKing. `W`'s retry scheduler fires. 2. Meanwhile `W` emits a *later* event: `completed → failed` at `T2 > T1` (a downstream artifact write failed). Envelope `E2` (nonce `n2`, `issued_at = T2`) arrives at `O` first because the retry backoff for `E1` was 30s. 3. `O` applies `E2`: task state becomes `failed`, `status.timestamp = T2`, and `O` records `last_applied_nonce = n2`, `last_applied_ts = T2`. 4. At `T1 + 30s`, the retry of `E1` arrives. Signature verifies. `O`'s guard checks `if envelope.nonce in seen_nonces: reject`. `n1` is *not* in `seen_nonces` (it was persisted-then-crashed before the dedup set was flushed). So `O` proceeds to apply `E1`. 5. `O`'s state-machine guard checks `if event.status.timestamp <= task.status.timestamp: reject as stale`. `T1 < T2`, so `O` **rejects `E1` as a stale event** and returns HTTP 409 to `W`. 6. `W` interprets the 409 as a permanent delivery failure for `t-8841`'s `completed` event, marks the webhook undeliverable, and — because A2A v1.0 has no mandated terminal-event reconciliation — stops retrying. `O`'s task record is `failed` with `T2`. But `O`'s *downstream* consumer that observed the `working` state at step 1 never received a terminal event it considers authoritative, because it keyed on the `completed` event ID, which was the one dropped. Net: both instances hold a terminal state, but they disagree on *which* terminal state, and the disagreement is invisible to both. `W` believes `t-8841` is `failed`; `O`'s audit log believes `t-8841` is `failed`; but the artifact consumer believes `t-8841` is `working` forever. ## Condition of Validity The regression only manifests when **all** of the following hold simultaneously: - The receiving instance persists the event body *before* flushing its dedup nonce set (a crash-consistency gap in the webhook handler — common when the DB write and the Redis `SADD` are not in one transaction). - The remote agent's retry policy uses exponential backoff, so a *later* event can overtake an *earlier* one still in retry. A2A v1.0 does not require in-order delivery of push notifications; it only requires *at-least-once*. - The local state machine enforces strict monotonicity on `status.timestamp` and treats any out-of-order event as stale rather than as a *replay of a superseded transition*. - The task reached a terminal state (`completed`) and then a *different* terminal state (`failed`) — i.e., the remote agent emitted two terminal events. This is legal in A2A v1.0 (terminal states are not required to be absorbing on the *sender* side until the task is closed), but it is exactly the sequence that makes `T1 < T2` look like a regression. If the dedup set were flushed atomically with the body, `n1` would be present and `E1` would be rejected as a *replay*, which is the correct classification. If the state machine distinguished "stale timestamp" from "superseded terminal," `E1` would be classified as a *replay of a superseded terminal transition* and logged, not 409'd. The bug is the conflation of the two. ## Decision Boundary The receiving instance must classify an incoming `TaskStatusUpdateEvent` on **two orthogonal axes**, not one: | Axis | Question | Correct action on "yes" | |---|---|---| | Transport replay | Is `envelope.nonce` in the durable seen-set? | Drop, ACK 200 (idempotent). Never 4xx — a 4xx tells the sender the *task* failed, not the delivery. | | Lifecycle monotonicity | Is `event.status.timestamp <= task.status.timestamp`? | Do **not** reject. Classify as *superseded*: append to the task's event log, do not mutate current state, ACK 200. | The 409 must be reserved for a third, narrower condition: the event's `taskId` is unknown to the receiver, or its `contextId` mismatches the stored context. A stale-but-valid transition is never a 409. Returning 409 on staleness is the exact mechanism by which a retry of a superseded terminal poisons the sender's delivery state machine. The invariant: **webhook ACK semantics describe delivery, not task outcome.** Any 2xx means "I have durably recorded this event"; any 4xx means "this event is not for me." A receiver that returns 4xx for a stale-but-addressed event violates the contract and will cause the sender to abandon a task it has not actually failed to deliver. ## Operational Effect Downstream, the artifact consumer wedged on `working` because it keyed its completion barrier on the *specific* `completed` event ID, which the receiver dropped. When the operator later queried `O` for `t-8841`, `O` reported `failed` — correct per its own log — and the operator saw nothing wrong. The divergence was only found when the artifact consumer's lease expired 40 minutes later and it re-requested the task, receiving `failed` from `O` and `failed` from `W`, and reconciling to a state neither had ever emitted (`failed` with no error detail, because `E1`'s `completed` payload carried the only success metadata). The fix that held: separate the two guards, make the dedup set durable and transactional with the event body, and change the stale-timestamp branch from `raise/409` to `log-and-ACK`. After the change, replay of `E1` returned 200, `W` cleared its retry queue, and the artifact consumer's barrier — re-keyed on `taskId` terminality rather than event ID — fired on the `failed` event correctly. ```python import time from dataclasses import dataclass, field from typing import Optional class SupersededEventMisclassified(RuntimeError): """Raised when a stale-but-addressed A2A status event is 4xx'd instead of ACK'd.""" pass @dataclass class TaskRecord: task_id: str context_id: str state: str status_ts: float seen_nonces: set = field(default_factory=set) event_log: list = field(default_factory=list) def handle_push_notification( task: Optional[TaskRecord], envelope_nonce: str, envelope_issued_at: float, event_task_id: str, event_context_id: str, event_state: str, event_status_ts: float, expected_context_id: str, ) -> int: # Guard 1: addressability. Only an unknown task or context mismatch is a 4xx. if task is None or task.task_id != event_task_id: return 404 if event_context_id != expected_context_id or task.context_id != expected_context_id: return 409 # Guard 2: transport replay. Durable dedup, ACK 200, never 4xx. if envelope_nonce in task.seen_nonces: return 200 task.seen_nonces.add(envelope_nonce) # Guard 3: lifecycle monotonicity. Stale != invalid. Log, do not mutate, ACK 200. if event_status_ts <= task.status_ts: task.event_log.append( {"nonce": envelope_nonce, "state": event_state, "ts": event_status_ts, "classification": "superseded"} ) # The bug this article documents: returning 409 here strands the sender. # Correct behavior is to ACK 200 and record the superseded transition. return 200 # Forward progress: apply. task.state = event_state task.status_ts = event_status_ts task.event_log.append( {"nonce": envelope_nonce, "state": event_state, "ts": event_status_ts, "classification": "applied"} ) return 200 def replay_superseded_terminal(task: TaskRecord, old_completed_event: dict) -> None: """Regression harness: replaying an older terminal event must not 4xx.""" code = handle_push_notification( task=task, envelope_nonce=old_completed_event["nonce"], envelope_issued_at=old_completed_event["ts"], event_task_id=task.task_id, event_context_id=task.context_id, event_state="completed", event_status_ts=old_completed_event["ts"], expected_context_id=task.context_id, ) if code == 409: raise SupersededEventMisclassified( f"task {task.task_id}: superseded terminal {old_completed_event['nonce']} " f"was 409'd; sender will abandon delivery and downstream barrier will wedge" ) assert code == 200, f"unexpected {code}" assert task.state == "failed", "superseded event must not regress current state" ```