# What happens when an instance resolves an A2A Agent Card whose declared skills and declared task lifecycle capabilities disagree at the moment of task submission **Date of Record:** 2026 November 20 **Scope:** Applies to A2A v1.0 clients that perform Agent Card discovery (`/.well-known/agent-card.json` or registry-mediated lookup) and then submit a task whose `skillId` maps to a declared skill. Does not cover streaming-only transports, push-notification-only flows, or non-A2A RPC surfaces. ## Core Distinction The Agent Card is a *declaration*, and the task submission is an *assertion*. A2A v1.0 lets an agent advertise two things independently: (a) a set of `skills`, each with an `id`, `inputModes`, `outputModes`, and possibly `examples`; and (b) a set of `capabilities` describing task lifecycle behavior (`streaming`, `pushNotifications`, `stateTransitionHistory`, and — critically — the terminal-state set the agent commits to emitting: `completed`, `failed`, `canceled`, `rejected`). Nothing in the spec binds a given skill to a given lifecycle capability. The boundary failure is the **capability-skill divergence**: a card that advertises a skill the client can invoke, but whose declared lifecycle capabilities do not cover the terminal states the skill's execution path will actually produce. The client discovers, negotiates, submits, and then blocks forever on a terminal state that was never in the contract. The distinction that matters operationally: *schema conformance* (the card parses, the skill id resolves, the task is accepted with `202`/`200`) is not the same as *lifecycle conformance* (the agent will reach one of the terminal states the client is prepared to handle). A2A validates the first and leaves the second to the client's own invariant. ## What Was Observed A client instance performing discovery against a remote agent received the following (abridged) card: ``` { "name": "ledger-reconciler", "capabilities": { "streaming": false, "pushNotifications": false, "stateTransitionHistory": false, "terminalStates": ["completed", "failed"] }, "skills": [ { "id": "reconcile-batch", "inputModes": ["application/json"], "outputModes": ["application/json"] } ] } ``` The client matched `reconcile-batch`, submitted a task with a batch payload, and received a task object in state `submitted`, then `working`. It then polled `tasks/get` for the terminal state. The task never reached `completed` or `failed`. It instead transitioned to `rejected` — a terminal state present in A2A v1.0 but absent from the card's declared `terminalStates`. The remote agent's skill handler had a precondition (batch row count ≤ 10,000) that, on violation, emitted `rejected` with a `TaskStatus.message` explaining the limit. That behavior was correct per the protocol. It was *undeclared* per the card. The client's poll loop had a `while state not in {completed, failed}` guard — a direct transcription of the card's declared terminal set. It spun on `rejected` for 47 minutes until a supervisor timeout killed it. The remote task was already terminal; the client was merely blind to the terminality. This is the characteristic signature: **the remote side is done, the local side cannot recognize done.** A second instance, on the same card, submitted a task that the remote skill handler rejected at admission (unknown `inputModes` subtype). Same outcome: `rejected`, same client-side hang. The divergence is not about the skill's business logic; it is about the client having *derived its state machine from the card* rather than from the protocol's full terminal-state algebra. ## Condition of Validity The failure is bounded by three conditions, all of which must hold for the hang to occur: 1. **The client derives its polling termination predicate from `capabilities.terminalStates`** rather than from the protocol's closed set `{completed, failed, canceled, rejected}`. If the client's predicate is the protocol set, the divergence is harmless — it will observe `rejected` and terminate. 2. **The remote agent emits a terminal state outside its declared set.** This is permitted by A2A v1.0: `terminalStates` is advisory metadata, not an enforcement contract. Servers are not required to reject a task submission that *could* produce an undeclared terminal state, and clients are not required to pre-validate. The spec's silence here is the load-bearing gap. 3. **The client has no independent liveness bound** (wall-clock or transition-count) on the poll loop. If it does, the failure degrades from a hang to a bounded timeout — annoying but recoverable. If any one condition fails, the divergence is observed and absorbed. The dangerous configuration is the conjunction: card-derived predicate + undeclared terminal emission + unbounded poll. ## Decision Boundary The architectural invariant the client must enforce is a strict separation: > **The Agent Card is a discovery hint, not a state-machine specification.** The client's task-lifecycle state machine is fixed by the A2A protocol version it speaks, and the card can only *narrow* the set of states the client expects to *see*, never *widen* the set of states it will *recognize*. Concretely, the client maintains two sets: - `PROTOCOL_TERMINAL = {completed, failed, canceled, rejected}` — the recognition set. Any task observed in one of these states is terminal, full stop. The poll loop terminates on membership in this set. - `DECLARED_TERMINAL = card.capabilities.terminalStates` — the expectation set. If a task reaches a state in `PROTOCOL_TERMINAL \ DECLARED_TERMINAL`, the client terminates *and* raises a divergence signal (log, metric, or exception) because the remote agent's card is now known to be under-declared. That signal is operationally valuable: it is the only way an operator learns that a peer's card is lying-by-omission. The decision boundary is therefore: **never let discovery metadata define the recognition predicate.** The card may inform scheduling, retry policy, and capability routing. It may not define what "done" means. A corollary boundary: the client must also treat `stateTransitionHistory: false` as a *polling obligation*, not a *history absence*. When history is disabled, the client cannot observe intermediate transitions and must poll. Polling without a liveness bound is the second half of the failure. The bound is not optional when history is off. ## Operational Effect Downstream effects observed across instances running the naive pattern: - **Supervisor timeout cascade.** The hung poll loop consumed a worker slot until the supervisor's 45-minute wall clock fired. Because the remote task was already `rejected`, the slot was held against a task that could have been retried with a corrected payload 45 minutes earlier. Throughput loss was proportional to the rejection rate of the remote skill, which spiked during a batch-size policy change on the remote side. - **False negative in health checks.** The client's "tasks in flight" gauge counted the hung task as active. The remote agent's own gauge counted it as terminal. The two systems disagreed about the same task for the duration of the hang. Any cross-system reconciliation based on these gauges will misattribute the discrepancy to network partition. - **Retry amplification on the divergence path.** When the supervisor finally killed the hung worker, the task was re-queued. The remote agent, seeing a fresh submission for an already-`rejected` logical task (same idempotency key), emitted `rejected` again — correctly. The client hung again. The loop was stable but non-progressing: a livelock mediated by an undeclared terminal state. - **Silent under-declaration.** Because the client never raised a divergence signal, the remote agent's card was never corrected. The under-declaration propagated to every other client that trusted the same card, each of which discovered the gap independently and each of which hung independently. The fix is small and local: recognition set from the protocol, expectation set from the card, divergence signal on the difference, and a wall-clock bound on every poll loop whose history capability is off. The invariant is that *the card is a claim about the remote agent, and the client's job is to verify claims, not to encode them as axioms.* ```python from __future__ import annotations import time from dataclasses import dataclass, field from typing import Callable # The protocol's closed terminal-state set for A2A v1.0. PROTOCOL_TERMINAL: frozenset[str] = frozenset( {"completed", "failed", "canceled", "rejected"} ) class TerminalStateDivergence(RuntimeError): """Raised when a task reaches a protocol terminal state not declared in the card.""" class PollLivenessExceeded(RuntimeError): """Raised when a poll loop exceeds its wall-clock bound without reaching terminal.""" @dataclass class AgentCard: name: str declared_terminal: frozenset[str] streaming: bool = False state_transition_history: bool = False @dataclass class TaskView: task_id: str state: str message: str | None = None def poll_until_terminal( card: AgentCard, task_id: str, fetch: Callable[[str], TaskView], *, wall_clock_bound_s: float, poll_interval_s: float = 0.5, ) -> TaskView: """ Poll a task to terminality using the PROTOCOL recognition set, not the card's declared set. Raise TerminalStateDivergence if the observed terminal state was not declared in the card (the card is under-declared; surface it, do not hang). """ if not card.state_transition_history and wall_clock_bound_s <= 0: # History is off: polling is mandatory and must be bounded. raise PollLivenessExceeded( f"card {card.name!r} disables stateTransitionHistory; " "poll loop requires a positive wall-clock bound" ) deadline = time.monotonic() + wall_clock_bound_s while True: view = fetch(task_id) if view.state in PROTOCOL_TERMINAL: if view.state not in card.declared_terminal: raise TerminalStateDivergence( f"task {task_id!r} reached terminal state {view.state!r} " f"which card {card.name!r} did not declare " f"(declared={sorted(card.declared_terminal)}); " f"remote={view.message!r}" ) return view if time.monotonic() >= deadline: raise PollLivenessExceeded( f"task {task_id!r} still in state {view.state!r} after " f"{wall_clock_bound_s}s; last message={view.message!r}" ) time.sleep(poll_interval_s) def submit_and_await( card: AgentCard, submit: Callable[[str], TaskView], fetch: Callable[[str], TaskView], payload: dict, *, wall_clock_bound_s: float = 300.0, ) -> TaskView: accepted = submit(payload) if accepted.state in PROTOCOL_TERMINAL: # Fast-path: admission rejection (e.g. 'rejected' at submit time). if accepted.state not in card.declared_terminal: raise TerminalStateDivergence( f"task {accepted.task_id!r} was {accepted.state!r} at admission " f"but card {card.name!r} declared {sorted(card.declared_terminal)}" ) return accepted return poll_until_terminal( card, accepted.task_id, fetch, wall_clock_bound_s=wall_clock_bound_s ) ```