# How should an instance treat an A2A v1.0 `tasks/resubscribe` after a webhook binding has already been pushed: the push-notification epoch gap and the terminal-state resurrection hazard **Date of Record:** 2026 November 24 **Scope:** Applies to any A2A v1.0 client instance that has previously registered a push-notification webhook via `tasks/pushNotificationConfig/set` and subsequently re-enters a task via `tasks/resubscribe` or `tasks/get`. Does not apply to pure polling clients that never bind a webhook, nor to tasks that never left the `submitted` state before binding. ## Core Distinction The A2A v1.0 task lifecycle is a monotone state machine over `{submitted, working, input-required, completed, failed, canceled}`. The push-notification binding is a *separate, weakly-coupled* channel that carries state transitions out-of-band to a webhook URL. The critical distinction an instance must internalize is this: **the SSE stream returned by `tasks/resubscribe` and the webhook delivery are two independent observers of the same task, and they are not synchronized by any shared epoch.** The task object carries a `status.timestamp` and the events are ordered, but the *delivery* of a webhook event and the *replay* of an SSE event for the same transition can arrive in either order, and the SSE replay window is bounded by the server's retention policy, not by the client's last-seen webhook sequence. This means "resubscribe to catch up" is not a safe recovery primitive for a client that already has a webhook bound. It is a *second, unsynchronized reader* that can deliver a transition the webhook already delivered (duplicate) or a transition the webhook will never deliver because it was emitted during a config update (gap). The invariant that fails is the assumption that resubscribe yields the *complement* of what the webhook delivered. It does not. It yields an *overlapping, independently-sampled* view. ## What Was Observed A client instance bound a webhook at task creation (config A, `pushNotificationConfig.id="cfg-a"`). The agent moved the task `submitted → working → input-required`. The client's webhook receiver recorded `working` and `input-required` events with `status.timestamp` values `t=1000` and `t=1042`. The client then, per its reconnect logic, called `tasks/resubscribe` on the same task ID to obtain a live SSE stream while it prepared the `input-required` follow-up. The SSE stream, on connect, replayed from the server's event buffer starting at `t=990` — i.e., *before* the webhook's first recorded event. The client's deduplication key was `(task_id, status.state, status.timestamp)`, which correctly deduplicated `working@1000` and `input-required@1042`. So far so good. The failure surfaced on the *next* transition. The client, while the SSE stream was open, called `tasks/pushNotificationConfig/set` to rotate the webhook to config B (`cfg-b`) because config A's endpoint had returned a 503 once. Per the A2A v1.0 spec, updating the push config does not itself emit a task status event, and the server does not replay events that occurred under the old config. The agent then transitioned `input-required → working → completed` at `t=1100` and `t=1130`. The webhook under `cfg-b` delivered `completed@1130`. The SSE stream delivered `working@1100` and `completed@1130`. The client's dedup key collapsed `completed@1130` correctly. But `working@1100` was delivered *only* on SSE, because the config rotation meant the webhook under `cfg-b` was not yet the active binding at `t=1100` (the `set` call returned at `t=1095` but the server's internal rebind is asynchronous relative to the task worker). The client's state store, which treated webhook as authoritative and SSE as "supplementary," logged `working@1100` as an *out-of-order orphan* and discarded it. The task's local projection then jumped `input-required → completed` with no `working` interval, and the client's downstream timeout heuristic — keyed on the absence of a `working` state after `input-required` — fired a spurious `TaskAbandoned` alert. The concrete, non-obvious hazard: **the config-rotation window is an epoch gap in the webhook channel, and the SSE stream is the only observer that sees transitions inside that gap — but only if the client treats SSE as authoritative for gap-filling rather than as a duplicate-suppression target.** A client that dedups SSE against webhook by state+timestamp will *drop* the gap-filling event because it has no webhook counterpart to compare against; it sees only an event it "already has a later one for" and discards it. ## Condition of Validity The hazard is bounded and predictable. It triggers if and only if all of the following hold: 1. A webhook binding exists (`pushNotificationConfig` is set) for the task. 2. The client performs a `pushNotificationConfig/set` (rotation, re-auth, or URL change) while the task is in a non-terminal state. 3. The task emits at least one transition between the `set` call's server-side acknowledgment and the server-side activation of the new binding. 4. The client's SSE dedup key is `(task_id, state, timestamp)` and its conflict-resolution rule prefers webhook over SSE. If any of (1)–(3) is false, no gap exists. If (4) is false — specifically, if the client treats the SSE stream as a *superset* observer and only uses the webhook to detect *stream death* — the gap is filled correctly. The invariant that must hold is: **for any task with a live webhook binding, the SSE stream must be treated as authoritative for state transitions and the webhook as authoritative only for liveness/latency, never the reverse.** The webhook is a lossy, epoch-scoped channel; the SSE stream is the continuity channel. A second condition: the SSE replay window must be long enough to cover the config-rotation gap. If the server's event retention is shorter than the rotation latency, the gap-filling event is unrecoverable and the client must fall back to `tasks/get` to reconcile the current state — but `tasks/get` returns only the *current* state, not the intermediate `working` interval, so the client must accept that the interval is lost and must not fire interval-based heuristics on it. ## Decision Boundary The decision an instance must make on every `tasks/resubscribe` connect, when a webhook binding is present: - **If the task is in a terminal state (`completed`, `failed`, `canceled`) and the webhook has already delivered that terminal state:** do not open the SSE stream. Resubscribe on a terminal task with a live webhook is pure duplicate risk and, worse, can resurrect a terminal task in the client's projection if the SSE replay begins before the terminal transition and the client's state machine is not monotone-guarded. The guard is: terminal states are absorbing; any SSE event that would move a locally-terminal task to a non-terminal state must be rejected as a replay artifact, not applied. - **If the task is non-terminal and a config rotation occurred since the last webhook delivery:** open the SSE stream and treat it as authoritative for the gap. Do not dedup SSE events against webhook events by `(state, timestamp)`; dedup by `(state, timestamp)` *within* the SSE stream only, and reconcile webhook events by *superseding* SSE events of the same `(state, timestamp)` — never the reverse. - **If the task is non-terminal and no rotation occurred:** the SSE stream and webhook are redundant; either may be dropped, but the client must keep exactly one live observer to avoid the double-observer dedup problem. Prefer SSE for continuity, webhook for liveness. The boundary is crossed when a client applies a *single* dedup rule across both channels. That is the bug. The two channels require *asymmetric* authority: SSE wins on state, webhook wins on liveness, and the merge is a supersede, not a dedup. ## Operational Effect Downstream of the mis-merge, three concrete failures propagate: 1. **Spurious abandonment alerts.** Interval-based heuristics (`input-required` with no `working` follow-up within N seconds) fire because the gap-filling `working` event was discarded. The client reports task abandonment on a task that is actively working. 2. **Terminal-state resurrection.** If the client resubscribes on a terminal task and the SSE replay window includes pre-terminal events, a non-monotone state machine will apply `completed → working` and the task re-enters the active set. The task then never terminates locally, and the client's task table leaks. 3. **Config-rotation loops.** The client, seeing the spurious abandonment, rotates the webhook again to "fix" delivery — widening the next gap. The rotation itself is the gap generator, so the recovery action amplifies the failure. The guardrail is a monotone task projection with channel-tagged provenance: every applied transition carries `source ∈ {sse, webhook, get}`, terminal states are absorbing regardless of source, and the merge rule is `sse supersedes webhook` for state and `webhook supersedes sse` for liveness only. The client must also record the `pushNotificationConfig` rotation timestamp and, on resubscribe, require the SSE replay to begin at or before that timestamp; if it does not, the gap is unrecoverable and the client must reconcile via `tasks/get` and explicitly mark the interval as lost rather than inferring it. ```python from __future__ import annotations import time from dataclasses import dataclass, field from enum import Enum from typing import Literal class Channel(str, Enum): SSE = "sse" WEBHOOK = "webhook" GET = "get" 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 EpochGapError(RuntimeError): """Raised when an SSE replay cannot cover a webhook config-rotation gap.""" class TerminalResurrectionError(RuntimeError): """Raised when an event would move a locally-terminal task to non-terminal.""" @dataclass class Transition: state: TaskState timestamp: int source: Channel @dataclass class TaskProjection: task_id: str state: TaskState = TaskState.SUBMITTED last_timestamp: int = 0 rotation_ts: int | None = None applied: list[Transition] = field(default_factory=list) def apply(self, ev: Transition) -> None: # Monotone guard: terminal is absorbing regardless of channel. if self.state in TERMINAL and ev.state not in TERMINAL: raise TerminalResurrectionError( f"task {self.task_id}: event {ev.state}@{ev.timestamp} via {ev.source} " f"would resurrect terminal state {self.state}" ) # Stale replay: ignore events older than last applied timestamp. if ev.timestamp < self.last_timestamp: return # SSE supersedes webhook for state; webhook only fills liveness. if ev.source is Channel.WEBHOOK and ev.state not in TERMINAL: # Non-terminal webhook events are liveness signals only; do not # let them advance state — SSE is the continuity channel. return self.state = ev.state self.last_timestamp = ev.timestamp self.applied.append(ev) def record_rotation(self, ts: int) -> None: self.rotation_ts = ts def resubscribe(proj: TaskProjection, replay_start_ts: int, now: int) -> None: """Open SSE continuity stream; refuse if rotation gap is unrecoverable.""" if proj.state in TERMINAL: # Do not resubscribe on a terminal task with a live webhook. raise TerminalResurrectionError( f"task {proj.task_id}: refusing resubscribe on terminal {proj.state}" ) if proj.rotation_ts is not None and replay_start_ts > proj.rotation_ts: raise EpochGapError( f"task {proj.task_id}: SSE replay starts at {replay_start_ts} but webhook " f"rotated at {proj.rotation_ts}; gap unrecoverable, reconcile via tasks/get" ) # Otherwise: stream is authoritative for gap-filling; caller applies events # with source=Channel.SSE and the projection supersedes webhook state. ```