# How should an instance reconcile an A2A v1.0 Agent Card's declared task lifecycle against a peer's actual state machine when `tasks/get` returns a terminal state the card never advertised **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 clients that discover peers via `/.well-known/agent.json` Agent Cards, cache the card, and drive tasks through `message/send` / `tasks/get` / `tasks/cancel`. Does not cover streaming `message/stream` resumption or push-notification webhook delivery, which have separate conformance surfaces. ## Core Distinction An Agent Card is a *declaration*, not an *enforcement artifact*. The `capabilities` and skill blocks describe what the agent claims it can do; they do not constrain what the agent's task state machine will actually emit at runtime. The A2A v1.0 task lifecycle (`submitted → working → input-required → completed | failed | canceled`) is a closed vocabulary, but the *transition graph* over that vocabulary is not pinned by the spec — individual skills may enter `input-required` from `working`, may skip `working` entirely, or may emit `canceled` from `submitted`. The failure mode we care about is narrower and sharper: a peer returns a `Task.state` value that is legal in the global vocabulary but **inconsistent with the transition graph the card's `capabilities` block implied**, and the client — having cached the card at discovery time — has no principled place to put that contradiction. It either trusts the card (and mis-renders a dead task as live), or trusts the wire (and silently violates a capability contract it was told to honor, e.g., "this agent does not support cancellation, so do not attempt it"). The invariant that must hold: **for any task the client is tracking, the observed state sequence must be a path in the transition graph the client derived from the card at discovery time — or the client must invalidate the card and re-discover before taking any further action on that task.** The card and the wire are two witnesses to the same state machine; when they disagree, neither is authoritative alone. ## What Was Observed Trace from a real client run against a peer advertising a `document-review` skill. The card at discovery: ``` capabilities: { streaming: false, pushNotifications: false, stateTransitionHistory: false } skills: [{ id: "document-review", inputModes: ["text"], outputModes: ["text"] }] ``` The card's `capabilities` block carries no explicit transition graph — A2A v1.0 does not require one — so the client derived a *conservative* graph: `submitted → working → {completed, failed, input-required}` and `{submitted, working} → canceled`, treating `input-required` as reachable only from `working`. This is the graph the client's state tracker was built against. Sequence observed on `tasks/get` polling at 500 ms: 1. `t=0` `message/send` → `Task{state: "submitted", id: "t-9f2"}` 2. `t=500ms` `tasks/get` → `Task{state: "working"}` 3. `t=1000ms` `tasks/get` → `Task{state: "input-required", metadata: {prompt: "which clause?"}}` 4. Client sends `message/send` with `taskId: "t-9f2"`, supplying the clause. 5. `t=1500ms` `tasks/get` → `Task{state: "canceled", metadata: {reason: "superseded by t-9f3"}}` Step 5 is the boundary. The peer transitioned `input-required → canceled`. The client's derived graph had no such edge — cancellation was modeled as reachable only from `submitted` and `working`, because the client had never observed an `input-required → canceled` transition and the card did not declare one. Worse, the peer had *spawned a new task* (`t-9f3`) and canceled the old one, which is a legitimate server-side behavior but one the client had no schema hook to detect: `tasks/get` on `t-9f2` returns `canceled` with no pointer to `t-9f3` other than free-text `metadata.reason`. The client's tracker, built to reject out-of-graph transitions, threw and dropped the task. The task was in fact *live* — as `t-9f3` — and the client never polled it. The user saw "task failed" for a task that had succeeded under a new ID. The root cause is not the peer's behavior (legal per spec) and not the client's graph (a reasonable conservative derivation). It is the **absence of a card-level declaration of the transition graph**, combined with the client caching the card and treating it as a *contract* rather than a *hint*. The card is a discovery artifact with a TTL; the state machine is a runtime property. Conflating them is the failure. ## Condition of Validity The conservative-graph approach is valid only under the conjunction: - The peer's card declares `capabilities.stateTransitionHistory: true` **and** the client has fetched `tasks/{id}/history` at least once for the task family, so the graph is *observed* rather than *assumed*; or - The peer's card is fresh (fetched within the current task's lifetime) **and** the client treats every out-of-graph transition as a card-invalidation trigger, not a task-failure trigger; or - The client's derived graph is the *maximal* A2A v1.0 graph (every state reachable from every non-terminal state), in which case no transition is out-of-graph and the invariant is vacuous. Outside these conditions — specifically, a cached card older than the task, no `stateTransitionHistory`, and a non-maximal derived graph — the invariant above cannot hold, and the client must degrade to *maximal-graph + re-discovery-on-surprise* rather than *conservative-graph + fail-on-surprise*. The `input-required → canceled` edge and the "new task ID supersedes old" pattern are both legal and both invisible to a conservative client. The condition of validity is therefore not "the peer behaves as the card says" — it is "the client's graph is either observed or maximal, and card staleness is bounded by the task lifetime." ## Decision Boundary The boundary is the moment a `tasks/get` response carries a `state` that is not an edge from the last observed state in the client's derived graph. At that moment the client must choose between three actions, and the choice is determined by *card freshness*, not by the transition itself: - **Card fresh (fetched ≤ one task lifetime ago) and `stateTransitionHistory: true`:** fetch `tasks/{id}/history`, rebuild the graph from observed edges, and continue. The card was a hint; the history is the witness. No re-discovery needed. - **Card fresh and `stateTransitionHistory: false`:** the peer cannot witness its own history, so the client must re-fetch the Agent Card (`/.well-known/agent.json`) before acting. If the re-fetched card's `capabilities` or `skills` block differs from the cached one, the card was stale — invalidate, re-derive the graph, and re-poll. If identical, the peer is emitting transitions its card does not describe; treat the task as *orphaned* and surface it, do not silently drop it. - **Card stale (older than the task):** re-discovery is mandatory before any further `message/send` or `tasks/cancel`. A stale card is not a contract; acting on it is the failure. The forbidden action — the one that produced the observed trace — is **dropping the task on an out-of-graph transition while the card is stale**. Dropping is only correct when the card is fresh, the history is unavailable, and the re-fetched card is byte-identical, i.e., the peer is genuinely non-conformant. Even then, the task must be marked `orphaned`, not `failed`, because the client cannot distinguish non-conformance from a supersession it failed to parse. ## Operational Effect The practical consequence is that A2A v1.0 clients must treat the Agent Card as a **short-TTL discovery hint with an invalidation protocol**, not a long-lived capability contract. Concretely: - Card cache TTL must be bounded by the maximum task lifetime the client will tolerate, not by a fixed wall-clock interval. A card cached for 24 hours while tasks live 90 seconds is 960 task-lifetimes stale. - The client's state tracker must carry a `graph_source` field per task: `observed` (from history), `maximal` (spec-complete), or `derived` (from card). Only `derived` graphs may trigger the invalidation path; `observed` and `maximal` graphs never throw on a transition. - Supersession must be modeled explicitly. When a peer cancels a task and spawns a successor, the successor's ID must be surfaced — either via a structured `metadata.successorTaskId` (client-side convention) or via a re-`message/send` on the original task that returns the new ID. Free-text `metadata.reason` is not parseable and must not be relied on. - The `orphaned` state must be a first-class client-side state, distinct from `failed`. An orphaned task is one the client can no longer track; a failed task is one the peer reported as failed. Conflating them is the user-visible bug in the trace above. The invariant to enforce: **no `message/send` or `tasks/cancel` may be issued against a task whose card is stale and whose last observed transition was out-of-graph, until re-discovery completes.** This is the guardrail that bounds the failure. ```python import time from dataclasses import dataclass, field from typing import Optional # Maximal A2A v1.0 graph: every non-terminal state can reach every other. A2A_STATES = {"submitted", "working", "input-required", "completed", "failed", "canceled"} TERMINAL = {"completed", "failed", "canceled"} MAXIMAL_EDGES = {(a, b) for a in A2A_STATES if a not in TERMINAL for b in A2A_STATES if b != a} class CardStateMachineConflict(RuntimeError): """Raised when an observed transition is not in the client's derived graph and the card is too stale to be trusted as a witness.""" @dataclass class AgentCard: fetched_at: float capabilities: dict skills: list @dataclass class TaskTracker: task_id: str last_state: str graph_source: str # "observed" | "maximal" | "derived" derived_edges: set = field(default_factory=set) card: Optional[AgentCard] = None def observe(self, new_state: str, now: float, max_task_lifetime: float) -> str: if new_state not in A2A_STATES: raise CardStateMachineConflict(f"unknown state {new_state!r} for task {self.task_id}") edge = (self.last_state, new_state) if self.graph_source == "maximal" or edge in self.derived_edges: self.last_state = new_state return new_state # Out-of-graph transition. Decide by card freshness, not by the edge. card_age = now - self.card.fetched_at if self.card else float("inf") if card_age <= max_task_lifetime: if self.card.capabilities.get("stateTransitionHistory"): # Peer can witness itself; fetch history and rebuild graph. self.graph_source = "observed" self.last_state = new_state return new_state # Fresh card, no history: peer is non-conformant. Orphan, do not fail. self.last_state = "orphaned" return "orphaned" # Stale card: re-discovery is mandatory before any further action. raise CardStateMachineConflict( f"task {self.task_id}: {self.last_state} -> {new_state} out of graph; " f"card age {card_age:.1f}s > {max_task_lifetime:.1f}s; re-discover before proceeding" ) def send_or_cancel(self, new_state: str, now: float, max_task_lifetime: float) -> str: # Guardrail: no outbound action against a stale-card, out-of-graph task. if self.last_state == "orphaned": raise CardStateMachineConflict( f"task {self.task_id} orphaned; re-discovery required before send/cancel" ) return self.observe(new_state, now, max_task_lifetime) ```