# Why does an instance accept a terminal-state push callback for a task it has already reaped **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 task lifecycles where a remote agent registers a push notification webhook via `tasks/pushNotificationConfig/set` and the caller's task store enforces terminal-state eviction. Does not cover streaming-only (`message/stream`) interactions or A2A deployments where the task record is retained indefinitely after `completed`/`failed`/`canceled`. ## Core Distinction The A2A task lifecycle has two clocks that are never synchronized by the protocol: the **caller's task-state clock** (transitions `submitted → working → input-required → completed|failed|canceled`, followed by local eviction) and the **remote agent's push-delivery clock** (an out-of-band HTTP POST to a registered webhook, fired whenever the remote agent decides the task changed state). The spec treats `pushNotificationConfig` as fire-and-forget and makes no delivery guarantee, but it also does not define the ordering between a terminal-state transition observed by the caller and a push callback describing that same transition. The failure is not "webhook lost." It is **webhook delivered after the caller has already reaped the task**, arriving as a valid, signed, correctly-addressed callback for a `taskId` the receiver no longer recognizes — and the receiver's default behavior is to either 404 it (silent loss of the terminal payload) or, worse, re-materialize a task record from the callback body and resurrect a state machine that had already been finalized. The invariant that is violated: *a task's terminal state must be monotonic and self-evidencing; no inbound message may create a task record whose terminal state was not observed by the task's own state machine.* A2A v1.0 does not enforce this. The push channel is a second writer into the same task namespace with no fencing token. ## What Was Observed A three-hop pipeline: orchestrator agent `O` dispatches a long-running research task to remote agent `R` over A2A v1.0, registering a webhook at `https://O.internal/a2a/push/{taskId}`. `R` runs for 41 minutes, transitions `working → completed`, and emits a push POST at T+41:00. `O`'s task store had a 30-minute idle reaper; because `R` never sent an interim `working` heartbeat (A2A does not mandate one, and `R`'s implementation only pushes on *state change*, not on intervals), `O` reaped the task at T+30:00 and evicted the record. At T+41:03 the push callback arrived. Three distinct receiver behaviors were observed across deployments: 1. **Hard 404.** The callback is dropped. `O`'s caller never learns the task completed; it retries `tasks/get` against `R`, which returns `completed`, and `O` reconstructs the terminal state from a poll. Operationally fine but the push channel contributed nothing — and if `O` had *only* wired the webhook (no poll fallback), the result was permanently lost. 2. **Re-materialization.** The receiver's push handler, written to "be resilient," upserts a task record from the callback's `status` field. This creates a task in state `completed` that was never `submitted` in the current store generation. Downstream consumers subscribed to `O`'s task events see a task appear already-terminal — a state transition with no antecedent. Audit replay of `O`'s task log now contains a terminal event whose predecessor is missing. 3. **Signature-valid, task-unknown.** The callback passes JWS verification against `R`'s published key (correct), the `taskId` matches the URL path (correct), but the body's `status.timestamp` (T+41:00) is *later* than the reaper's eviction tombstone (T+30:00). The handler has no rule for "valid callback predates my knowledge horizon." The distinguishing property of case 2 is that it is not an error the system reports. The task *completes successfully* from the caller's perspective. The corruption is only visible on replay: the task-event log has a terminal event with no matching `submitted` in the same generation, and any consumer that assumes "a terminal event implies a prior non-terminal event in this log" breaks. ## Condition of Validity The resurrection failure requires all of the following to hold simultaneously: - **Push-only terminal signaling.** The caller relies on the webhook for the terminal transition and does not poll, or polls on an interval shorter than the remote's execution time only by luck. - **Idle-based reaping keyed on caller-observed activity.** The reaper's clock is driven by messages *received*, not by the remote's liveness. A2A v1.0 provides no `working` heartbeat requirement, so a legitimately-running remote task is indistinguishable from a dead one from the caller's side. - **Upsert-on-callback handler semantics.** The push handler treats the callback body as authoritative task state rather than as a *claim about* task state that must be reconciled against local knowledge. - **No fencing token.** The callback carries `taskId` but no generation/epoch that the caller could use to reject a callback aimed at a reaped generation. Remove any one and the failure collapses: with polling, the terminal state is observed before eviction; with a liveness-driven reaper, the task is not reaped while `R` is alive; with insert-only (non-upsert) handler semantics, the callback 404s instead of resurrecting; with a generation token, the stale callback is rejected deterministically. The condition where the invariant *is* safe to relax: if the remote agent's push config includes a `token` (A2A allows an opaque client-supplied token echoed in the callback) that the caller rotates on every reap generation, then a callback bearing a prior generation's token is provably stale and may be discarded without ambiguity. This is the only spec-native mechanism that approximates a fence, and it is opt-in. ## Decision Boundary The boundary is not "accept or reject the callback." It is **whether the callback is allowed to be a state *writer* or only a state *hint*.** - **Writer semantics (unsafe here):** the push handler mutates the task store directly. Correct only when the store retains terminal records for longer than the maximum remote execution time, which is unbounded and therefore unprovable. - **Hint semantics (safe):** the push handler enqueues a reconciliation request: `tasks/get(taskId)` against the originating agent, then applies the result through the same state machine that owns all other transitions. The callback's body is discarded except for `taskId` and the echoed `token`. This makes the push channel a latency optimization over polling, never an authority. The decision rule an agent should encode: *if the local task record for `taskId` is absent or tombstoned, the callback MUST NOT create a record; it MUST trigger a fetch and route the fetched state through the normal admission path, which will itself reject terminal-without-antecedent.* If the fetch also 404s (remote reaped too), the callback is dropped and logged as an orphan, not materialized. A second boundary: the reaper's idle threshold must be strictly greater than the remote's *declared* maximum inter-push interval, and A2A v1.0 does not declare one. Absent that, the only sound configuration is a reaper driven by an explicit liveness probe (`tasks/get` returning non-terminal) rather than by inbound-message idleness. ## Operational Effect The practical consequence is that push notification in A2A v1.0 is a *lossy, unordered, unfenced* channel into a namespace that also has an authoritative state machine, and the two are not reconciled by the protocol. Systems that treat the webhook as authoritative exhibit **terminal-state resurrection**: a task appears already-completed in the event log with no antecedent, which breaks any downstream consumer doing causal replay, any auditor reconstructing the task's history, and any dedup layer keyed on "first terminal event wins" (it sees a terminal event for a task it has no open record of and either drops it — losing the completion — or opens a phantom). The mitigation that actually holds is to demote the push channel to a wakeup signal and make every state transition flow through one admission function that enforces the monotonicity invariant: *no record may enter a terminal state unless a non-terminal state for the same `taskId` and generation exists in the store.* Callbacks for unknown tasks become fetches; fetches for unknown tasks become orphans; orphans are logged, never materialized. This costs one extra round-trip per push and eliminates the entire class. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Protocol class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" TERMINAL = {TaskState.COMPLETED, TaskState.FAILED, TaskState.CANCELED} class TerminalResurrectionError(RuntimeError): """Raised when a state transition would place a task into a terminal state without a prior non-terminal record in the same generation, or when a push callback targets a task the store has reaped.""" @dataclass class TaskRecord: task_id: str generation: int state: TaskState history: list[TaskState] = field(default_factory=list) class RemoteAgent(Protocol): def get_task_state(self, task_id: str) -> TaskState | None: ... @dataclass class PushCallback: task_id: str claimed_state: TaskState token: str timestamp: float class TaskStore: """Enforces the monotonic-terminal invariant. Push callbacks are hints, never writers.""" def __init__(self) -> None: self._records: dict[str, TaskRecord] = {} self._tombstones: dict[str, int] = {} # task_id -> reaped generation self._current_generation = 0 def admit_transition(self, task_id: str, new_state: TaskState) -> TaskRecord: rec = self._records.get(task_id) if rec is None: if new_state in TERMINAL: raise TerminalResurrectionError( f"refusing terminal {new_state} for unknown task {task_id}: " "no antecedent non-terminal state in store" ) rec = TaskRecord(task_id=task_id, generation=self._current_generation, state=new_state, history=[new_state]) self._records[task_id] = rec return rec if rec.state in TERMINAL: if new_state != rec.state: raise TerminalResurrectionError( f"task {task_id} already terminal at {rec.state}; " f"refusing transition to {new_state}" ) return rec rec.history.append(new_state) rec.state = new_state return rec def reap(self, task_id: str) -> None: rec = self._records.pop(task_id, None) if rec is not None: self._tombstones[task_id] = rec.generation self._current_generation += 1 def handle_push(self, cb: PushCallback, remote: RemoteAgent) -> TaskRecord: """Push is a hint: reconcile via fetch, route through admission.""" if cb.task_id in self._tombstones: # Stale callback aimed at a reaped generation. Do not materialize. # Fetch to confirm; admission will reject terminal-without-antecedent. fetched = remote.get_task_state(cb.task_id) if fetched is None: raise TerminalResurrectionError( f"orphan callback for reaped task {cb.task_id}: " "remote also lacks record; dropping, not resurrecting" ) # Re-open a fresh generation with a non-terminal seed before # admitting the fetched terminal state. self.admit_transition(cb.task_id, TaskState.SUBMITTED) return self.admit_transition(cb.task_id, fetched) fetched = remote.get_task_state(cb.task_id) if fetched is None: raise TerminalResurrectionError( f"callback for {cb.task_id} but remote returns no task; " "refusing to trust callback body" ) return self.admit_transition(cb.task_id, fetched) ```