Under what conditions must an instance treat a peer's A2A Agent Card as non-authoritative for task-state transitions after a push-notification webhook has fired

**Date of Record:** 2026 December 2 **Scope:** Applies to A2A v1.0 clients that discover peers via Agent Card (`/.well-known/agent-card.json`), drive tasks through the `submitted → working → input-required → completed/failed/canceled` lifecycle, and subscribe to state changes via push-notification webhooks. Does not apply to synchronous request/response-only A2A usage where no webhook is registered, nor to non-A2A transports.

Core Distinction

The Agent Card is a *capability and endpoint advertisement*, not a *task-state authority*. In A2A v1.0 the card declares `capabilities`, `skills`, `defaultInputModes`/`defaultOutputModes`, and crucially the `pushNotifications` capability block plus the `url` used for `message/send` and `tasks/get`. A subtle and repeatedly observed failure is that an orchestrating instance conflates two distinct sources of truth:

  1. **The card** — a static, cached, discovery-time artifact describing *what the peer claims it can do and where to reach it*.
  2. **The task resource** — a mutable, per-`taskId` state machine owned by the remote agent, whose authoritative snapshot is only obtainable via `tasks/get` (or a verified push event).

The boundary condition: once a push-notification webhook has fired for a `taskId`, the card's advertised `pushNotifications` config and the card's `url` are **no longer sufficient** to interpret the event. If the card is stale (re-discovered after a rolling deploy that changed the webhook signing key or the task endpoint), the client will accept a webhook payload whose `status.state` it maps against a lifecycle it no longer shares with the peer, and it will *not* re-fetch the task because it believes the card already told it the current contract. The invariant violated: **webhook payloads are only trustworthy relative to the card revision that was live when the subscription was created, and card revisions are not monotonic across peer restarts.**

What Was Observed

A three-hop pipeline: planner agent `P` → worker agent `W` (A2A v1.0, push-enabled) → auditor agent `A`. `P` discovers `W`'s card at T0, caches it, and calls `message/send` with a `pushNotificationConfig` pointing at `P`'s webhook. `W` returns a `Task` in state `submitted` with a `taskId`. `W` then transitions to `working` and emits a push event.

At T1, `W` is redeployed. Its card changes in two ways that matter: the `pushNotifications` block now advertises a new `authentication.schemes` value (webhook payloads are now signed with a rotated HMAC key), and the task endpoint `url` moves to a new host. `W`'s internal task store is *not* migrated; existing `taskId`s are reaped and the task is restarted under the same `taskId` but a fresh state machine, resetting to `submitted`.

`P` receives a second push event for the same `taskId` with `status.state: "submitted"` — a *backwards* transition from `working`. Because `P` cached the T0 card, it validates the webhook signature against the old key, fails verification, and (in the observed implementation) falls back to "trust the payload body, re-verify later." It then applies the `submitted` state to a task it had recorded as `working`, and because its local state machine forbids `working → submitted`, it raises a transition error, marks the task `failed`, and notifies `A`. `A` independently calls `tasks/get` on the *new* `url` (it re-discovered), sees `submitted`, and disagrees with `P`'s `failed`. The two auditors deadlock on consensus for the task.

The root mechanics, in order:

Condition of Validity

A push-notification webhook payload may be treated as authoritative for a task-state transition **if and only if all of the following hold**:

  1. The webhook's signature verifies against the signing key material associated with the *card revision that was live at subscription creation*, and that revision is still the peer's current revision (checked by re-fetching the card and comparing a stable revision identifier — `ETag`, or a hash of `capabilities` + `pushNotifications` + `url`).
  2. The payload's `status.state` is a legal forward transition from the client's last *confirmed* state for that `taskId`, where "confirmed" means either the initial `message/send` response or the result of a `tasks/get` reconciliation — never a prior webhook alone.
  3. The client can order the event relative to the last confirmed state. Since v1.0 webhooks lack sequence numbers, this requires either (a) a `tasks/get` reconciliation on every webhook before applying, or (b) an idempotency key derived from `(taskId, status.state, status.timestamp)` and a monotonic timestamp check.

If any condition fails, the webhook is *evidence*, not *authority*: the client must call `tasks/get` against the peer's *current* card `url` and reconcile before mutating local state. This is the non-obvious part — most implementations treat a verified signature as sufficient authority and skip reconciliation, which is exactly the gap the redeploy exploited.

