# Why does an instance lose task ownership when an A2A v1.0 Agent Card changes mid-task: webhook rebinding and the `TaskState` monotonicity invariant **Date of Record:** 2026 November 21 **Scope:** Applies to A2A v1.0 inter-agent task delegation where the client resolves the remote agent via Agent Card discovery and receives asynchronous task updates through a push-notification webhook. Does not apply to synchronous request/response A2A calls, nor to MCP tool invocations, which have no remote card lifecycle. ## Core Distinction The boundary that matters is not "did the remote agent crash" but "did the remote agent's *identity contract* mutate while a task was in flight." In A2A v1.0, the Agent Card is a discovery artifact: it advertises `capabilities`, `skills`, `defaultInputModes`, `defaultOutputModes`, and crucially the `pushNotifications` block including the authorization scheme and any `url`/callback binding the server expects. The task lifecycle (`submitted → working → input-required → completed/failed/canceled`) is a *separate* state machine that lives on the remote server, keyed by `taskId`. The non-obvious failure mode: **the client caches the Agent Card at delegation time, but the server re-derives webhook authentication and callback routing from the *current* card at each push event.** When the card is re-fetched/redeployed between the client's `tasks/send` and the server's first `working` push, the two sides disagree about the binding. The task itself is healthy; the *transport binding to observe it* is not. The client sees silence and, under most orchestration loops, interprets silence as failure and re-delegates — producing duplicate task execution against a server that already committed side effects. ## What Was Observed A three-hop pipeline: orchestrator `O` → worker agent `W` → auditor agent `A`. `O` discovers `W` via `/.well-known/agent.json`, caches the card (TTL 900s), and calls `tasks/send` with `pushNotification.url` pointing at `O`'s webhook and an auth token `T1` matching the card's advertised `pushNotifications.authentication.schemes = ["bearer"]`. `W` accepts, returns `taskId=abc`, state `submitted`. Mid-execution, `W` is redeployed (rolling update) with a card change: `pushNotifications` now requires `schemes = ["hmac-sha256"]` and a rotated signing key, and the callback URL is validated against an allowlist. `W`'s in-memory task store survives the restart (it was externalized), so `taskId=abc` is still `working`. But the push dispatcher, on its next event, signs with HMAC and POSTs to `O`'s webhook. `O`'s webhook handler validates against the cached card: expects `Authorization: Bearer T1`, sees `X-Signature: hmac=...`, returns `401`. `W`'s dispatcher retries 3× with exponential backoff (1s, 2s, 4s), then marks the push endpoint **degraded** and *stops pushing* for that task — but does not fail the task. `abc` continues to `working`, later to `completed`, with results retrievable only via `tasks/get`. `O` never calls `tasks/get` for `abc` because its loop is push-driven: no push → no completion event → after a 120s watchdog, `O` assumes `W` died and re-delegates the same work as `taskId=def`. `W` executes the work twice. The auditor `A` receives two result submissions for the same logical unit and, lacking an idempotency key, flags a consensus conflict. Trace of the state divergence: ``` t0 O: card_cached = C1 (bearer, url=hook_O) t0 O -> W: tasks/send(taskId=abc, push.url=hook_O) t1 W: abc -> working t2 W redeploy: card = C2 (hmac, allowlist) t3 W: push(abc, working) signed hmac -> O t3 O: 401 (validates against C1) t4 W: push endpoint degraded, push suppressed t5 W: abc -> completed (state advances, push does not) t6 O: watchdog fires, no event for abc -> re-delegate t7 O -> W: tasks/send(taskId=def, same payload) t8 W: def executes (duplicate side effect) t8 A: two results, no idempotency key -> conflict ``` The invariant violated: **`TaskState` advancement on the server must not be observable to the client only through a channel whose authentication is bound to a mutable discovery artifact.** The card is a *discovery* contract; the push binding is a *session* contract; they were conflated. ## Condition of Validity This failure requires all of the following to co-occur, which is why it is rare and hard to reproduce: 1. The task is asynchronous and push-driven, not poll-driven (a polling client re-reads the card or calls `tasks/get` and self-heals). 2. The Agent Card's `pushNotifications` block changes *between* delegation and the first post-change push — a window that is widest during rolling deploys and key rotation. 3. The client caches the card with a TTL longer than the task's expected duration, or caches it for the connection lifetime. 4. The server treats push-auth failure as *transport* failure (suppress + retry) rather than *task* failure (fail the task and surface it via `tasks/get`). 5. The client's watchdog converts "no push" into "task dead" rather than "transport suspect." Remove any one and the failure does not propagate to duplicate execution. The dangerous combination is (3)+(4)+(5): a caching client, a suppressing server, and an optimistic watchdog. ## Decision Boundary The architectural guardrail is a **two-channel liveness invariant with card-version pinning**: - Every `tasks/send` response must echo the card version the server used (`agentCard.version` or a content hash). The client pins that version for the task's lifetime and treats any push signed under a *different* version as a *binding change event*, not a validation failure. - On binding change, the client must **fall back to `tasks/get`** for that `taskId` before any watchdog action. Push is an optimization; `tasks/get` is the source of truth. A push-driven client that cannot poll is not A2A-conformant for long tasks. - The server must **never suppress pushes silently**. A push that fails auth must transition the task's *notification* sub-state to `degraded` and be reported in the `tasks/get` payload so a polling fallback can detect it. - Re-delegation must carry an **idempotency key** derived from the logical unit of work (not the `taskId`), so `W` can dedupe `def` against `abc`. The decision boundary for the orchestrator: *re-delegate only after a successful `tasks/get` confirms the task is absent or failed.* "No push received" is not evidence of task death; it is evidence of transport suspicion. ## Operational Effect Without the invariant, the system exhibits **duplicate execution under benign redeploys** — the worst class of bug because it is triggered by normal operations (a deploy, a key rotation) and produces correct-looking-but-doubled side effects that surface downstream as auditor consensus conflicts, double-charges, or duplicated writes. The failure is invisible in per-agent logs (each agent is locally correct) and only appears in cross-agent reconciliation. With the invariant, the redeploy is a non-event: the client detects the card-version mismatch on the first post-change push, polls `tasks/get`, observes `working`/`completed`, and reconciles without re-delegation. The cost is one extra `tasks/get` per binding change — negligible against the cost of a duplicate execution. The general lesson: **in A2A, the Agent Card is discovery, not session state.** Any per-task behavior (webhook auth, callback routing, capability gating) that is re-derived from the card at event time must be pinned at delegation time and reconciled explicitly, or the task lifecycle and the transport lifecycle will drift apart — and the client will mistake transport silence for task death. ```python import hashlib from dataclasses import dataclass from typing import Optional class CardBindingDriftError(RuntimeError): """Raised when a push event is signed under a different Agent Card version than the one pinned at delegation time. This is a binding-change event, not a validation failure: the caller must fall back to tasks/get.""" pass class TaskLivenessError(RuntimeError): """Raised when a watchdog would re-delegate based only on push silence, without a confirming tasks/get. Re-delegation here risks duplicate execution.""" pass @dataclass(frozen=True) class PinnedCard: version: str # e.g. content hash of the Agent Card push_scheme: str # "bearer" | "hmac-sha256" callback_url: str @dataclass class TaskHandle: task_id: str idempotency_key: str # derived from logical unit of work, NOT task_id pinned: PinnedCard notification_state: str = "healthy" # "healthy" | "degraded" def verify_push(task: TaskHandle, event_card_version: str, event_scheme: str, event_url: str) -> None: """Validate an inbound push against the PINNED card, not the live card.""" if event_card_version != task.pinned.version: # Binding drift: do NOT 401-and-forget. Signal fallback. task.notification_state = "degraded" raise CardBindingDriftError( f"task {task.task_id}: push signed under card {event_card_version}, " f"pinned {task.pinned.version}; fall back to tasks/get" ) if event_scheme != task.pinned.push_scheme: task.notification_state = "degraded" raise CardBindingDriftError( f"task {task.task_id}: scheme {event_scheme} != pinned {task.pinned.push_scheme}" ) if event_url != task.pinned.callback_url: task.notification_state = "degraded" raise CardBindingDriftError( f"task {task.task_id}: callback {event_url} != pinned {task.pinned.callback_url}" ) def watchdog_redelegate(task: TaskHandle, push_silence_secs: int, last_get_state: Optional[str]) -> bool: """Return True only if re-delegation is provably safe.""" if push_silence_secs < 120: return False if last_get_state is None: # No confirming tasks/get: silence is transport suspicion, not death. raise TaskLivenessError( f"task {task.task_id}: {push_silence_secs}s push silence with no " f"tasks/get confirmation; refusing to re-delegate (idempotency_key=" f"{task.idempotency_key})" ) if last_get_state in ("completed", "failed", "canceled"): return False # task is terminal; reconcile, do not re-delegate # last_get_state == "working" or "input-required": task is alive return False def idempotency_key(logical_unit: str, payload_digest: str) -> str: return hashlib.sha256(f"{logical_unit}:{payload_digest}".encode()).hexdigest() ```