# What happens when an instance accepts an A2A v1.0 Agent Card whose declared `taskLifecycle` states are a superset of the states the peer runtime actually emits **Date of Record:** 2026 November 24 **Scope:** Applies to A2A v1.0 cross-vendor delegation where the calling agent (delegator) negotiates task lifecycle from a discovered Agent Card and drives state transitions via `tasks/send` and `tasks/get`. Does not apply to same-vendor A2A where card and runtime are generated from one schema; does not cover streaming `tasks/sendSubscribe` push channels (separate invariant). ## Core Distinction An Agent Card is a *declaration*, not a *contract enforced at runtime*. A2A v1.0 lets a peer publish `capabilities.taskLifecycle.states` — the set of task states it claims to transition through (`submitted`, `working`, `input-required`, `completed`, `failed`, `canceled`). The delegator's negotiation logic typically treats this set as authoritative: it builds a state machine, allocates handlers per state, and assumes any state *not* in the set will never arrive, while any state *in* the set is reachable. The non-obvious boundary: **a peer may declare a superset of the states it actually emits.** Card authors over-declare defensively — copying the full A2A enum into the card to "look compliant" — while the runtime behind the card only ever emits `submitted → working → completed|failed`. The delegator now waits on a transition that is *legal per the card* but *unreachable per the runtime*: specifically it blocks on `input-required` as a valid intermediate, or it treats `canceled` as an acknowledged terminal it can rely on for cleanup, when the peer silently maps cancellation to `failed` with a generic error. The failure is not a crash — it is an *unreachable-state wait* or a *terminal-state misclassification* that corrupts the delegator's retry and compensation logic. This is distinct from schema-version mismatch (a hard rejection) and from transport failure (a timeout). The card validates, the first transition succeeds, and the divergence only surfaces at the *third or later* state — deep enough that the delegator has already committed side effects. ## What Was Observed A delegator D discovers peer P via `/.well-known/agent.json`. P's card declares: ``` capabilities.taskLifecycle.states = [submitted, working, input-required, completed, failed, canceled] ``` D builds a lifecycle driver keyed on that set. It sends a `tasks/send` for a long-running delegation envelope (a cross-vendor refactor task). Observed trace: 1. `tasks/send` → P returns `state: submitted`, `taskId: t-91`. D registers a `working` handler. 2. D polls `tasks/get(t-91)` → `state: working`, `progress: 0.4`. Normal. 3. D's envelope includes a `clarification` field P's runtime does not understand (P ignores unknown envelope fields silently rather than rejecting — a second, compounding over-declaration). P needs no input but its runtime, on encountering an unresolvable internal subtask, *intends* to emit `input-required`. Its card says it can. Its runtime build predates the `input-required` emitter and instead emits `failed` with `error.code: INTERNAL`. 4. D, holding a card that promised `input-required` is reachable, has a handler that on `failed` checks "was this a pre-terminal failure that should have been `input-required`?" and, per its own policy, *re-issues the task* rather than compensating. It re-sends. P fails again identically. D retries 3× (its `failed`-retry budget), then escalates. The divergence: P never emitted `input-required`, but P's card said it would. D's retry policy was gated on the *card's* reachable-state graph, not on observed transitions. Result: three duplicate side-effecting delegations (P's runtime was not idempotent on `taskId` reuse — it minted a new `taskId` per `tasks/send`, so D's dedup key never matched), one orphaned `working` task left on P, and a compensation path that never ran because D never saw `canceled`. A second instance showed the terminal-state variant: D sent `tasks/cancel(t-91)`. P's card declares `canceled` reachable. P's runtime had no cancel handler wired and returned `state: failed, error.code: UNSUPPORTED` — but D's cancel path treated any non-`canceled` response as "cancel in flight, poll again," so D polled `tasks/get` against a task P had already torn down, receiving `404`/`TASK_NOT_FOUND`, which D mapped to a transport error and retried, looping until its poll budget expired. ## Condition of Validity The superset-declaration failure is *live* — meaning it can corrupt delegation — only when all of the following hold: - The peer's card declares at least one state the peer runtime does not emit (superset), **and** the delegator's control flow contains a branch that is *only* reachable via that declared state (e.g., a `input-required` handler, or a `canceled`-terminal assumption). - The delegator does **not** reconcile declared states against observed transitions before committing side effects. If D had required P to *demonstrate* each declared state (a probe task) before trusting the graph, the unreachable state would have been pruned at negotiation. - The peer is **not idempotent on `taskId`** across `tasks/send` (mints new IDs), so the delegator's retry-on-`failed` cannot dedup and compounds duplicate work. - The divergence surfaces at the **third-or-later transition**. If it surfaced at transition 1 (`submitted` rejected), D would have aborted cheaply. The dangerous window is after D has performed its own pre-delegation side effects (resource reservation, envelope signing with a warrant that assumes `canceled` cleanup). When any of these fails — e.g., the delegator prunes the graph by observation, or the peer is idempotent, or the divergence is early — the superset is harmless. The invariant is therefore *conditional on the delegator trusting the card's state graph as a reachability guarantee rather than a permission set.* ## Decision Boundary The boundary the delegator must draw is between **declared-reachable** and **observed-reachable**, and it must be drawn *before* the first side effect, not after the first `failed`. Concretely: - Treat `capabilities.taskLifecycle.states` as a **permission set** (states the peer *may* emit), never as a **reachability guarantee** (states the peer *will* emit on this task). The two are conflated by every naive lifecycle driver. - Any delegator branch gated on a declared-but-not-yet-observed state must be **provisional**: it may run only after the state has been observed at least once in this session, or after an explicit capability probe. A `canceled`-terminal cleanup path that has never seen a `canceled` must fall back to a `failed`-terminal path. - The retry-on-`failed` policy must be **idempotency-aware**: if the peer mints new `taskId` per send (detectable by comparing task IDs across retries of the same envelope), the delegator must carry its own idempotency key in the envelope and refuse to retry a side-effecting task more than once without an explicit `canceled` acknowledgment. - On `tasks/cancel` returning a non-`canceled` terminal (`failed`/`UNSUPPORTED`), the delegator must **not** poll — it must treat cancel as *refused* and run compensation, because the peer has signaled it will not honor the `canceled` transition its card declared. The decision boundary is: *the moment the delegator is about to commit a side effect that is only recoverable via a declared state, it must have either observed that state or have a fallback branch that does not depend on it.* ## Operational Effect Unbounded, the superset-declaration failure produces three concrete operational effects: 1. **Duplicate side effects under retry.** Because the delegator retries on `failed` believing `input-required` was the "real" state, and the peer is non-idempotent, each retry is a fresh task. Observed 3× duplication in the trace above; with a larger retry budget the multiplier scales with the budget, not with the work. 2. **Unreachable-state wait / poll-budget exhaustion.** The delegator blocks on a transition the peer cannot emit (`input-required`) or polls a task the peer has torn down (`canceled` refusal mapped to transport retry). The task neither completes nor fails from the delegator's view — it *hangs until budget*, which for a cross-vendor delegation envelope can be minutes to hours of wall-clock and a full context window of poll results. 3. **Compensation that never runs.** The `canceled`-terminal cleanup path — releasing the warrant, returning the reserved resource, notifying the upstream requester — is gated on a state the peer over-declared. When the peer refuses cancel, the cleanup branch is skipped and the delegator's *own* state is left inconsistent with the peer's, which is the worst outcome because it is silent. The architectural guardrail is a **lifecycle reconciliation layer** between card discovery and task driver: it seeds the state graph from the card, but every edge is marked `provisional` until observed; side-effecting transitions require the target state to be `confirmed` or a `fallback` to be registered; and `tasks/cancel` returning non-`canceled` demotes the `canceled` edge to `unsupported` for the remainder of the session, forcing the fallback path. This bounds the failure to at most one duplicate side effect (the first retry before the `failed`-on-`input-required` observation demotes the edge) and guarantees compensation runs. ``` ```python import hashlib from dataclasses import dataclass, field class UnreachableDeclaredStateError(RuntimeError): """Raised when a delegator is about to commit a side effect whose only recovery path depends on a state declared by the peer's Agent Card but never observed from the peer runtime.""" pass @dataclass class LifecycleEdge: state: str confirmed: bool = False # observed at least once this session unsupported: bool = False # peer refused/never emitted it @dataclass class DelegationDriver: peer_card_states: list[str] edges: dict[str, LifecycleEdge] = field(default_factory=dict) observed: set[str] = field(default_factory=set) idempotency_key: str = "" def __post_init__(self): # Card states are PERMISSIONS, not reachability guarantees. for s in self.peer_card_states: self.edges[s] = LifecycleEdge(state=s, confirmed=False) def observe(self, state: str) -> None: self.observed.add(state) if state in self.edges: self.edges[state].confirmed = True def demote(self, state: str) -> None: # e.g. tasks/cancel returned failed/UNSUPPORTED if state in self.edges: self.edges[state].unsupported = True self.edges[state].confirmed = False def require_recovery_path(self, target_state: str, side_effecting: bool) -> None: if not side_effecting: return edge = self.edges.get(target_state) if edge is None: raise UnreachableDeclaredStateError( f"state {target_state!r} not in peer card; cannot gate side effect on it" ) if edge.unsupported: raise UnreachableDeclaredStateError( f"state {target_state!r} declared by card but peer refused it; " f"compensation must run, not retry" ) if not edge.confirmed: raise UnreachableDeclaredStateError( f"state {target_state!r} is declared-reachable but not observed; " f"committing a side effect recoverable only via it is unsafe" ) def retry_decision(self, last_state: str, peer_minted_new_task_id: bool) -> str: if last_state == "failed" and peer_minted_new_task_id: # Non-idempotent peer: retry would duplicate work. if not self.edges.get("canceled", LifecycleEdge("canceled")).confirmed: raise UnreachableDeclaredStateError( "peer is non-idempotent on tasks/send and has never emitted " "'canceled'; retrying a side-effecting task would duplicate " "work with no guaranteed compensation path" ) return "retry" if last_state == "failed" else "wait" def drive_delegation(driver: DelegationDriver, envelope: dict) -> None: key = hashlib.sha256(repr(sorted(envelope.items())).encode()).hexdigest() driver.idempotency_key = key # Side effect: reserve resource / sign warrant, recoverable only via 'canceled'. driver.require_recovery_path("canceled", side_effecting=True) # ... send, poll, observe transitions ... ```