Decision Boundary

The decision boundary is **whether the card revision bound to the webhook subscription still equals the peer's current card revision.** Concretely:

The boundary is *not* "did the signature verify" — that is necessary but insufficient. It is "is the signature's key context still the live contract for this task."

Operational Effect

Enforcing this boundary changes three things in practice:

  1. **Card caches must be revision-keyed and subscription-bound.** Store the card hash alongside each `pushNotificationConfig`; on every webhook, compare. This converts silent state corruption into a detectable orphan event.
  2. **Webhook handling becomes reconcile-first on revision mismatch.** The fast path (matching revision, verified signature, legal transition) stays cheap; the slow path (`tasks/get` + reconcile) triggers only on revision drift, which is rare but catastrophic if unhandled.
  3. **Backwards transitions are reinterpreted as restarts, not failures.** This prevents the `P`/`A` consensus deadlock: both auditors, following the same rule, converge on "peer restarted the task" and agree, rather than one seeing `failed` and the other `submitted`.

The cost is one extra `tasks/get` per revision-drift webhook and a small amount of bookkeeping per subscription. The benefit is that a peer redeploy — an operationally routine event — no longer corrupts downstream task state or deadlocks multi-agent verification.

import hashlib
from dataclasses import dataclass
from typing import Optional


class OrphanedSubscriptionError(RuntimeError):
    """Raised when a webhook arrives for a task whose bound card revision
    no longer matches the peer's current Agent Card revision."""
    pass


class IllegalTransitionError(RuntimeError):
    """Raised when a webhook asserts a state transition that is neither a
    legal forward move from the confirmed state nor a recognized restart."""
    pass


FORWARD = {
    "submitted": {"working", "canceled", "failed"},
    "working": {"input-required", "completed", "failed", "canceled"},
    "input-required": {"working", "canceled", "failed"},
    "completed": set(),
    "failed": set(),
    "canceled": set(),
}


def card_revision(card: dict) -> str:
    """Stable revision identifier for an Agent Card."""
    material = (
        card.get("url", "")
        + str(sorted(card.get("capabilities", {}).items()))
        + str(card.get("pushNotifications", {}))
    )
    return hashlib.sha256(material.encode()).hexdigest()


@dataclass
class Subscription:
    task_id: str
    bound_revision: str
    confirmed_state: str


def handle_webhook(
    sub: Subscription,
    payload: dict,
    current_card: dict,
    signature_ok: bool,
    reconcile,  # callable(task_id) -> str, performs tasks/get
) -> str:
    """Apply a push-notification webhook, enforcing the revision-binding invariant.

    Returns the new confirmed state.
    """
    live_rev = card_revision(current_card)

    if sub.bound_revision != live_rev:
        # Orphaned subscription: card changed since we subscribed.
        # Do NOT trust the payload body. Reconcile against tasks/get.
        if not signature_ok:
            raise OrphanedSubscriptionError(
                f"task {sub.task_id}: card revision drifted and webhook "
                f"signature failed; refusing to apply payload"
            )
        true_state = reconcile(sub.task_id)
        if true_state != sub.confirmed_state:
            # Peer restarted or advanced the task under a new contract.
            sub.confirmed_state = true_state
            sub.bound_revision = live_rev
            return true_state
        sub.bound_revision = live_rev
        return sub.confirmed_state

    # Revision matches: signature must verify, transition must be legal.
    if not signature_ok:
        raise IllegalTransitionError(
            f"task {sub.task_id}: signature failed at matching revision; "
            f"possible injection or mid-flight key rotation"
        )

    new_state = payload["status"]["state"]
    if new_state == sub.confirmed_state:
        return sub.confirmed_state  # duplicate delivery, idempotent

    if new_state in FORWARD.get(sub.confirmed_state, set()):
        sub.confirmed_state = new_state
        return new_state

    # Backwards or illegal transition at matching revision: treat as restart
    # only if tasks/get confirms it; otherwise hard-fail.
    true_state = reconcile(sub.task_id)
    if true_state == new_state:
        sub.confirmed_state = new_state
        return new_state

    raise IllegalTransitionError(
        f"task {sub.task_id}: webhook claims {new_state} from "
        f"{sub.confirmed_state}, but tasks/get reports {true_state}"
    )