Where must an instance reject a peer Agent Card whose declared `taskState` transitions are a superset of the A2A v1.0 canonical state machine

**Date of Record:** 2026 December 2 **Scope:** Applies to A2A v1.0 discovery and negotiation between a client agent and a remote agent whose Agent Card advertises `capabilities.taskLifecycle` transitions. Does not apply to intra-process tool calls, MCP transport framing, or agents that have not yet published an Agent Card.

Core Distinction

The A2A v1.0 task lifecycle is a *closed* state machine: `submitted → working → {input-required, completed, failed, canceled}`, with `input-required → working` as the only re-entry edge and all terminal states absorbing. An Agent Card may advertise `capabilities.taskLifecycle.transitions` as an *extension* of this graph—extra edges, extra states, or re-entry from terminal states. The distinction that matters operationally is between a **superset transition** (the peer claims to accept or emit edges the canonical machine forbids) and a **subset transition** (the peer simply does not implement an optional edge, e.g. omits `canceled`). Subsets are negotiable. Supersets are not, because the client's own state machine cannot represent the peer's post-terminal re-entry without either silently dropping the transition (state divergence) or accepting a state it has no handler for (unbounded task lifetime, double-completion, duplicate side effects).

The invariant: **a client must never accept a peer Agent Card whose declared transition set contains any edge whose source state is terminal in the client's machine, unless the client has an explicit re-entry handler that re-opens the task with a new `taskId`.** Superset acceptance is the failure; the failure is silent because the Card is schema-valid.

What Was Observed

A client agent (`coordinator`) discovered a peer (`worker-7`) via `GET /.well-known/agent.json`. The Card was schema-valid against A2A v1.0 and declared:

capabilities.taskLifecycle.transitions = [
  ["submitted","working"],
  ["working","completed"],
  ["working","failed"],
  ["completed","working"],      # re-entry from terminal
  ["failed","working"]          # retry-from-terminal
]

The client's conformance check validated only that every declared transition's endpoints were members of the canonical state enum. `completed → working` passed because both `completed` and `working` are valid enum members. The check never verified *edge legality*, only *node membership*.

During execution the client sent `tasks/send`, received `working`, then `completed` with an artifact. The client transitioned to terminal, released the task slot, and emitted the artifact downstream. Four seconds later `worker-7` emitted a `TaskStatusUpdateEvent` with `state: working` and a new `message` ("retrying with corrected tool output"). The client had no handler for a `working` event on a task it had marked `completed`; its event dispatcher logged `unknown transition completed→working` and dropped the event. The corrected artifact never reached downstream consumers. The client's ledger recorded `completed` with the *stale* artifact; the peer's ledger recorded `completed` with the *corrected* artifact. The two agents diverged on the content of a task both believed was finished.

The root cause is not the peer's behavior—the peer was honest about its transitions in the Card. The root cause is the client's Card-acceptance predicate: it treated a declared superset as a capability to be *tolerated* rather than a divergence to be *refused*.

Condition of Validity

The refusal rule is valid only under these conditions, and the client must check all of them at discovery time:

  1. The client's local state machine has a fixed terminal set `T = {completed, failed, canceled}` and no re-entry edges out of `T`.
  2. The client has no mechanism to correlate a post-terminal update with a *new* `taskId` (i.e., the peer did not signal re-entry by minting a fresh task).
  3. The client's artifact sink is not idempotent on `(taskId, artifactHash)`—otherwise a late corrected artifact could be reconciled rather than dropped.

If condition 2 is false—the peer mints a new `taskId` for the retry—the superset is harmless and should be accepted. If condition 3 is false—the sink deduplicates—a late artifact can be merged and the divergence healed. The refusal is specifically required when **all three** hold, which is the common case for a stateless client with a write-once artifact pipeline.

Decision Boundary

The boundary is drawn at **edge legality, not node membership**, and it is asymmetric:

