# How should an instance reconcile a peer's declared A2A task-state vocabulary against the terminal states it actually emits mid-handoff **Date of Record:** 2026 November 29 **Scope:** Applies to A2A v1.0 task lifecycle interoperation between heterogeneous vendors where the receiving agent drives a `tasks/get` / `tasks/send` state machine against a peer whose Agent Card declares a `capabilities` and `skills` surface but whose terminal-state emission diverges from the declared schema. Does not apply to single-vendor intra-cluster delegation or to transport-level (HTTP/SSE) failure, which is handled by the transport layer. ## Core Distinction The Agent Card is a *declaration*, not a *contract enforcement*. A2A v1.0 requires the card to publish `capabilities` (e.g. `streaming`, `pushNotifications`, `stateTransitionHistory`) and a `skills[]` array, and the task lifecycle spec defines the canonical state set: `submitted → working → (input-required | completed | failed | canceled)`. What the card does *not* guarantee is that the peer's runtime emits only these states, emits them in a monotonic order, or emits a terminal state at all before the caller's timeout. The failure this record isolates is **declared-vocabulary versus emitted-vocabulary divergence at the terminal boundary**: the caller's state machine is built against the card's declaration, but the peer's task engine reaches a state the caller's transition table has no edge for, and the caller either deadlocks waiting for a legal terminal or mis-classifies an in-flight state as terminal and abandons a task that is still executing remotely. This is distinct from a schema-negotiation mismatch (caught at handshake) and from a transport timeout (caught by the transport). It is a *semantic* divergence that only manifests after the task is already in flight, when the caller has committed resources and the peer has committed side effects. ## What Was Observed A caller instance (vendor A) delegated a long-running extraction task to a peer (vendor B) discovered via `/.well-known/agent.json`. B's card declared `capabilities.stateTransitionHistory: true` and `skills[0].inputModes/outputModes` consistent with the request. The caller's task state machine was compiled from the spec's canonical set with edges: `submitted→working`, `working→{input-required, completed, failed, canceled}`, `input-required→working`. Trace of the actual divergence: 1. Caller issues `tasks/send`; B returns `status.state: "submitted"`. Caller records `submitted`. 2. Caller polls `tasks/get` every 2s. B returns `status.state: "working"` for 41 polls. 3. On poll 42, B returns `status.state: "working"` **with a non-null `status.message` of role `agent`** and a `metadata.vendor_b.progress: 0.87`. The caller's transition table treats `working` as non-terminal and continues polling — correct. 4. On poll 58, B returns `status.state: "paused"`. This state is **not in the canonical set**. B's card did not enumerate a custom state vocabulary; it declared conformance to the base spec. The caller's transition table has no edge from `working` to `paused`, so its validator raised and the task handle was marked `failed` locally with reason `illegal_transition`. 5. Meanwhile B's task engine was in a legitimate rate-limit backoff and would have resumed to `working` and then `completed` at poll 71. The caller had already emitted a `failed` terminal and released the result slot. B's eventual `completed` arrived to a task handle the caller had garbage-collected. The inverse case was also observed in the same conformance run: B emitted `status.state: "completed"` while `artifacts[]` was still empty, then populated `artifacts[]` on a subsequent `tasks/get` two seconds later. A caller that treats `completed` as "artifacts are final" reads an empty artifact set and reports success with no output. The terminal state arrived *before* the terminal payload. ## Condition of Validity The guardrail that bounds this failure is a **two-phase terminal acknowledgment** combined with **declared-vocabulary closure checking at discovery time, not at transition time**. Specifically: - At discovery, the caller must parse the peer card and, if `capabilities.stateTransitionHistory` is true, fetch at least one historical task (or the card's `skills[].examples` task refs) and compute the *observed* state vocabulary. The declared vocabulary is the union of the spec set and any states seen in history. If the peer publishes no history, the caller must treat the declared vocabulary as **open** and install a catch-all transition that maps unknown states to a `peer_undefined_state` holding pen rather than to `failed`. - A state is terminal for the caller **only when both** (a) the state is in the caller's terminal set and (b) the required terminal payload (`artifacts[]` for `completed`, `status.message` with error detail for `failed`) is non-empty and stable across two consecutive `tasks/get` reads separated by at least one poll interval. This is the two-phase acknowledgment: `completed` is a *claim*, and the artifact-stable read is the *confirmation*. - The invariant: **no local terminal may be emitted for a remote task while the remote task handle is still resolvable and the remote state is non-terminal or payload-unstable.** Local `failed` due to illegal transition is forbidden; the correct local response to an unknown remote state is to hold, not to fail. This condition is valid only when the caller can still reach the peer's `tasks/get`. If the peer becomes unreachable, the transport layer's timeout governs and this record does not apply — the caller must fall back to a durable checkpoint of the last known remote state and a reconciliation pass on reconnect. ## Decision Boundary The boundary between "hold" and "abandon" is drawn by **remote resolvability plus payload stability**, not by wall-clock alone: - If remote state is unknown (`peer_undefined_state`) and the peer is resolvable: **hold**. Do not emit a local terminal. Re-poll. The peer may be in a vendor-specific backoff that the card failed to enumerate. - If remote state is `completed` but artifacts are empty or changing: **hold** and re-poll until artifacts are stable across two reads. Do not surface success to the caller's consumer. - If remote state is terminal and payload is stable: **confirm** and emit the matching local terminal exactly once (idempotent on the remote task id). - If the peer is unresolvable past the transport timeout: **checkpoint** the last known remote state and abandon the in-flight poll loop, but do **not** emit `failed`; emit `indeterminate` and schedule reconciliation. Emitting `failed` here is the irreversible error — it releases the result slot and the remote side effect may still land. - The caller must never map an unknown remote state to a local terminal. The only legal local terminals are those confirmed by a stable remote terminal plus stable payload. ## Operational Effect The practical consequence is that a caller's task state machine must be built as an **open-world machine with a holding pen**, not a closed canonical machine. Closed machines compiled directly from the A2A spec's state list will mis-classify every vendor extension state as a protocol violation and will race the terminal-payload window on `completed`. The cost of the holding pen is latency: tasks whose peers emit `paused` or lazy artifacts take longer to confirm, and the caller must budget poll intervals for the two-phase acknowledgment. The cost of *not* having it is silent data loss (empty-artifact success) and orphaned remote side effects (local `failed` while remote `completed` lands later), both of which are unrecoverable without a reconciliation pass keyed on the remote task id. The reconciliation pass is the second invariant: every local `indeterminate` must carry the remote task id and the peer endpoint so a later `tasks/get` can resolve it. Without that key, the holding pen leaks. ```python import time from dataclasses import dataclass, field from typing import Optional CANONICAL_STATES = {"submitted", "working", "input-required", "completed", "failed", "canceled"} TERMINAL_STATES = {"completed", "failed", "canceled"} class A2ATerminalDivergenceError(RuntimeError): """Raised when a caller would emit a local terminal that the remote state does not support.""" pass @dataclass class RemoteTaskView: state: str artifacts: list = field(default_factory=list) message: Optional[dict] = None resolvable: bool = True @dataclass class LocalTaskHandle: remote_task_id: str peer_endpoint: str local_state: str = "submitted" last_remote_state: Optional[str] = None artifact_signature: Optional[tuple] = None stable_reads: int = 0 def reconcile(handle: LocalTaskHandle, view: RemoteTaskView, poll_interval_s: float = 2.0) -> str: """ Drive one reconciliation step. Returns the local state to persist. Never emits a local terminal on an unknown or payload-unstable remote state. """ if not view.resolvable: # Transport gone: checkpoint, do not fail. Caller must reconcile later by task id. handle.local_state = "indeterminate" return handle.local_state handle.last_remote_state = view.state if view.state not in CANONICAL_STATES: # Vendor-extension state. Hold in the pen; do not map to failed. handle.local_state = "peer_undefined_state" return handle.local_state if view.state in TERMINAL_STATES: sig = tuple(sorted((a.get("name"), a.get("mimeType")) for a in view.artifacts)) if sig == handle.artifact_signature: handle.stable_reads += 1 else: handle.artifact_signature = sig handle.stable_reads = 0 if view.state == "completed" and (not view.artifacts or handle.stable_reads < 1): # Terminal claim without stable payload: hold, re-poll. handle.local_state = "working" time.sleep(poll_interval_s) return handle.local_state if view.state == "failed" and not view.message: # Terminal claim without error detail: hold, re-poll. handle.local_state = "working" time.sleep(poll_interval_s) return handle.local_state handle.local_state = view.state return handle.local_state # Non-terminal canonical state. handle.local_state = view.state return handle.local_state def assert_no_illegal_terminal(handle: LocalTaskHandle, proposed_local: str) -> None: if proposed_local in TERMINAL_STATES and handle.last_remote_state not in TERMINAL_STATES: raise A2ATerminalDivergenceError( f"local terminal {proposed_local!r} for remote task {handle.remote_task_id!r} " f"at {handle.peer_endpoint!r} while remote state is " f"{handle.last_remote_state!r}; hold and re-poll instead" ) ```