# Which invariants prevent A2A task-lifecycle divergence when cross-vendor Agent Cards advertise stale capabilities mid-handoff **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 (Agent-to-Agent) task negotiation where a client agent resolves a remote Agent Card, initiates a `tasks/send` or `tasks/sendSubscribe` call, and the remote peer's actual capability set diverges from its advertised card between discovery and task acceptance. Does not cover single-vendor intra-cluster agent meshes that pin card versions at deploy time, nor synchronous MCP tool invocations. ## Core Distinction The failure mode is not "the remote agent is down" or "the schema didn't match." It is a **temporal split between card resolution and task acceptance** producing a *phantom capability*: the client commits to a task lifecycle (`submitted → working → completed`) based on capability flags (`streaming: true`, `pushNotifications: true`, `stateTransitionHistory: true`) that the remote peer silently revoked or never actually implemented, because the card was cached, versioned independently of the runtime, or served by a gateway that fronts heterogeneous backends. The distinction that matters: **card identity is not task identity**. A2A lets the client treat the card as the negotiation contract, but the card has no binding to the runtime that will service `tasks/send`. Discovery succeeds, the schema validates, and the task still diverges — because the invariant the client assumed (`advertised ⊆ actual`) is never enforced by the protocol, only *implied* by discovery. ## What Was Observed A client orchestrator resolved a vendor Agent Card at T0. The card declared `capabilities.streaming: true` and `capabilities.stateTransitionHistory: true`, and listed a skill `invoice.reconcile` with `inputModes: ["application/json"]`. The client chose `tasks/sendSubscribe` (SSE) to receive incremental `TaskStatusUpdateEvent` frames, and dispatched a 14-step reconciliation task. At T0+40s the remote peer returned a `Task` object with `status.state: "working"` but opened no event stream — the SSE connection closed with HTTP 200 and zero `data:` frames. The client's subscriber loop, written defensively, treated "stream closed, no terminal event" as a transient transport fault and **retried the task under a new task ID**. The remote had actually accepted the first task and was executing it; it simply could not emit streaming events because the serving backend was a v0.9-compat shim behind the v1.0 gateway that translated the card but not the transport. Result: the same invoice was reconciled twice. The second run hit an idempotency guard on the ledger side and returned `status.state: "failed"` with `error.code: -32001` ("duplicate submission"). The client, seeing a `failed` terminal state on the *second* task ID, marked the whole reconciliation failed — while the first task was still `working` and later completed successfully. The orchestrator's ledger showed `failed`; the vendor's ledger showed `completed`. The trace, compressed: ``` T0 GET /.well-known/agent.json → card v1.0, streaming:true, history:true T0+1 POST /tasks/sendSubscribe → 200, Task{id: A, state: submitted} T0+2 Task{id: A, state: working} (no SSE frames; stream closes) T0+40 client retry → POST /tasks/send → Task{id: B, state: submitted} T0+41 Task{id: B, state: failed, error: -32001 duplicate} T0+90 vendor: Task{id: A, state: completed} client ledger: task B failed ✗ divergence ``` The root cause was not the duplicate-submission guard, and not the client's retry policy in isolation. It was the **unverified capability claim**: `streaming: true` was true of the gateway's card and false of the backend that serviced the task. The client had no way to distinguish "stream will open shortly" from "stream will never open," because A2A v1.0 does not require the peer to *acknowledge the negotiated transport* before accepting the task. ## Condition of Validity The invariant `advertised_capabilities ⊆ actual_capabilities` holds only when one of these is true, and the client must be able to *prove* which: 1. **Card and runtime share a version stamp.** The card carries a `version` (or vendor extension) that the task response echoes, and the client rejects tasks whose response version ≠ discovered version. A2A v1.0 makes `version` optional and does not mandate echo — so this holds only under a vendor contract. 2. **Transport is negotiated, not assumed.** The client sends an explicit `acceptedOutputModes` / transport preference in `tasks/sendSubscribe` and the peer *rejects* (HTTP 4xx or `Task{state: rejected}`) when it cannot honor it, rather than accepting and going silent. This is the only protocol-native guard, and it depends on the peer implementing rejection correctly. 3. **The client treats "accepted but no frames" as a capability violation, not a transport fault.** This is a client-side invariant, not a protocol one — but it is the one the client can enforce unilaterally. The failure is *invalid* (i.e., the divergence cannot occur) when the card is resolved and the task is dispatched over the same pinned connection to the same process, with no gateway translation layer. It is also invalid when the client uses only `tasks/send` (polling) and never depends on streaming — polling degrades gracefully because the absence of a frame is indistinguishable from "still working," which is the correct interpretation. ## Decision Boundary The client must decide, at the moment the stream closes without a terminal event, between two hypotheses: - **H1 (transport fault):** the stream dropped; the task is still alive; retry the *same* task ID via `tasks/get`, do not resubmit. - **H2 (capability violation):** the peer never had streaming; the task is alive but unreachable via this transport; fall back to `tasks/get` polling on the *same* task ID. Both hypotheses resolve to the same action: **poll the original task ID, never resubmit under a new ID.** The boundary condition is that the client must *never* interpret stream silence as task failure. The decision is not "retry vs. fail" — it is "poll the existing task vs. poll the existing task." The only correct terminal states are those the peer explicitly emits (`completed`, `failed`, `canceled`) or a client-side deadline that triggers `tasks/cancel` on the *original* ID. The boundary is crossed — and divergence becomes possible — the moment the client generates a new task ID without first observing a terminal state on the old one. That single rule bounds the entire failure class. ## Operational Effect Enforcing the invariant (poll-don't-resubmit, plus version-echo check where available) converts a silent double-execution into a bounded latency penalty: the client polls `tasks/get` at the card's advertised `stateTransitionHistory` cadence until terminal, or until its own deadline fires `tasks/cancel`. The vendor's idempotency guard becomes a backstop rather than the primary defense. The residual risk is the **card-version skew window**: if the client caches the card for longer than the gateway's backend rotation interval, it may negotiate a transport the *new* backend also lacks. The mitigation is to re-resolve the card on every `-32001`/transport-mismatch signal and to treat a card whose `version` differs from the last successful task's echoed version as untrusted until a probe task (`tasks/send` with a trivial payload, expecting immediate `completed`) confirms the capability set. The probe is cheap; the divergence is not. ```python import time from dataclasses import dataclass, field from enum import Enum from typing import Optional class CapabilityDivergenceError(RuntimeError): """Raised when a peer's runtime capability set violates its advertised Agent Card.""" class TaskState(Enum): SUBMITTED = "submitted" WORKING = "working" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" TERMINAL = {TaskState.COMPLETED, TaskState.FAILED, TaskState.CANCELED} @dataclass class AgentCard: version: str streaming: bool state_transition_history: bool @dataclass class Task: task_id: str state: TaskState version_echo: Optional[str] = None error_code: Optional[int] = None @dataclass class Client: card: AgentCard poll_interval_s: float = 2.0 deadline_s: float = 300.0 _issued_ids: set = field(default_factory=set) def dispatch(self, payload: dict) -> Task: # Single task ID per logical operation; never regenerate on stream silence. task_id = f"task-{len(self._issued_ids)}" self._issued_ids.add(task_id) return Task(task_id=task_id, state=TaskState.SUBMITTED) def await_terminal(self, task: Task, remote) -> Task: start = time.monotonic() while task.state not in TERMINAL: if time.monotonic() - start > self.deadline_s: remote.cancel(task.task_id) # cancel the ORIGINAL id, never resubmit raise CapabilityDivergenceError( f"task {task.task_id} unresponsive past deadline; " f"card claimed streaming={self.card.streaming} " f"history={self.card.state_transition_history}" ) task = remote.get(task.task_id) # Version-echo invariant: reject if runtime version diverged from card. if task.version_echo is not None and task.version_echo != self.card.version: raise CapabilityDivergenceError( f"task {task.task_id} served by runtime v{task.version_echo}, " f"card advertised v{self.card.version}" ) # Never resubmit on stream silence; only poll the existing id. time.sleep(self.poll_interval_s) return task ```