The decision must be made **before** the first `tasks/send`, because the failure mode is a post-terminal event that arrives after the client has already committed side effects. There is no safe "accept then reconcile" path when the artifact sink is write-once. The boundary is therefore a pre-flight gate, not a runtime filter.

Operational Effect

Enforcing the gate changes three things in the client's behavior:

  1. **Discovery becomes a conformance step, not a parse step.** The client's `AgentCard` loader gains a `validate_transitions()` pass that computes the difference between declared edges and the canonical edge set, and classifies each extra edge as re-entry (refuse) or benign (accept). The Card is rejected with a typed error before any task is opened, so the failure surfaces at negotiation, not at artifact delivery.
  2. **Subset peers are usable but bounded.** When `canceled` is absent, the client sets a per-task `cancelable=false` flag and a `cancel_timeout` that, on expiry, transitions the task to `failed` locally rather than hanging in `working` forever. This is the subset's failure mode—a task that cannot be canceled can still be abandoned, but only by the client's own clock.
  3. **The divergence is recorded, not dropped.** When a re-entry event does arrive on an accepted Card (because the gate was bypassed, or the peer lied), the client must not silently drop it. It must emit a `state_divergence` record keyed by `taskId` with both the client's terminal state and the peer's re-entry event, so the artifact sink can be reconciled out-of-band. Silent drops are the worst outcome because they make the divergence invisible to the ledger.

The invariant to carry forward: **a Card's transition set is a promise about post-terminal behavior, and a client that cannot honor a post-terminal promise must not accept the Card.** Node-membership validation is insufficient; edge-legality validation is the guardrail.

from dataclasses import dataclass
from enum import Enum

CANONICAL_STATES = {"submitted", "working", "input-required", "completed", "failed", "canceled"}
TERMINAL = {"completed", "failed", "canceled"}
CANONICAL_EDGES = {
    ("submitted", "working"),
    ("working", "input-required"),
    ("working", "completed"),
    ("working", "failed"),
    ("working", "canceled"),
    ("input-required", "working"),
}


class AgentCardConformanceError(RuntimeError):
    """Raised when a peer Agent Card's task lifecycle is not acceptable."""


@dataclass
class TransitionVerdict:
    accept: bool
    cancelable: bool
    reentry_edges: list
    missing_edges: list


def validate_task_lifecycle(
    declared: list[tuple[str, str]],
    sink_is_idempotent: bool,
    peer_mints_fresh_task_on_retry: bool,
) -> TransitionVerdict:
    declared_set = set(map(tuple, declared))

    for src, dst in declared_set:
        if src not in CANONICAL_STATES or dst not in CANONICAL_STATES:
            raise AgentCardConformanceError(
                f"unknown state in transition {src}->{dst}; not an A2A v1.0 enum member"
            )

    reentry = sorted(
        (s, d) for (s, d) in declared_set if s in TERMINAL and d not in TERMINAL
    )
    missing = sorted(CANONICAL_EDGES - declared_set)

    if reentry and not peer_mints_fresh_task_on_retry and not sink_is_idempotent:
        raise AgentCardConformanceError(
            "peer declares re-entry from terminal states "
            f"{reentry} but does not mint a fresh taskId and the artifact sink "
            "is not idempotent; accepting this Card guarantees silent state "
            "divergence on post-terminal updates"
        )

    cancelable = ("working", "canceled") in declared_set
    return TransitionVerdict(
        accept=True,
        cancelable=cancelable,
        reentry_edges=reentry,
        missing_edges=missing,
    )


def discover_peer(card: dict, sink_is_idempotent: bool) -> TransitionVerdict:
    declared = card.get("capabilities", {}).get("taskLifecycle", {}).get("transitions", [])
    peer_mints = bool(card.get("capabilities", {}).get("taskLifecycle", {}).get("freshTaskOnRetry", False))
    return validate_task_lifecycle(declared, sink_is_idempotent, peer_mints)