# Which invariants prevent A2A v1.0 task-state divergence when a push-notification webhook rebinds to a restarted remote agent **Date of Record:** 2026 November 25 **Scope:** Applies to A2A v1.0 task lifecycles where a client agent observes a remote agent's task via `tasks/get` polling plus a `pushNotifications` webhook binding, and the remote agent process restarts (new instance, same logical agent identity, possibly new `AgentCard` URL/host). Does not cover purely synchronous A2A calls with no webhook binding, nor A2A v0.x cards lacking `capabilities.pushNotifications`. ## Core Distinction The failure is not "webhook delivery failed." Webhook delivery failure is observable and retryable. The failure is **task-state divergence under a stale binding**: the client holds a `task.id` plus a webhook `pushNotificationConfig` bound to the *old* remote endpoint, while the restarted remote agent has re-materialized the task under a *new* `AgentCard` and a *new* instance identity. The client's local task state machine (e.g., `submitted → working → completed`) and the remote's authoritative state machine now advance independently because the two sides disagree about *which instance owns the transition*. The client believes it is subscribed; the remote believes it has no live subscriber and may (per `TaskState`) park the task in `input-required` or, worse, garbage-collect it. The non-obvious invariant: **a push-notification binding is a lease on a specific remote *instance generation*, not on the logical agent identity.** A2A v1.0 `AgentCard` discovery gives you identity continuity (same `name`, same `url` after redeploy, same skills), but identity continuity does *not* imply binding continuity. Treating card-identity stability as webhook-binding stability is the exact category error that produces silent divergence. ## What Was Observed Trace from a real incident class (client A, remote B, task `t-7f3a`): 1. A calls `message/send` on B, receives `Task{id: t-7f3a, state: working, pushNotificationConfig: {url: https://a.example/hook, token: tok-1}}`. A registers `t-7f3a` in `working`. 2. B's process is rescheduled. New instance B′ comes up. B′ re-reads its `AgentCard` from disk — identical `name`, identical `url`, but `capabilities.pushNotifications` now advertises a *new* `webhookBindingId` namespace. B′ restores `t-7f3a` from its durable store with `state: working` but **no live webhook subscriber** (the binding table was in-memory / instance-scoped and was not restored). 3. B′ finishes the work and transitions `t-7f3a → completed`. Because it has no subscriber for `t-7f3a`, it does **not** emit a `TaskStatusUpdateEvent` to A. 4. A polls `tasks/get(t-7f3a)` and sees `completed`. Fine — *if A polls*. But A's poll interval is 30s and its local state machine has a `working → input-required` watchdog at 45s that fires a clarifying `message/send`. That message arrives at B′ for a task in `completed`; B′ returns `TaskNotFound` or `InvalidTaskState`. 5. A's watchdog interprets the error as "remote lost the task," re-issues the *original* `message/send` with the same `messageId`. B′ — correctly deduplicating per `messageId` — returns the existing `completed` task. A now has two conflicting local records for one `task.id`. The divergence window is step 2→3: **the remote transitioned state without a live binding, and the client's watchdog is calibrated to binding liveness, not to remote state truth.** The webhook was a *latency optimization* that A had silently promoted to a *liveness oracle*. ## Condition of Validity This divergence requires all of the following to co-occur; remove any one and the failure does not manifest: - **Instance-scoped binding store.** The remote persists task state durably but persists `pushNotificationConfig` bindings in memory or in an instance-local table. A2A v1.0 does not mandate binding durability; it mandates binding *acceptance*. This is the load-bearing gap. - **Card-identity stability across restart.** The `AgentCard` `url` and `name` are unchanged, so A's card-refresh logic (if any) sees no reason to re-bind. If the card `url` changed, A would be forced to re-discover and re-bind, and the bug would not occur. - **Client-side liveness inference from binding.** A treats "no webhook event within N seconds" as "remote is stalled," rather than treating it as "no signal." This is the probabilistic-reasoning component: A is doing Bayesian inference over a channel it has no delivery guarantee for. - **A retry path that is not idempotency-safe at the state-machine level.** A's watchdog re-sends with a fresh `messageId` (or the remote's dedup is keyed on payload hash rather than `messageId`), so the resend is accepted as a *new* turn rather than collapsed onto the existing task. If the remote *does* persist bindings durably (many production A2A servers do, by writing `pushNotificationConfig` into the same store as `Task`), the failure is prevented at the source. The invariant is therefore conditional on the remote's binding-durability posture, which the `AgentCard` **does not advertise**. There is no `capabilities.pushNotificationDurability` field in v1.0. That omission is the root cause. ## Decision Boundary The client must decide, on every `tasks/get` poll and every watchdog tick, between two regimes: - **Binding-as-signal (unsafe):** "No webhook event ⇒ remote is stalled ⇒ intervene." Valid only when the client has a *positive* confirmation that the binding survived the remote's current instance generation — e.g., a `tasks/get` response whose `pushNotificationConfig.token` matches the client's current `tok-1` *and* whose `Task.metadata` carries an instance-generation nonce the client observed at bind time. - **Polling-as-truth (safe):** "Webhook events are latency hints; `tasks/get` is the only authority on `Task.state`." The watchdog may only fire on a *stale `tasks/get`*, never on a stale webhook. The boundary is crossed the moment the client's watchdog timeout is shorter than its `tasks/get` poll interval. If `watchdog_timeout < poll_interval`, the client is structurally forced to act on binding silence before it has authoritative state — and that is the exact ordering that produced step 4 above. The invariant to enforce: **`watchdog_timeout ≥ 2 × poll_interval`, and the watchdog may only trigger a `tasks/get`, never a `message/send`.** A `message/send` is a state-mutating operation; it must be gated on an authoritative `tasks/get` that returns `input-required` or a terminal state, not on the absence of a webhook. A second boundary: on any `tasks/get` response, if `pushNotificationConfig` is absent or its `token` differs from the client's recorded token, the client must treat the binding as **revoked** and re-bind via `tasks/pushNotificationConfig/set` before resuming its watchdog. Re-binding is cheap; a spurious `message/send` against a `completed` task is not. ## Operational Effect The practical consequence is that A2A v1.0 webhook bindings are **advisory, not authoritative**, and any client that builds a liveness or progress oracle on top of them will, under remote restart, either (a) double-submit work against a terminal task and corrupt its local state machine, or (b) hang indefinitely waiting for an event that the remote has decided not to send because it no longer has a subscriber. Both are silent: no error surfaces at bind time, and the remote's `AgentCard` looks perfectly healthy throughout. The guardrail is a client-side **binding-generation check** on every poll: compare the `pushNotificationConfig.token` in the `tasks/get` response to the token the client last set. A mismatch is a hard signal that the remote's binding store did not survive, and the client must re-bind and reset its watchdog clock — never re-send the task message. Combined with `watchdog_timeout ≥ 2 × poll_interval` and the rule that only `tasks/get` may trigger a watchdog action, this bounds the divergence window to at most one poll interval and eliminates the double-submit path entirely. The remote's binding durability is unknowable from the card, so the client must assume non-durability and verify generation on every read. ```python class BindingGenerationMismatch(RuntimeError): """Raised when a tasks/get response shows the webhook binding did not survive the remote agent's instance generation, invalidating any liveness inference.""" pass class TaskWatchdog: POLL_INTERVAL_S = 15 WATCHDOG_TIMEOUT_S = 30 # must be >= 2 * POLL_INTERVAL_S def __init__(self, task_id: str, expected_token: str): if self.WATCHDOG_TIMEOUT_S < 2 * self.POLL_INTERVAL_S: raise BindingGenerationMismatch( "watchdog_timeout must be >= 2 * poll_interval; otherwise the " "watchdog fires on binding silence before authoritative state is read" ) self.task_id = task_id self.expected_token = expected_token self.last_poll_ts = 0.0 def on_poll_response(self, resp: dict, now: float) -> None: cfg = resp.get("pushNotificationConfig") if cfg is None or cfg.get("token") != self.expected_token: # Binding did not survive remote restart: re-bind, do NOT re-send task. raise BindingGenerationMismatch( f"task {self.task_id}: binding token {cfg and cfg.get('token')!r} " f"!= expected {self.expected_token!r}; remote instance generation changed" ) self.last_poll_ts = now def on_watchdog_tick(self, now: float, last_webhook_ts: float) -> str: # Webhook silence is NOT a liveness signal. Only stale polling is. if now - self.last_poll_ts < self.WATCHDOG_TIMEOUT_S: return "continue" if now - last_webhook_ts < self.WATCHDOG_TIMEOUT_S: # A webhook arrived recently but poll is stale: re-poll, never re-send. return "repoll" # Only now, with authoritative staleness, may we consider intervention — # and even then the caller must tasks/get first, not message/send. raise BindingGenerationMismatch( f"task {self.task_id}: no authoritative poll for {now - self.last_poll_ts:.1f}s; " "issuing message/send here would risk double-submit against a terminal task" ) ```