# Why does an instance reject a valid A2A v1.0 push-notification webhook after task resurrection — the `taskId`-vs-`contextId` reattachment invariant **Date of Record:** 2026 December 1 **Scope:** Applies to A2A v1.0 servers that emit `TaskStatusUpdateEvent` / `TaskArtifactUpdateEvent` push notifications to a client-registered webhook, and to clients that reattach to a task after a server-side restart, `input-required` resume, or `canceled`→`working` transition. Does not cover streaming (`message/stream`) transport, which carries its own resumption semantics. ## Core Distinction The failure is not a webhook delivery failure and not an authentication failure. It is a **notification affinity failure**: the server holds two independently-mutable identifiers per task — the immutable `taskId` and the conversation-scoped `contextId` — and A2A v1.0 permits a task to be *resumed into a new context* (e.g., after `input-required` on a server that re-keyed the session during a restart). The client's `pushNotificationConfig` is registered against `(taskId, pushNotificationConfigId)`, but the server's dispatcher resolves the outbound webhook by looking up `contextId → config`. When the task is resurrected under a new `contextId`, the dispatcher finds *no* config for the new context, silently drops the event, and the client observes a task that is `working` on the server but frozen in its own view. The client then re-registers, the server accepts the re-registration against the *new* context, and the client now has two live registrations for one logical task — one of which will fire duplicate terminal events when a stale `contextId` is reused by an unrelated task later in the same tenant. The invariant that is violated: **`pushNotificationConfig` identity must be bound to `taskId`, not to `contextId`, and the dispatcher must fall back to `taskId` resolution when `contextId` resolution misses.** A2A v1.0's `tasks/pushNotificationConfig/set` accepts both an optional `taskId` and a `contextId`; most implementations bind the config to whichever key the client supplied, and clients that supply only `contextId` (a common pattern for "session-scoped" notification routing) become silently unbound at resurrection. ## What Was Observed Trace on a two-node A2A server behind a sticky-less load balancer, task lifecycle `submitted → working → input-required → working → completed` with a server restart injected between the two `working` states: 1. Client calls `tasks/send` with `pushNotificationConfig: {url, token}` and no explicit `taskId` (it doesn't exist yet). Server mints `taskId=T1`, `contextId=C1`, persists config `{configId=P1, taskId:T1, contextId:C1, url, token}`. 2. Server emits `working` → webhook fires at `url`, HMAC over `token` validates. Client records `T1/P1` as the live binding. 3. Server transitions to `input-required`, persists state, then restarts. On boot, the recovery scanner reloads tasks but **rehydrates `contextId` from the last client-supplied `message.contextId`**, which the client had set to a fresh value `C2` on its resume call. `taskId` is preserved as `T1`; `contextId` is rewritten to `C2`. 4. Client calls `tasks/send` with `taskId=T1`, `message.contextId=C2`, `pushNotificationConfig` omitted (it believes `P1` still holds). Server accepts, resumes to `working`. 5. Server dispatcher attempts to fire `TaskStatusUpdateEvent` for `T1`. Resolution path: `contextId=C2 → configs`. Miss. The dispatcher does **not** fall back to `taskId=T1`. Event dropped, no error, no retry, no dead-letter. 6. Client's `tasks/get T1` shows `working`; the client waits. After 90s it re-registers a config under `C2` (configId `P2`). Server now has `P1` (orphaned, `contextId=C1`) and `P2` (live, `contextId=C2`) both bound to `T1`. 7. Task completes. Dispatcher fires against `C2 → P2`. Client gets one terminal event. Correct-looking. 8. Three hours later, an unrelated task `T9` is created with `contextId=C1` (context IDs are reused per tenant in this server's allocator). The orphaned `P1` fires a `TaskStatusUpdateEvent` for `T9` — but the payload's `taskId` is `T9`, while the client maps `P1` to `T1`. Client applies a status update for `T9` onto its `T1` record. Cross-task state contamination. The observable signature is: **webhook silence during a resume, followed by a delayed duplicate/misattributed event after context-ID reuse.** Neither the silence nor the misattribution raises an error at the A2A layer. ## Condition of Validity This failure requires all of the following to hold simultaneously: - The server's push-notification dispatcher resolves configs by `contextId` as the primary key (or by `contextId` exclusively when the client supplied only `contextId` at registration). - The task lifecycle includes at least one transition that mutates `contextId` while preserving `taskId` — i.e., `input-required` resume, cancellation-and-reopen, or restart rehydration from a client-supplied `message.contextId`. - The client does not re-send `pushNotificationConfig` on every `tasks/send` that carries an existing `taskId`. - Context IDs are allocated from a bounded or reused namespace (per-tenant counters, hash of conversation seed, etc.), so an orphaned config can later collide with a new task. If any one is false, the failure does not manifest. Notably, a server that binds configs strictly to `taskId` and treats `contextId` as a routing hint is immune; a client that re-registers configs on every resume call is immune to the silence (but not to the duplicate-registration contamination in step 6–8, which is a separate leak). ## Decision Boundary The boundary is whether the client treats `pushNotificationConfig` as **task-scoped** or **context-scoped**, and whether the server enforces that choice. - **Task-scoped (correct):** config identity is `(taskId, configId)`; `contextId` is metadata. Dispatcher resolves `taskId → configs`, then filters by `contextId` only if multiple configs exist. Resurrection preserves delivery. Reused context IDs cannot misroute because the config is not keyed by context. - **Context-scoped (observed failure):** config identity is `(contextId, configId)`. Resurrection breaks delivery; context reuse causes cross-task contamination. The boundary is crossed the moment a server accepts a `pushNotificationConfig` with a `contextId` but no `taskId` and stores it keyed by `contextId` alone. A2A v1.0's schema permits this; the spec's normative language ("the server MUST deliver events for the task to the registered webhook") is task-scoped, but the wire format does not force the binding. Implementations diverge here, and the divergence is invisible until a resume happens. Guardrail: on `tasks/pushNotificationConfig/set`, if `taskId` is absent, the server must resolve the task from `contextId` and persist the config under `taskId`. If `taskId` is present and `contextId` differs from the task's current `contextId`, the server must reject with `InvalidParams` rather than silently re-key — the client is trying to attach a notification to a task it no longer owns the context for. ## Operational Effect During the silent window (step 5), the client's task view diverges from the server's. Any client that gates on webhook receipt (rather than polling `tasks/get`) will hang until its own timeout, then either re-register (creating the duplicate) or abandon the task (leaving it `working` on the server until the server's own task TTL reaps it). For a task that is `input-required` and awaiting human approval, this can strand the task indefinitely, because the approval webhook never fires and the human never sees the prompt. During the contamination window (step 8), the client applies a status event for task `T9` onto its record for `T1`. If the event is `completed`, the client marks `T1` complete and stops polling — the real `T1` result is never fetched. If the event is `failed`, the client surfaces a spurious failure. The client has no way to detect the mismatch from the event payload alone, because the payload's `taskId` is correct for the *sending* task; the misattribution is purely on the receiving side's config-to-task map. The durable fix is on both sides: servers must key configs by `taskId` and reject re-keying; clients must send `taskId` on every `pushNotificationConfig/set` and must verify that incoming events' `taskId` matches the config's bound `taskId` before applying. The check is cheap and catches the entire class. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Literal class PushConfigAffinityError(RuntimeError): """Raised when a push-notification config cannot be bound to a stable task identity.""" @dataclass(frozen=True) class PushConfig: config_id: str task_id: str | None context_id: str url: str @dataclass class TaskRecord: task_id: str context_id: str state: Literal["submitted", "working", "input-required", "completed", "failed", "canceled"] @dataclass class Dispatcher: tasks: dict[str, TaskRecord] = field(default_factory=dict) configs_by_task: dict[str, list[PushConfig]] = field(default_factory=dict) configs_by_context: dict[str, list[PushConfig]] = field(default_factory=dict) def register(self, cfg: PushConfig) -> None: # Guardrail: refuse context-only registration when the task is known. if cfg.task_id is None: owners = [t for t in self.tasks.values() if t.context_id == cfg.context_id] if len(owners) != 1: raise PushConfigAffinityError( f"context {cfg.context_id!r} does not resolve to exactly one task; " f"refusing context-scoped push config {cfg.config_id!r}" ) cfg = PushConfig(cfg.config_id, owners[0].task_id, cfg.context_id, cfg.url) task = self.tasks.get(cfg.task_id) if task is None: raise PushConfigAffinityError(f"unknown task {cfg.task_id!r}") if task.context_id != cfg.context_id: # Client is trying to attach a notification to a task under a stale context. raise PushConfigAffinityError( f"config {cfg.config_id!r} context {cfg.context_id!r} != task " f"{cfg.task_id!r} current context {task.context_id!r}" ) self.configs_by_task.setdefault(cfg.task_id, []).append(cfg) self.configs_by_context.setdefault(cfg.context_id, []).append(cfg) def dispatch(self, task_id: str) -> list[PushConfig]: # Guardrail: resolution is task-scoped. Context is never the primary key. task = self.tasks.get(task_id) if task is None: raise PushConfigAffinityError(f"dispatch for unknown task {task_id!r}") configs = self.configs_by_task.get(task_id, []) if not configs: raise PushConfigAffinityError( f"task {task_id!r} has no bound push config; " f"event would be silently dropped (context {task.context_id!r})" ) return [c for c in configs if c.context_id == task.context_id] or configs ```