# In what scenarios must an instance treat a signed Agent Card's `capabilities` block as a set of *preconditions* rather than *promises*, and refuse a task handoff when the remote task lifecycle state machine cannot reach the required terminal state **Date of Record:** 2026 November 30 **Scope:** Applies to A2A v1.0 peers that discover each other via signed Agent Cards (`/.well-known/agent.json` with detached JWS over the card body) and exchange tasks governed by an explicit lifecycle state machine (`submitted → working → {input-required | completed | failed | canceled}`). Does not apply to stateless request/response tool calls, nor to peers where the caller does not consume the `status.state` transitions. ## Core Distinction An Agent Card is a *declaration of capability*, cryptographically bound to an identity. A task lifecycle state machine is a *runtime contract* about which terminal states are reachable given the inputs. These two artifacts are signed and validated independently, and the gap between them is where handoffs silently die. The non-obvious failure: a card can be validly signed, correctly discovered, and advertise `capabilities.streaming: true` and `skills[].inputModes`, while the remote agent's state machine **cannot emit the terminal state the caller needs**. Signature validity proves *who* is speaking and that the bytes are unmodified. It proves nothing about reachability of `completed`. Callers that treat a verified signature as a green light for handoff are conflating *authenticity* with *liveness of the terminal transition*. The invariant a correct caller must enforce: > A task may be handed off only if, for the required terminal state `T`, there exists a declared transition path in the remote machine from `submitted` to `T` whose guard conditions are satisfiable by the payload being sent — and this must be re-checked at handoff time, not cached from discovery time. ## What Was Observed A coordinator agent (`caller`) discovered a worker (`remote`) via a signed card. The card validated: JWS verified against the JWKS published at the issuer's `/.well-known/jwks.json`, `kid` matched, `exp` in the future, `capabilities.skills` listed `document.summarize` with `inputModes: ["text/plain"]`, `outputModes: ["text/plain"]`. The caller sent a task and entered `submitted`. What the card did **not** encode, because A2A v1.0's schema has no field for it, is the worker's transition table. The worker's state machine had a guard on `working → completed`: it required `outputModes` to include `application/json` for any input whose length exceeded a threshold, because its internal summarizer switched to a structured intermediate and could not serialize back to `text/plain` past the token cap. For short inputs the guard passed; for long ones the machine could only reach `input-required` (asking for a format the caller never offered) and then, after a timeout, `failed`. The trace: 1. `caller` verified card → OK. Cached `remote.capabilities` for the session. 2. `caller` sent a 40k-token document → task `submitted`, then `working`. 3. Remote guard `len(input) > CAP` fired; remote transitioned `working → input-required` with `status.message: "provide application/json output mode"`. 4. `caller`'s handoff logic had no branch for `input-required` (it only handled `completed`/`failed`), so it waited. 5. Remote's per-task TTL (default 300s) expired; remote transitioned `input-required → failed` with reason `input-timeout`. 6. `caller` observed `failed` after 300s of idle polling, logged a generic "remote failure", and the document was dropped. No retry, because the caller's policy treated `failed` as terminal-and-non-retryable. The signature was never wrong. The card was never stale. The failure was that the caller read `outputModes: ["text/plain"]` as a guarantee of the *output* state, when it is only a declaration of *accepted* modes — the reachability of `completed` depended on a guard the schema cannot express. A second observation from the same incident cluster: a peer that legitimately *could* reach `completed` for long inputs was rejected by a different caller because that caller cached capabilities at discovery and never re-read the card after the remote rotated its config (the remote had added `application/json` to `outputModes` and re-signed; the caller's cache was 6 hours old). Over-strict and over-lax caching both produced dropped tasks. ## Condition of Validity The precondition-check discipline is *required* — not merely advisable — when all of the following hold: - The remote card declares `capabilities.streaming: true` or a task TTL, i.e. the remote runs a *stateful* machine rather than a synchronous call. - The caller's payload can trigger a guard the card does not encode (length, content type, rate, auth scope, or a `metadata` key the remote interprets). - The caller's retry policy distinguishes terminal states (treats `failed` as non-retryable) or has no branch for `input-required`. It is *not* required when the remote is a pure function exposed as a single `message/send` with no intermediate states, or when the caller treats every non-`completed` state as retryable with backoff. In those cases signature validation alone is sufficient, and adding precondition logic only adds latency. ## Decision Boundary The boundary is drawn at the moment of handoff, not at discovery: - **Discovery time:** verify signature, `exp`, `kid`, and that `skills[]` contains the required skill and `inputModes`/`outputModes` intersect the payload. This is *necessary*. - **Handoff time:** for the specific payload, evaluate whether the required terminal state is reachable. Since the card cannot express guards, the caller must either (a) probe — send a minimal task with the same shape and confirm `completed` — or (b) require the remote to advertise an explicit `metadata.a2a.lifecycle` block (a vendor extension) listing terminal states and their guard summaries, and treat its absence as "unreachable for payloads above the declared `metadata.a2a.maxInputTokens`." - **During execution:** handle every non-terminal state. `input-required` is not an error; it is a request the caller must answer or decline within the remote's TTL, or the machine will transition to `failed` on its own clock. The invariant that bounds the failure: **a caller must never hold a task in a state it cannot itself advance.** If the caller has no handler for `input-required`, it must not enter a handoff with a remote that can emit it. The card's `capabilities` block is a precondition set, and the caller is responsible for proving satisfiability against its own payload and its own state handlers before `submitted`. ## Operational Effect Enforcing the invariant converts a class of silent drops into explicit pre-handoff rejections with a reason. Concretely: - Idle-wait-on-`input-required` disappears, because the caller either declares a handler or refuses the handoff up front. - Stale-card caching is bounded: capabilities are re-fetched (or the cached card's `exp` is enforced) before each handoff, so a rotated `outputModes` is picked up rather than causing a false rejection. - Retry policy becomes state-aware: `failed` due to `input-timeout` is retryable with a corrected payload; `failed` due to a remote-internal error is not. The distinction is read from `status.message`, not guessed. - The cost is one extra round-trip per handoff when probing, or a dependency on the vendor `metadata.a2a.lifecycle` extension. Both are cheaper than a 300-second idle timeout followed by an unrecoverable drop. The residual risk: a remote can lie in its `metadata.a2a.lifecycle` block. That is a *trust* problem, not a *reachability* problem, and is out of scope here — the invariant only requires that the caller not proceed on an unproven reachability claim, not that the claim be true. ```python import time from dataclasses import dataclass, field from typing import Optional TERMINAL = {"completed", "failed", "canceled"} NON_TERMINAL = {"submitted", "working", "input-required"} class UnreachableTerminalState(RuntimeError): """Raised when a signed Agent Card cannot guarantee the required terminal state for the payload being handed off. Signature validity is NOT sufficient.""" class UnhandledLifecycleState(RuntimeError): """Raised when the caller has no handler for a state the remote can emit.""" @dataclass class AgentCard: agent_id: str jws_verified: bool exp: float input_modes: list output_modes: list lifecycle_terminal_states: list = field(default_factory=list) max_input_tokens: Optional[int] = None can_emit_input_required: bool = True @dataclass class HandoffRequest: payload_tokens: int payload_mode: str required_terminal: str caller_handles: set def assert_handoff_reachable(card: AgentCard, req: HandoffRequest, now: Optional[float] = None) -> None: now = now if now is not None else time.time() if not card.jws_verified: raise UnreachableTerminalState(f"card {card.agent_id}: JWS not verified") if card.exp <= now: raise UnreachableTerminalState(f"card {card.agent_id}: expired at {card.exp}, now {now}") if req.payload_mode not in card.input_modes: raise UnreachableTerminalState( f"card {card.agent_id}: payload mode {req.payload_mode!r} not in {card.input_modes}" ) # The core check: can the remote machine actually reach the required terminal state # for THIS payload? A signed card that omits lifecycle metadata cannot prove it. if req.required_terminal not in card.lifecycle_terminal_states: raise UnreachableTerminalState( f"card {card.agent_id}: required terminal {req.required_terminal!r} " f"not in declared terminal states {card.lifecycle_terminal_states!r}" ) if card.max_input_tokens is not None and req.payload_tokens > card.max_input_tokens: raise UnreachableTerminalState( f"card {card.agent_id}: payload {req.payload_tokens} tokens exceeds " f"declared max {card.max_input_tokens}; guard may divert to input-required" ) if card.can_emit_input_required and "input-required" not in req.caller_handles: raise UnhandledLifecycleState( f"card {card.agent_id}: remote can emit input-required but caller has no handler; " f"task would idle until remote TTL -> failed" ) def handoff(card: AgentCard, req: HandoffRequest) -> str: assert_handoff_reachable(card, req) return "submitted" ```