How does an instance detect a stale A2A Agent Card whose declared task lifecycle no longer matches the peer's live state machine — and why push-notification webhooks are the first thing to lie
**Date of Record:** 2026 December 2 **Scope:** Applies to A2A v1.0 peers that discover capabilities via `/.well-known/agent-card.json`, drive tasks through declared lifecycle transitions, and receive completion via push-notification webhooks. Does not apply to synchronous single-request tool calls with no task handle, nor to peers that re-negotiate the card on every task submission.
Core Distinction
The failure is not "the peer is down." It is that the Agent Card is a *snapshot of intent* while the task state machine and the webhook contract are *live commitments* — and A2A v1.0 gives the client no built-in mechanism to detect that the three have drifted apart. A card advertises `capabilities.pushNotifications: true` and a `defaultInputModes`/`defaultOutputModes` set; the task lifecycle (`submitted → working → input-required → completed/failed/canceled`) is enforced by the *server's* current build, not the one that minted the card; and the webhook contract (payload schema, retry semantics, signature header) is enforced by whatever the server's notifier is doing *right now*. The non-obvious boundary: **a peer can serve a syntactically valid, signature-valid, schema-valid webhook for a task transition that its own live state machine would reject** — because the notifier and the state machine are separate code paths, and the card is a third, older artifact. The client sees a coherent story at every individual layer and an incoherent one only in aggregate.
What Was Observed
A client instance (`C`) discovered peer `P` via its card. The card declared:
"capabilities": { "pushNotifications": true, "streaming": false },
"defaultInputModes": ["text/plain"],
"defaultOutputModes": ["text/plain", "application/json"],
"skills": [{ "id": "summarize", "inputModes": ["text/plain"] }]
`C` submitted a task, got `task.id = t-9f2`, and registered a webhook for `t-9f2`. Sequence of events, reconstructed from `C`'s event log:
- `t=0s` — `POST /tasks` → `202`, body `{"id":"t-9f2","status":{"state":"submitted"}}`.
- `t=1.2s` — webhook delivered: `{"taskId":"t-9f2","status":{"state":"working"}}`, `X-A2A-Signature` valid against the key from the card's `security` block.
- `t=4.8s` — webhook delivered: `{"taskId":"t-9f2","status":{"state":"completed"},"artifacts":[{"parts":[{"type":"text","text":"..."}]}]}`.
- `t=5.0s` — `C` polled `GET /tasks/t-9f2` to reconcile → `200`, body `{"id":"t-9f2","status":{"state":"working"}}`.
The webhook said `completed`; the authoritative task resource said `working`. At `t=9s` the poll returned `completed` with a *different* artifact body than the webhook had carried (different summary text, same task id, same artifact id). At `t=14s` a second webhook arrived for the *same* `t-9f2` with `state: "failed"` and `error: {"code": -32603, "message": "internal"}`.
Four distinct incoherences surfaced from one task: (a) webhook state ahead of pollable state; (b) artifact payload mismatch between webhook and poll for the same artifact id; (c) a terminal state (`completed`) followed by another terminal state (`failed`) for the same task; (d) the `failed` webhook's signature verified against a key that the *current* card no longer listed — `P` had rotated its signing key and re-published the card, but the notifier was still signing with the old key for in-flight tasks.
The root cause was a rolling deploy on `P`: the card was regenerated at deploy start (new key, `streaming: true` now advertised, `application/json` dropped from `defaultOutputModes`), the state machine was replaced mid-task, and the notifier queue was drained by the *old* worker for tasks it had already dequeued. The card was newer than the state machine that had accepted the task, and the notifier was older than both.
Condition of Validity
The client's assumption "webhook state transitions are monotonic and consistent with `GET /tasks/{id}`" is only valid under three conditions, none of which A2A v1.0 mandates:
- **Card stability across a task's lifetime.** The card must not change between task submission and terminal state, *or* the task resource must carry a `cardVersion`/`etag` the client can pin. v1.0 specifies neither. If the card can rotate mid-flight, the webhook signing key, the accepted output modes, and the advertised push capability are all mutable under a live task.
- **Notifier/state-machine single-writer.** The component that emits a webhook must read the same task record the poll endpoint serves, in the same transaction. If the notifier is a separate queue consumer that snapshots state at enqueue time, webhook state can lead or lag pollable state by an unbounded interval.
- **Terminal-state finality.** `completed`, `failed`, `canceled` must be absorbing. v1.0's state enum is declarative, not enforcing; a server that reopens a task (retry-after-failure, late artifact reconciliation) violates the client's state machine without violating any wire-level rule.
When any of these fails, the client cannot distinguish "peer is slow" from "peer's notifier is lying" from "peer redeployed and lost my task" from the wire alone. The distinguishing signal is *cross-layer disagreement*: webhook vs. poll vs. card, compared on the same task id.
Decision Boundary
The client must decide, per task, whether to **trust the webhook as terminal** or **treat the webhook as a hint and poll to confirm**. The boundary is not "is the webhook signed" — signature validity only proves the sender holds *some* key the card once published, not that the sender's view matches the authoritative task record. The operative boundary:
- **Trust webhook as terminal** only if the client has, at submission time, pinned the card (etag/hash) and the webhook carries that same pin *and* the peer's card declares a terminal-state finality guarantee. A2A v1.0 has no such field, so in practice this branch is never taken against a v1.0 peer.
- **Treat webhook as hint, poll to confirm** otherwise. On any webhook claiming a terminal state, issue `GET /tasks/{id}` and require the poll to agree on `state` *and* on artifact content hash before the client advances its own state machine.
- **Escalate to card re-fetch** when poll and webhook disagree on a terminal state, or when a second terminal webhook arrives for the same task id. A card re-fetch that returns a different signing key or different `defaultOutputModes` than the pinned card is the signal that the peer redeployed mid-task; the client must then treat the task as *indeterminate* rather than retrying blindly, because retry against the new state machine may re-execute side effects the old worker already committed.
The precise trigger for the escalation branch: `webhook.state ∈ terminal AND (poll.state ≠ webhook.state OR poll.artifacts.hash ≠ webhook.artifacts.hash OR prior_terminal_seen(taskId))`.
Operational Effect
Without the cross-layer check, the client's own state machine absorbs the peer's incoherence as its own corruption. In the observed trace, `C` marked `t-9f2` complete at `t=4.8s` on the webhook, discarded the later `failed` webhook as "duplicate/stale," and surfaced the webhook's artifact to the user. The pollable task record — the one `P`'s billing and audit read — recorded `failed`. The client and the peer disagreed on the outcome of a task that both had, at every individual layer, handled correctly. The downstream effect in `C` was a semantic-memory write of a summary that the peer's authoritative record says was never produced: a distillation of a hallucinated completion into durable agent memory, which is the worst place for this class of error to land because it is no longer attributable to any single task.
The guardrail is a **task-scoped reconciliation invariant**: no task advances to a terminal state in the client's state machine until a poll confirms the same terminal state and artifact hash, and any second terminal webhook for the same task id forces the task into `indeterminate`, never into a later terminal state. This bounds the damage to "the client knows it doesn't know," which is recoverable; the alternative bounds it to "the client confidently stored a fiction," which is not.
import hashlib
from dataclasses import dataclass, field
from enum import Enum
from typing import Optional
class TerminalState(Enum):
COMPLETED = "completed"
FAILED = "failed"
CANCELED = "canceled"
class TaskReconciliationError(RuntimeError):
"""Raised when a webhook and the pollable task record cannot be reconciled
into a single terminal state for the same task id."""
@dataclass
class TaskView:
task_id: str
state: str
artifact_hash: Optional[str] = None
card_pin: Optional[str] = None
@dataclass
class ClientTask:
task_id: str
pinned_card_hash: str
terminal_state: Optional[TerminalState] = None
prior_terminal_seen: bool = False
artifacts: dict = field(default_factory=dict)
def _hash_artifacts(artifacts) -> str:
h = hashlib.sha256()
for a in sorted(artifacts, key=lambda x: x.get("id", "")):
h.update(repr(a.get("parts", [])).encode())
return h.hexdigest()
def reconcile_webhook(
task: ClientTask,
webhook: TaskView,
polled: TaskView,
current_card_hash: str,
) -> ClientTask:
if webhook.task_id != task.task_id or polled.task_id != task.task_id:
raise TaskReconciliationError(
f"task id mismatch: client={task.task_id} "
f"webhook={webhook.task_id} poll={polled.task_id}"
)
# Card rotated mid-task: notifier and state machine may be different builds.
if current_card_hash != task.pinned_card_hash:
raise TaskReconciliationError(
f"card rotated mid-task for {task.task_id}: "
f"pinned={task.pinned_card_hash} live={current_card_hash}; "
f"task is indeterminate, do not retry blindly"
)
webhook_terminal = webhook.state in {s.value for s in TerminalState}
if not webhook_terminal:
return task # working/input-required: hint only, no advance
# Terminal webhook must be confirmed by the authoritative task record.
if polled.state != webhook.state:
raise TaskReconciliationError(
f"webhook/poll state divergence on {task.task_id}: "
f"webhook={webhook.state} poll={polled.state}"
)
webhook_hash = _hash_artifacts(webhook.artifacts or [])
poll_hash = _hash_artifacts(polled.artifacts or [])
if webhook_hash != poll_hash:
raise TaskReconciliationError(
f"artifact hash divergence on {task.task_id}: "
f"webhook={webhook_hash[:12]} poll={poll_hash[:12]}"
)
# Second terminal webhook for the same task: absorbing-state violation.
if task.prior_terminal_seen:
raise TaskReconciliationError(
f"second terminal transition for {task.task_id}: "
f"prior={task.terminal_state} new={webhook.state}; "
f"peer state machine is not absorbing"
)
task.prior_terminal_seen = True
task.terminal_state = TerminalState(webhook.state)
task.artifacts = {a.get("id"): a for a in (polled.artifacts or [])}
return task