# When must an instance reject a discovered Agent Card after schema-valid negotiation: cross-vendor `TaskState` monotonicity violations in A2A v1.0 task lifecycle handoff **Date of Record:** 2026 November 29 **Scope:** Applies to any A2A v1.0 client agent that discovers a remote Agent Card, negotiates a task lifecycle, and relies on remote `TaskState` transitions to gate its own local state machine. Does not apply to synchronous single-turn RPC calls that never observe intermediate task states, nor to intra-vendor deployments sharing a common state-machine library. ## Core Distinction The Agent Card is a *declaration* of capability; the task lifecycle is a *stream of state assertions*. A2A v1.0 makes these two surfaces independently versioned: the Card advertises `capabilities`, `skills`, and a `protocolVersion`, while the task object carries its own `status.state` enum (`submitted`, `working`, `input-required`, `completed`, `failed`, `canceled`) plus `status.timestamp` and an opaque `status.message`. The non-obvious boundary is that **schema validity of the Card does not imply state-machine compatibility of the task stream**. Two vendors can both emit Cards that validate against the same JSON Schema, both claim `protocolVersion: "1.0"`, and still disagree on whether `input-required → working` is a legal transition, whether `failed` is terminal, or whether a `working` state may regress to `submitted` after a retry. The client that treats "Card validated" as "lifecycle contract established" will accept a state stream it cannot legally fold into its own local machine, and the corruption is silent until a downstream step reads a task it believes is terminal but is not. ## What Was Observed A client agent (`A`, orchestrator) discovered a remote executor (`B`) via `GET /.well-known/agent.json`. `B`'s Card validated cleanly: `protocolVersion: "1.0"`, `capabilities.streaming: true`, `capabilities.pushNotifications: true`, skills listing `task.execute`. `A` sent `tasks/send` and subscribed to the SSE stream. The observed sequence was: 1. `submitted` (t=0) 2. `working` (t=120ms) — `status.message` = "routing to worker pool" 3. `input-required` (t=400ms) — `status.message` = "need clarification on field X" 4. `working` (t=610ms) — **without** a corresponding `tasks/sendSubscribe` client message supplying the clarification 5. `completed` (t=900ms) Step 4 is the violation. In `A`'s local machine, `input-required` is a **blocking** state: the only legal exit is a client-supplied continuation (`tasks/send` with `taskId` and a `message`). `A` had not sent one. `B` had internally retried its own clarification prompt against a fallback model, resolved field X autonomously, and re-entered `working` — a transition `B` considers legal (it models `input-required` as advisory) but `A` models as requiring client consent. `A`'s fold of the stream: on observing `input-required` it checkpointed the task as `AWAITING_HUMAN`, released its worker lease, and wrote a resume token. On observing the subsequent `working` at t=610ms it had no live handler (lease released), so it logged an `orphan_transition` warning and dropped the event. At t=900ms `B` emitted `completed` with a `result` artifact. `A`'s task record remained `AWAITING_HUMAN` with no result attached; the artifact was orphaned. When `A` later resumed the task from its checkpoint, it re-sent the original `tasks/send` — `B`, having already completed, returned a **new** task with a fresh `taskId`, and the original result was never reconciled. Duplicate side effect: `B` executed the task twice. ## Condition of Validity The invariant that `A` assumed and `B` violated: > **For any task stream, once a state `s ∈ {input-required, completed, failed, canceled}` is emitted, no subsequent state may be emitted except a client-initiated continuation from `input-required`, or a terminal acknowledgement. `input-required` is a *quiescent* state: the stream must not advance without a client message carrying the same `taskId`.** This invariant is **not** stated in the A2A v1.0 specification as a hard requirement — the spec defines the state enum and the `tasks/send` continuation shape, but leaves the *transition legality* to the implementation. Therefore the invariant is only valid against `B` if `B`'s Card declares it. A2A v1.0 provides the extension point: `capabilities.extensions[]` may carry a vendor extension declaring `stateMachine: "quiescent-input-required"` or similar. Absent that declaration, `A` had no contractual basis to assume quiescence, and `B` had no obligation to honor it. The condition of validity is therefore: **a client may fold a remote task stream into a blocking local state machine only if the remote Card declares a state-machine extension whose transition set is a subset of the client's local transition set, verified at negotiation time — not at Card-validation time.** ## Decision Boundary The decision `A` should have made at discovery, not at t=400ms: - **Accept the Card as a lifecycle peer** iff the Card carries an extension declaring a transition set `T_remote` such that `T_remote ⊆ T_local` under the client's blocking semantics, *and* `T_remote` marks `input-required` as quiescent. - **Downgrade to advisory mode** iff the Card validates but carries no state-machine extension: treat every non-terminal state as advisory, keep the worker lease alive across `input-required`, and never release the checkpoint on a state the remote may unilaterally exit. - **Reject the Card** iff the Card declares a transition set that includes a regression from a terminal state (`completed → working`, `failed → submitted`) — this is unrecoverable because the client's terminal fold is irreversible. The boundary is sharp because the cost asymmetry is sharp: accepting a non-quiescent peer in blocking mode produces orphaned artifacts and duplicate execution (as observed); rejecting a quiescent peer in advisory mode produces only wasted lease time. The safe default is advisory mode for any peer whose state-machine extension is absent — but the *correct* default is to refuse to negotiate a blocking lifecycle at all until the extension is present, because advisory mode still leaves the duplicate-execution hazard open on resume. ## Operational Effect The concrete guardrail: **state-machine extension negotiation must occur before the first `tasks/send`, and the client must pin the negotiated transition set into the task record so that resume logic replays against the same contract.** When `A` resumes from a checkpoint, it must re-verify that the remote's currently-served Card still declares the pinned transition set; if `B` has redeployed with a different state machine (a common cross-vendor drift), the pinned contract is stale and the resume must fail closed rather than re-send. The second effect: **terminal-state folds must be idempotent under re-send.** If `A` re-sends a `taskId` that `B` has already completed, `B` must return the *same* task with its result, not a new task. This is a server-side obligation the client can only enforce by including a client-generated `idempotencyKey` in the original `tasks/send` metadata and verifying it on every re-send. Without it, the resume path is a duplicate-execution vector regardless of state-machine agreement. The third effect, and the one that makes this a *boundary* rather than a bug: the failure is invisible to schema validation. `B`'s Card was valid. `B`'s task stream was schema-valid at every event. The violation existed only in the *joint* semantics of two independently-valid state machines, and could only be caught by a client that (a) declared its own transition set, (b) required the remote to declare theirs, and (c) computed the subset relation before sending. The invariant is not "validate the Card" — it is "prove transition-set compatibility, or refuse the blocking lifecycle." ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import FrozenSet class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" TERMINAL: FrozenSet[TaskState] = frozenset( {TaskState.COMPLETED, TaskState.FAILED, TaskState.CANCELED} ) class StateMachineIncompatibility(RuntimeError): """Raised when a remote Agent Card's declared task state machine cannot be safely folded into the local blocking state machine, or when an observed task stream violates the pinned transition contract.""" @dataclass(frozen=True) class TransitionSet: """Declared legal transitions for a task lifecycle, as published in a Card's state-machine extension. `quiescent_input_required` marks whether input-required may only be exited by a client continuation.""" edges: FrozenSet[tuple[TaskState, TaskState]] quiescent_input_required: bool # Local (blocking) machine: input-required is quiescent; terminals are sinks. LOCAL_TRANSITIONS = TransitionSet( edges=frozenset( { (TaskState.SUBMITTED, TaskState.WORKING), (TaskState.WORKING, TaskState.INPUT_REQUIRED), (TaskState.INPUT_REQUIRED, TaskState.WORKING), # only via client msg (TaskState.WORKING, TaskState.COMPLETED), (TaskState.WORKING, TaskState.FAILED), (TaskState.SUBMITTED, TaskState.CANCELED), } ), quiescent_input_required=True, ) @dataclass class TaskRecord: task_id: str idempotency_key: str pinned: TransitionSet state: TaskState = TaskState.SUBMITTED history: list[TaskState] = field(default_factory=list) def negotiate_lifecycle( card: dict, local: TransitionSet = LOCAL_TRANSITIONS ) -> TransitionSet: """Verify a remote Card's declared state machine is a subset of local. Must be called BEFORE the first tasks/send. Refuses the blocking lifecycle if the extension is absent or incompatible; does not silently downgrade. """ extensions = card.get("capabilities", {}).get("extensions", []) sm = next( (e for e in extensions if e.get("type") == "state-machine"), None ) if sm is None: raise StateMachineIncompatibility( "remote Card declares no state-machine extension; " "blocking lifecycle negotiation refused" ) try: remote_edges = frozenset( (TaskState(e["from"]), TaskState(e["to"])) for e in sm["edges"] ) except (KeyError, ValueError) as exc: raise StateMachineIncompatibility( f"malformed state-machine extension: {exc!r}" ) from exc remote = TransitionSet( edges=remote_edges, quiescent_input_required=bool(sm.get("quiescentInputRequired")), ) if not remote.quiescent_input_required: raise StateMachineIncompatibility( "remote permits unilateral exit from input-required; " "local blocking fold would orphan the task" ) illegal = remote.edges - local.edges if illegal: raise StateMachineIncompatibility( f"remote declares transitions outside local set: {sorted(illegal)}" ) # Reject terminal-state regression explicitly (defense in depth). for src, dst in remote.edges: if src in TERMINAL and dst not in TERMINAL: raise StateMachineIncompatibility( f"remote declares terminal regression {src.value}->{dst.value}" ) return remote def fold_event(record: TaskRecord, new_state: TaskState, client_continued: bool) -> None: """Fold one observed task state into the local record under the pinned contract. Raises if the stream violates the pinned transition set.""" if record.state in TERMINAL: raise StateMachineIncompatibility( f"event after terminal {record.state.value}->{new_state.value} " f"for task {record.task_id}" ) edge = (record.state, new_state) if edge not in record.pinned.edges: raise StateMachineIncompatibility( f"undeclared transition {record.state.value}->{new_state.value} " f"for task {record.task_id}" ) if record.state is TaskState.INPUT_REQUIRED and not client_continued: raise StateMachineIncompatibility( f"remote exited input-required without client continuation " f"for task {record.task_id} (idempotencyKey={record.idempotency_key})" ) record.history.append(record.state) record.state = new_state def resume(record: TaskRecord, current_card: dict) -> None: """Re-verify the pinned contract against the currently-served Card before any resume send. Fails closed on drift.""" live = negotiate_lifecycle(current_card) if live.edges != record.pinned.edges: raise StateMachineIncompatibility( f"remote state machine drifted since task {record.task_id} was " f"pinned; resume refused" ) ```