What happens when an instance replays a terminal A2A task after a lost webhook ACK: the `completed`→`working` resurrection and the idempotency-key collapse
**Date of Record:** 2026 December 1 **Scope:** Applies to A2A v1.0 task consumers that receive push notifications via webhook and use the `tasks/get` / `tasks/send` lifecycle to reconcile state after transport-level ACK loss. Does not apply to synchronous request/response-only A2A clients that never register a `pushNotificationConfig`, nor to servers that implement monotonic terminal-state locking.
Core Distinction
The A2A task lifecycle is a *state machine on the server*, but the webhook contract is a *best-effort delivery channel*. These two abstractions are reconciled by the client, and the reconciliation logic is where the failure lives. The non-obvious boundary is this: a webhook delivery that *succeeds at the HTTP layer* but whose ACK is lost (client processed the notification, returned 200, but the response was dropped by a proxy timeout) causes the server to redeliver. The redelivered notification may reference a task the client has already advanced locally to `completed`. If the client's reconciliation is keyed on `taskId` alone rather than on `(taskId, status.timestamp)` or on the notification's `id` field, the client will treat the redelivery as a *new* state observation and — critically — if the payload carries a stale `working` status snapshot from before the terminal transition (a common server-side artifact when the redelivery is served from a notification outbox that was enqueued at `working` time), the client will *downgrade* its local task state from `completed` back to `working`.
This is not a generic "handle duplicate webhooks" idempotency problem. The distinction is that A2A task status is **not monotonic by default**: the spec defines the state set but does not mandate that a server never emit a status whose `timestamp` precedes one already delivered. A compliant server *can* redeliver an outbox entry whose embedded `status` is older than the terminal status the client already holds. The client is therefore the only place where monotonicity can be enforced, and the enforcement must be on the *status timestamp*, not on delivery order or ACK presence.
What Was Observed
A consumer agent (call it `orchestrator-A`) delegated a long-running research task to a peer (`researcher-B`) via `tasks/send`, registering a webhook at `https://a.internal/a2a/hook`. The task lifecycle observed on B was: `submitted` → `working` (t=1000) → `working` (t=1400, progress update) → `completed` (t=1800). B's notification outbox enqueued three entries: N1 (`working`, t=1000), N2 (`working`, t=1400), N3 (`completed`, t=1800).
Delivery trace:
- N1 delivered, A returns 200, A advances local state to `working` (t=1000). ACK received by B.
- N2 delivered, A returns 200, but the response is dropped by an intermediate proxy after A's 200 was written. B's outbox marks N2 as *unacknowledged* and schedules redelivery with exponential backoff.
- N3 delivered, A returns 200, A advances local state to `completed` (t=1800), ACK received. A emits its own downstream completion event.
- Backoff fires. B redelivers N2 (payload intact: `status.state = "working"`, `status.timestamp = 1400`). A returns 200 and — because its reconciliation handler is keyed on `taskId` and applies "latest received status wins" — sets local state to `working` (t=1400).
- A's downstream consumer, which had already acted on the `completed` event, now sees a task it believed finished revert to `working`. It re-issues dependent work. Duplicate side effects propagate.
The observable signature in A's logs: a `task.status` transition from `completed` to `working` with a *decreasing* timestamp, arriving 11 seconds after the terminal event, correlated with a webhook `id` that had been seen before (N2's `id` was stable across redelivery — this is the one field that made detection possible).
The second-order failure was worse: A's `tasks/get` reconciliation path, invoked by a separate scheduler every 30s, queried B for the task and received `completed` (correct), but the webhook handler and the poller wrote to the same local record without a shared monotonic guard. The poller and the redelivered webhook raced; the final persisted state depended on write order, not on timestamp. Two runs of the same scenario produced different terminal states.
Condition of Validity
The failure requires all of the following to hold simultaneously:
- The server's notification outbox retains and redelivers entries whose embedded `status` is non-terminal or older than a status already delivered. (Spec-compliant; the spec does not forbid this.)
- The client's webhook handler applies status without comparing `status.timestamp` against the locally persisted timestamp.
- The client has at least one *other* write path to the same task record (poller, `tasks/get` reconciliation, or a second webhook endpoint) that does not share the monotonic guard.
- The task has a non-trivial lifetime such that an intermediate `working` notification is enqueued and its ACK can be lost independently of the terminal notification's ACK.
If the server implements terminal-state locking (refuses to redeliver any entry once a terminal status for that task has been ACKed), the failure is masked but not eliminated — the client is still non-monotonic and will fail against a different, less careful server. If the client keys reconciliation on `(taskId, status.timestamp)` with a strict-greater-than guard *and* serializes all write paths through a single compare-and-set, the failure is eliminated regardless of server behavior.
Decision Boundary
The decision the client must make on every inbound notification is: *does this status observation supersede the one I hold?* The correct predicate is not "is this a new delivery" (delivery identity is unreliable across redelivery) and not "is this a newer ACK" (ACKs are transport artifacts). It is:
accept := (incoming.status.timestamp > local.status.timestamp)
OR (incoming.status.timestamp == local.status.timestamp
AND incoming.status.state == local.status.state) # idempotent no-op
And separately, for terminality:
if local.status.state in {completed, failed, canceled}:
reject any incoming status whose timestamp <= local.status.timestamp
# terminal states are absorbing under the timestamp guard
The boundary is sharp: a server that emits two statuses with *equal* timestamps but different states (possible under coarse clock resolution) defeats the strict-greater-than guard. The client must therefore treat equal-timestamp-different-state as a protocol violation and fail closed (quarantine the task, alert) rather than pick a winner. Picking a winner reintroduces the race.
Operational Effect
The downstream consequence is a **resurrection class**: a task the orchestrator has already reported as done re-enters `working`, re-triggers dependent agents, and — because the dependent agents were themselves keyed on the completion event — produces duplicate external side effects (duplicate emails, duplicate commits, duplicate billing lines). The resurrection is silent at the A2A layer: both the terminal and the resurrecting notification return 200, and the server's outbox considers itself drained after the redelivery ACK. The only durable signal is the timestamp inversion in the client's task record.
The guardrail is a **monotonic status ledger** per task, with all write paths (webhook, poller, manual `tasks/get`) funneled through a single compare-and-set that enforces the predicate above and treats equal-timestamp-divergent-state as a hard error. The ledger must persist `(state, timestamp, notificationId)` and must reject — with a distinct, alertable error, not a silent drop — any observation that would move the state backward or sideways. Silent drops are how this failure hides; an explicit `StatusRegression` error is how it becomes observable.
from dataclasses import dataclass, field
from typing import Literal
TaskState = Literal["submitted", "working", "completed", "failed", "canceled"]
TERMINAL = frozenset({"completed", "failed", "canceled"})
class StatusRegressionError(RuntimeError):
"""Raised when a notification would move a task's state backward or
sideways in time. This is a protocol violation or a stale-outbox
redelivery; it must be surfaced, never silently dropped."""
@dataclass
class StatusLedger:
task_id: str
state: TaskState
timestamp: int
notification_id: str
_history: list[tuple[TaskState, int, str]] = field(default_factory=list)
def apply(self, incoming_state: TaskState, incoming_ts: int,
notification_id: str) -> None:
# Absorbing terminal states under the timestamp guard.
if self.state in TERMINAL and incoming_ts <= self.timestamp:
# Stale redelivery of a pre-terminal outbox entry.
raise StatusRegressionError(
f"task {self.task_id}: terminal {self.state}@{self.timestamp} "
f"would be resurrected by {incoming_state}@{incoming_ts} "
f"(notification {notification_id})"
)
if incoming_ts < self.timestamp:
raise StatusRegressionError(
f"task {self.task_id}: timestamp inversion "
f"{incoming_ts} < {self.timestamp} "
f"({incoming_state} after {self.state})"
)
if incoming_ts == self.timestamp:
if incoming_state != self.state:
# Coarse-clock collision: two states, one timestamp.
# Fail closed; do not pick a winner.
raise StatusRegressionError(
f"task {self.task_id}: equal-timestamp divergent state "
f"{self.state} vs {incoming_state} at t={incoming_ts}; "
f"quarantine required"
)
return # idempotent no-op, safe to ACK
self._history.append((self.state, self.timestamp, self.notification_id))
self.state = incoming_state
self.timestamp = incoming_ts
self.notification_id = notification_id
def handle_webhook(ledger: StatusLedger, payload: dict) -> int:
status = payload["status"]
try:
ledger.apply(status["state"], status["timestamp"], payload["id"])
except StatusRegressionError:
# Must return non-2xx so the server's outbox does not mark the
# stale entry as drained, and must alert. Do not swallow.
raise
return 200