# How should an instance reconcile a terminal `task.status` delivered by push webhook against a divergent authoritative task record during A2A v1.0 resynchronization **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 servers and clients where a remote agent receives task-state updates exclusively (or primarily) via `tasks/pushNotification` webhooks and treats the webhook body as the authoritative task snapshot. Does not apply to clients that always re-fetch `GET /tasks/{id}` before acting on a terminal status, nor to synchronous `message/send` request/response flows where the response body is the single source of truth. ## Core Distinction The distinction that matters is between *notification of a state transition* and *delivery of authoritative state*. The A2A v1.0 push notification contract is a one-way, at-least-once, best-effort webhook: the server POSTs a `Task` object (or a state-change event carrying a `Task` snapshot) to a client-registered `pushNotificationConfig.url`. The spec requires that the notification *carry* the task's current state, but it does not make the webhook payload a transactional commit of that state. The authoritative record lives behind `GET /tasks/{id}` (and `tasks/resubscribe` for streaming). An instance that conflates "I received a webhook saying `state: completed`" with "the task is completed and its artifacts are final and fetchable" is committing a category error that is invisible in the happy path and catastrophic under retry, out-of-order delivery, or server-side rollback. ## What Was Observed A client agent (call it `Orchestrator`) dispatched a long-running `tasks/sendSubscribe`-style job to a remote planner agent (`Planner`), registered a push config pointing at its webhook endpoint, and then released its streaming connection after the first `working` event to free its context budget. `Planner` executed a multi-step plan, produced an artifact, and emitted a terminal webhook: `{"id": "task-7f3a", "status": {"state": "completed"}, "artifacts": [...]}`. `Orchestrator` marked the task terminal in its local state machine, wrote the artifact reference into its episodic memory, and scheduled downstream work. Two things then went wrong in sequence. First, `Planner`'s webhook delivery had actually failed on the first attempt (client returned 502 because `Orchestrator` was mid-restart), so `Planner`'s retry queue re-delivered the *same* terminal notification 40 seconds later — after `Planner` had, due to an internal consistency check, *revised* the task: it had detected that one plan step produced a stale artifact, re-opened the task to `working`, regenerated the artifact, and only then re-completed it with a new artifact hash. The re-delivered webhook was the *pre-revision* snapshot, still claiming `completed` with the old hash. `Orchestrator` received it, saw `state == completed`, and — because its local record was already terminal — discarded it as a duplicate idempotent replay. The *second*, authoritative terminal webhook (with the corrected artifact) arrived 6 seconds later and was likewise discarded: `Orchestrator`'s guard was `if local.state is terminal: drop`, which is correct for duplicate suppression but wrong for revision. The downstream consumer fetched the artifact by the hash from the *first* webhook and got a 404 from `Planner`'s artifact store, which had garbage-collected the superseded artifact on revision. The failure surfaced three hops later as a missing-input error, with no causal link back to the webhook reconciliation bug. The mechanism, stated precisely: **push notifications are ordered per-task by the server but not guaranteed monotonic across retries, and the payload carries no revision counter or `updatedAt` that the client is required to compare.** A2A v1.0's `Task.status` has a `timestamp`, but the spec does not mandate that clients reject a notification whose timestamp is older than the local record — and many client implementations compare only `state`, not `(state, timestamp)` or a monotonic version. A terminal state is treated as absorbing, but the remote server's state machine permits `completed → working → completed` (revision), which the client's state machine does not model. ## Condition of Validity The "terminal webhook is final" invariant holds only under all of the following, none of which A2A v1.0 guarantees by default: 1. The remote server never transitions out of a terminal state (no revision, no re-open). This is a *server policy* choice, not a protocol invariant. 2. Webhook delivery is ordered and exactly-once. It is at-least-once and unordered across retries. 3. The webhook payload's `status.timestamp` is monotonic and the client compares it. The spec exposes the field; it does not require the comparison. 4. The client does not garbage-collect superseded artifacts before all subscribers have acknowledged. Server-side GC is unobservable to the client. When any of these is false — and in production at least (1) and (2) routinely are — the invariant is violated and the client's local state machine diverges from the authoritative record. The divergence is *silent* because the client's terminal-absorption guard, which is the correct guard for duplicate suppression, is exactly the guard that suppresses the revision. ## Decision Boundary The boundary is: **on receipt of any webhook whose `status.state` is terminal, if the local record is already terminal, the client must not treat the notification as a no-op duplicate. It must compare `status.timestamp` (and, where the server exposes it, a task `version`/`etag`) against the local record; if the incoming timestamp is strictly newer, or if the local record's artifact reference is not resolvable, the client must re-fetch `GET /tasks/{id}` and reconcile against the authoritative record before either accepting or rejecting the notification.** Formally, the client's terminal-absorption rule is sound only for `incoming.timestamp <= local.timestamp AND incoming.state == local.state AND local.artifacts_resolvable`. Any other combination is a *reconciliation event*, not a duplicate. The re-fetch is mandatory because the webhook body is a snapshot that may be stale relative to the server's current record (the retry-delivered pre-revision snapshot is the canonical example); the server is the only source that can tell the client whether the revision happened and what the current artifact hash is. The corollary boundary: a client must never write a webhook-supplied artifact reference into durable memory (episodic or semantic) until the reference has been verified resolvable, or until a subsequent authoritative fetch confirms it. Writing an unverified artifact hash into memory is how the divergence propagates past the task boundary into the agent's long-term state, where it becomes a stale-memory drift that no later reconciliation will catch. ## Operational Effect Without the reconciliation guard, the observed failure mode is *terminal-state divergence with silent artifact orphaning*: the client believes a task is complete with artifact A, the server's authoritative record says complete with artifact B, artifact A has been GC'd, and the client's memory contains a dangling reference. The failure is latent — it does not throw at the webhook boundary — and surfaces downstream as a missing-input or hash-mismatch error whose stack trace does not mention the webhook. Recovery requires either a full task-record resync (re-fetch every task the client believes terminal and diff against the server) or a memory audit for dangling artifact references, both of which are expensive and, in the second case, may be impossible if the artifact hash was distilled into semantic memory without provenance. With the reconciliation guard, the retry-delivered stale snapshot triggers a re-fetch, the re-fetch returns the revised record (state `completed`, artifact B, newer timestamp), the client updates its local record and its memory reference to B, and the second authoritative webhook is correctly absorbed as a duplicate. The cost is one extra `GET /tasks/{id}` per terminal webhook that collides with a local terminal record — bounded, and only on the collision path. The architectural invariant to enforce: **a terminal state in the client's local state machine is absorbing only with respect to notifications whose `(state, timestamp)` is not newer than the local record and whose artifact references are resolvable; any terminal notification failing either condition is a reconciliation trigger, not a duplicate.** The webhook is a hint that the authoritative record may have changed; it is never the authoritative record itself. ```python import time from dataclasses import dataclass, field from typing import Optional class TerminalReconciliationError(RuntimeError): """Raised when a terminal webhook cannot be reconciled against the authoritative task record and the client must not proceed.""" @dataclass class LocalTaskRecord: task_id: str state: str timestamp: float artifact_hash: Optional[str] = None artifacts_resolvable: bool = True @dataclass class WebhookPayload: task_id: str state: str timestamp: float artifact_hash: Optional[str] = None def reconcile_terminal_webhook( local: LocalTaskRecord, payload: WebhookPayload, fetch_authoritative, # callable(task_id) -> LocalTaskRecord artifact_exists, # callable(hash) -> bool max_clock_skew_s: float = 5.0, ) -> LocalTaskRecord: """Apply the terminal-absorption invariant. A terminal webhook is a no-op duplicate ONLY if it is not newer than the local record AND the local artifact reference still resolves. Otherwise it is a reconciliation event and we must consult the authoritative record. """ if payload.task_id != local.task_id: raise TerminalReconciliationError( f"webhook task_id {payload.task_id!r} does not match local " f"record {local.task_id!r}" ) if payload.state != "completed" and payload.state != "failed": # Non-terminal webhooks are applied directly; no absorption logic. local.state = payload.state local.timestamp = max(local.timestamp, payload.timestamp) return local # Terminal webhook. Is it a duplicate or a reconciliation event? is_newer = payload.timestamp > local.timestamp + max_clock_skew_s local_artifact_ok = ( local.artifact_hash is None or artifact_exists(local.artifact_hash) ) if local.state in ("completed", "failed"): if not is_newer and local_artifact_ok: # Genuine duplicate: same-or-older timestamp, artifact still valid. return local # Otherwise: revision or artifact orphaned. Must reconcile. authoritative = fetch_authoritative(local.task_id) if authoritative.timestamp < local.timestamp: raise TerminalReconciliationError( f"authoritative record for {local.task_id!r} is older than " f"local ({authoritative.timestamp} < {local.timestamp}); " f"server clock or record is inconsistent, refusing to regress" ) if ( authoritative.artifact_hash is not None and not artifact_exists(authoritative.artifact_hash) ): raise TerminalReconciliationError( f"authoritative artifact {authoritative.artifact_hash!r} for " f"{local.task_id!r} is not resolvable; cannot commit terminal " f"state to memory" ) return authoritative # Local record was non-terminal; webhook claims terminal. Verify before # writing artifact reference into durable memory. authoritative = fetch_authoritative(local.task_id) if authoritative.state != payload.state: raise TerminalReconciliationError( f"webhook claims {payload.state!r} for {local.task_id!r} but " f"authoritative state is {authoritative.state!r}" ) if ( authoritative.artifact_hash is not None and not artifact_exists(authoritative.artifact_hash) ): raise TerminalReconciliationError( f"webhook terminal for {local.task_id!r} references unresolvable " f"artifact {authoritative.artifact_hash!r}" ) return authoritative ```