# Which invariants prevent push-notification rebinding from resurrecting a terminal A2A task after Agent Card re-discovery **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 clients and servers where a task's push-notification `webhookUrl` is bound at task creation and the remote Agent Card may be re-fetched (cache expiry, `/.well-known/agent.json` rotation, or explicit refresh) during the task's lifetime. Does not cover synchronous request/response-only agents that never bind a push channel, nor multi-hop A2A relay topologies where an intermediary rewrites `taskId`. ## Core Distinction The failure is not "webhook delivery failed." It is **identity re-resolution racing terminal state**. In A2A v1.0 a client binds a push channel by passing `pushNotification.webhookUrl` (and optionally `authentication`) at `tasks/send` or `tasks/sendSubscribe`. The server stores that binding keyed by `taskId`. Separately, the client may re-fetch the Agent Card to validate that the `capabilities.pushNotifications` flag and the card's declared `url`/`endpoints` still authorize the binding. These are two independent state machines — the **task lifecycle** (submitted → working → input-required → completed/failed/canceled) and the **card cache lifecycle** — and the invariant that must hold across them is: > A push binding may only be *created or rebound* while the task is non-terminal, and a re-fetched Agent Card may only *validate* an existing binding — never *re-authorize* delivery of a terminal task's final event. When a client (or a retrying delivery worker) treats card re-discovery as a trigger to re-assert the binding, it can re-open a `completed` task's event stream. The server, seeing a fresh `pushNotification` payload for a `taskId` it has already sealed, either (a) rejects with `TaskNotFound`/`TaskNotCancelable`-class errors that the client misreads as transient, or (b) — worse — accepts the rebind because it keys bindings by `(taskId, webhookUrl)` and the URL changed, producing a duplicate terminal event to a new endpoint while the original endpoint never got its `completed` status. The observable symptom is a task that appears to "resurrect" from `completed` back to `working` in the client's local store, or a terminal event delivered twice to two different URLs. ## What Was Observed Trace from a controlled reproduction with a conformant A2A v1.0 server: 1. Client issues `tasks/send` with `pushNotification.webhookUrl = https://a.example/hook`, `taskId = T1`. Server returns state `submitted`, stores binding `B1 = (T1, a.example)`. 2. Task progresses to `working`. The client's Agent Card cache for the remote agent expires (TTL 300s) mid-task. 3. Server finishes: emits `completed` to `a.example`. Delivery succeeds; `a.example` returns 200. Server marks binding `B1` sealed. 4. Client's card-refresh worker re-fetches `/.well-known/agent.json`, sees `capabilities.pushNotifications: true`, and — because the client's binding-reconciliation logic runs "on card change" — re-issues `tasks/sendSubscribe` for `T1` with a *new* webhook URL `https://a2.example/hook` (the client rotated its receiver). 5. Server receives a `pushNotification` payload for `T1`. Because it keys bindings by `(taskId, webhookUrl)`, `(T1, a2.example)` is a *new* key: the rebind is accepted. The server replays the terminal event to `a2.example`. The client's `a2.example` handler sees `completed` for a task its local store had already marked `completed`, and its idempotency check — keyed on `(taskId, state)` rather than `(taskId, state, eventId)` — drops it, but the *store write* for the rebind flips local state to `working` before the drop, because the client's handler assumes any inbound push implies an active binding. 6. Net result: local store shows `T1 = working` for ~one reconciliation cycle, then a stale-memory sweep re-marks it `completed` with a *new* `updatedAt`. Downstream consumers subscribed to state transitions fire a spurious "task reopened" event. The precise trigger is **step 4's coupling**: card re-discovery is treated as a binding-invalidation event, which is a category error. Card discovery answers "may this agent receive push at all," not "is this specific task's binding still live." ## Condition of Validity The invariant holds only under these conditions, and the failure is *bounded* (not eliminated) when any is violated: - **Terminal-state sealing is monotonic on the server.** Once a task reaches `completed`/`failed`/`canceled`, no new `(taskId, webhookUrl)` binding may be created for that `taskId`, regardless of URL novelty. Servers that key bindings by `taskId` alone and overwrite `webhookUrl` violate this silently. - **Card re-fetch must not carry binding intent.** The Agent Card response schema has no field that asserts a binding is live; a client that infers liveness from `capabilities.pushNotifications: true` is reading a *capability* as a *commitment*. The invariant requires clients to treat card data as authorization-scope only. - **Event identity is stable across replay.** Terminal events must carry a server-assigned `eventId` (or equivalent) so a receiver can dedupe on `(taskId, eventId)` rather than `(taskId, state)`. Without stable event identity, replay is indistinguishable from a genuine state transition. - **Rebind is legal only in non-terminal states.** A2A permits rebinding a push channel while `input-required` or `working`; it does not permit it after terminal. The boundary is the state machine transition, not the HTTP verb. Outside these conditions — e.g., a server that overwrites bindings by `taskId`, or a client that has no `eventId` — the failure is not preventable by protocol alone and must be handled by receiver-side idempotency. ## Decision Boundary The decision the client must make on card re-discovery is **not** "should I re-assert my binding?" but "does my local task state permit a binding mutation?" Concretely: - If local state ∈ {`submitted`, `working`, `input-required`} → card re-fetch may *validate* the existing binding (confirm `capabilities.pushNotifications` still true and the card's `url` still matches the endpoint the binding was created against). It must **not** create a new binding key. - If local state ∈ {`completed`, `failed`, `canceled`} → card re-fetch is a **no-op for binding purposes**. Any inbound push for this `taskId` is a replay and must be deduped on `eventId`, never allowed to mutate state. - If local state is *unknown* (cold start, store miss) → the client must reconcile against the server via `tasks/get` before trusting any inbound push, because a push for an unknown `taskId` could be either a genuine new task or a replay of a task the client forgot. The boundary is sharp: **binding mutation is gated on the local task state machine, not on card cache events.** Conflating the two is the defect. ## Operational Effect When the invariant is enforced, the failure mode collapses to a bounded, observable event: a duplicate terminal push that the receiver drops on `eventId` mismatch, with no state mutation. When it is not enforced, the effects compound: - **Spurious state resurrection** in client stores, which propagates to any downstream consumer keyed on state transitions (dashboards, retry orchestrators, billing meters). - **Duplicate terminal delivery** to rotated endpoints, doubling webhook volume for exactly the tasks that already finished — the worst time to spend tokens on delivery. - **False `input-required` loops**: if the rebind lands while the server is mid-`input-required` (a race between terminal and rebind), the client may re-prompt a human for input on a task that completed seconds earlier. The guardrail is a single server-side check — reject any binding write for a terminal `taskId` with a distinct error class (not a generic 404) — plus a client-side rule that card refresh never carries binding intent. Together they bound the failure to a dropped duplicate rather than a state-machine violation. ```python class TerminalTaskRebindError(RuntimeError): """Raised when a push binding is created/rebound for a terminal A2A task.""" pass TERMINAL_STATES = frozenset({"completed", "failed", "canceled"}) NON_TERMINAL_STATES = frozenset({"submitted", "working", "input-required"}) def bind_push_channel(task_state: str, existing_bindings: dict, task_id: str, webhook_url: str) -> dict: """ Enforce the invariant: no binding mutation for a terminal task, regardless of whether the webhook URL is novel. Returns updated bindings or raises. """ if task_state in TERMINAL_STATES: # Novel URL does NOT authorize a rebind; terminal is sealed. raise TerminalTaskRebindError( f"task {task_id} is terminal ({task_state}); " f"refusing to bind {webhook_url} — replay must be deduped on eventId" ) if task_state not in NON_TERMINAL_STATES: raise TerminalTaskRebindError( f"task {task_id} has unknown state {task_state!r}; " f"reconcile via tasks/get before binding" ) existing_bindings[(task_id, webhook_url)] = {"sealed": False} return existing_bindings def on_agent_card_refresh(task_state: str, task_id: str, card_capabilities: dict) -> str: """ Card refresh is authorization-scope only. It must never create a binding. Returns the permitted action for the caller to apply. """ if not card_capabilities.get("pushNotifications", False): return "revoke_binding" if task_state in TERMINAL_STATES: # Capability is true, but the task is sealed: no binding action. return "noop_terminal" if task_state in NON_TERMINAL_STATES: return "validate_existing_binding" raise TerminalTaskRebindError( f"card refresh for task {task_id} with unknown state {task_state!r}; " f"cannot decide binding action" ) ```