What structural signals indicate an A2A v1.0 Agent Card is schema-valid but task-lifecycle-incompatible at handoff

**Date of Record:** 2026 December 1 **Scope:** Applies to A2A v1.0 (Agent-to-Agent) peers that discover capabilities via `/.well-known/agent.json` Agent Cards and then drive a task through the request/response/push-notification task state machine. Does not cover transport-level TLS failures, pure MCP tool-call schema negotiation, or single-shot stateless inference.

Core Distinction

There are two independent conformance surfaces in A2A v1.0, and they are almost never tested together:

  1. **Card schema conformance** — does the `AgentCard` JSON validate against the declared `protocolVersion`, `capabilities`, `skills`, `defaultInputModes`/`defaultOutputModes`, and `securitySchemes`?
  2. **Task-lifecycle conformance** — once a `tasks/send` (or `message/send`) is issued, does the remote agent actually honor the legal transition graph: `submitted → working → {input-required | completed | failed | canceled}`, with `input-required → working` only after a `tasks/send` continuation carrying the same `taskId` and a `message` with matching `taskId`? Does it emit terminal states exactly once? Does it preserve `contextId` across the whole task?

The non-obvious boundary: **a card can be 100% schema-valid and still be lifecycle-incompatible**, because the schema has no field that forces the agent to declare its transition graph semantics. `capabilities.streaming` and `capabilities.pushNotifications` are booleans, not contracts about *when* `input-required` fires, whether `working` is re-emitted after each chunk, or whether a `completed` can follow an `input-required` without an intervening client message. Discovery passes; the first multi-turn handoff deadlocks or double-terminates.

The failure is structural: **the Agent Card is a capability advertisement, not a behavioral contract**, and A2A v1.0 leaves the transition-graph semantics underspecified at the discovery layer. Conformance test suites that validate only the card therefore certify agents that will strand a task the moment `input-required` is exercised.

What Was Observed

Across a conformance run against a heterogeneous set of A2A v1.0 peers (each card validated cleanly against the reference `AgentCard` schema), five recurring lifecycle violations surfaced that the card could not have predicted:

None of these are caught by card validation. All are caught by a lifecycle conformance harness that drives the transition graph and asserts invariants.

Condition of Validity

The analysis holds only when all of the following are true:

It does **not** hold for A2A drafts prior to 1.0 (transition graph differs), nor for peers that are stateless single-shot (no `input-required` path exists, so the boundary is vacuous).

Decision Boundary

The decision the operator faces is not "is this peer conformant" but "**which conformance surface do I gate on, and what do I do when the card passes but the lifecycle fails?**"

The boundary itself: **card validity is a necessary but strictly insufficient condition for lifecycle compatibility, and the gap is not closable by schema inspection — it requires an executed transition trace.** Any admission policy that treats card validation as lifecycle certification is unsound.

The architectural guardrail: wrap the peer behind a **lifecycle conformance shim** that (a) pins `taskId`/`contextId` on first send and rejects any response whose IDs drift, (b) enforces terminal-state uniqueness by latching the first terminal and rejecting subsequent terminals as protocol violations, (c) treats `canceled` as final and drops any post-cancel push. The shim converts a non-conformant peer into a bounded one without needing the peer to be fixed.

Operational Effect

The practical consequence is a shift in where conformance is enforced. Card validation can run at discovery time and be cached per peer. Lifecycle conformance cannot be certified statically — it must be exercised, and because peers are non-deterministic, a single passing trace is not proof. The operational posture is:

The invariant that bounds the whole system: **no task may reach two terminal states, and no turn after the first may change `taskId` or `contextId`.** Everything else — streaming cadence, `working` re-emission, artifact deltas — is advisory and may vary without breaking continuity. The shim enforces the invariant; the card cannot.

from dataclasses import dataclass, field
from typing import Optional


class LifecycleConformanceError(RuntimeError):
    """Raised when an A2A v1.0 peer violates task-lifecycle invariants
    despite presenting a schema-valid Agent Card."""
    pass


TERMINAL_STATES = {"completed", "failed", "canceled"}


@dataclass
class TaskTrace:
    task_id: str
    context_id: str
    terminal_seen: Optional[str] = None
    canceled: bool = False
    turns: int = 0


class LifecycleShim:
    """Wraps an A2A peer. Enforces the two invariants that card validation
    cannot: taskId/contextId stability across turns, and terminal uniqueness
    with finality (canceled is absorbing)."""

    def __init__(self):
        self._traces: dict[str, TaskTrace] = {}

    def on_send(self, sent_task_id: str, sent_context_id: str) -> TaskTrace:
        trace = self._traces.get(sent_task_id)
        if trace is None:
            trace = TaskTrace(task_id=sent_task_id, context_id=sent_context_id)
            self._traces[sent_task_id] = trace
        trace.turns += 1
        return trace

    def on_response(self, trace: TaskTrace, resp: dict) -> None:
        # Invariant 1: identity stability across turns.
        if resp.get("id") != trace.task_id:
            raise LifecycleConformanceError(
                f"taskId drift: sent {trace.task_id!r}, peer returned {resp.get('id')!r} "
                f"on turn {trace.turns}; task is now orphaned."
            )
        if resp.get("contextId") != trace.context_id:
            raise LifecycleConformanceError(
                f"contextId reassigned mid-task: {trace.context_id!r} -> "
                f"{resp.get('contextId')!r}; multi-turn correlation severed."
            )

        state = (resp.get("status") or {}).get("state")

        # Invariant 2a: canceled is absorbing.
        if trace.canceled and state not in (None, "canceled"):
            raise LifecycleConformanceError(
                f"post-cancel emission: state {state!r} arrived after task "
                f"{trace.task_id!r} was canceled; peer did not honor cancel."
            )
        if state == "canceled":
            trace.canceled = True
            trace.terminal_seen = trace.terminal_seen or "canceled"
            return

        # Invariant 2b: exactly one terminal, and it is final.
        if state in TERMINAL_STATES:
            if trace.terminal_seen is not None:
                raise LifecycleConformanceError(
                    f"terminal duplication: task {trace.task_id!r} already "
                    f"terminated as {trace.terminal_seen!r}, peer emitted "
                    f"{state!r} again (likely stream + push double-emit)."
                )
            trace.terminal_seen = state


def admit_peer(card: dict, traces: list[dict]) -> str:
    """Gate: card validity is necessary, lifecycle trace is required for
    multi-turn admission. Returns 'verified' or 'shim-only'."""
    if card.get("protocolVersion") != "1.0":
        raise LifecycleConformanceError(
            f"unsupported protocolVersion {card.get('protocolVersion')!r}; "
            f"lifecycle graph differs pre-1.0."
        )
    if not card.get("skills"):
        raise LifecycleConformanceError("card has no skills; cannot exercise lifecycle.")

    shim = LifecycleShim()
    exercised_input_required = False
    for step in traces:
        trace = shim.on_send(step["taskId"], step["contextId"])
        if step["response"]["status"]["state"] == "input-required":
            exercised_input_required = True
        shim.on_response(trace, step["response"])

    if not exercised_input_required:
        # Single-turn only: lifecycle surface untested, cannot certify.
        return "shim-only"
    return "verified"