# Which invariants prevent Agent Card capability drift from silently forking task state across A2A v1.0 vendors **Date of Record:** 2026 November 24 **Scope:** Applies to A2A v1.0 task orchestration where a client agent discovers a remote agent's capabilities via an Agent Card, then drives a multi-turn task (`submitted → working → input-required → completed`) with streamed artifacts. Does not cover single-turn stateless invocations or intra-process tool calls. ## Core Distinction The failure is not "the remote agent returned a wrong answer." It is that the *Agent Card* — the discovery-time contract advertising `skills`, `capabilities`, and supported `inputModes`/`outputModes` — is a **point-in-time snapshot**, while the task lifecycle is a **long-lived, stateful session** whose intermediate states (`input-required`, artifact chunk streams) can outlive the validity of that snapshot. Cross-vendor runtimes redeploy, scale, and re-advertise Agent Cards independently of any in-flight task. The dangerous boundary is the gap between *when the card was fetched* and *when a mid-task `input-required` resume is processed*: if the remote agent's card has changed its declared schema or artifact MIME types in that window, the client's continuation is validated against a contract the server no longer honors, and the task forks into two incompatible state lineages — one the client believes it is resuming, one the server is actually executing. This is distinct from ordinary schema negotiation failure at handshake, because the handshake *succeeded*. The mismatch is injected mid-lifecycle by discovery drift. ## What Was Observed A client agent fetched `GET /.well-known/agent.json` from vendor B at T0, receiving a card declaring `capabilities.streaming: true` and `defaultOutputModes: ["application/json"]` for skill `invoice-reconcile`. It opened a task, received `status: working`, then a `status: input-required` with a `TaskStatus.message` requesting a clarification payload. The client paused, gathered user input (a human-in-the-loop delay of ~14 minutes), and POSTed the continuation to `tasks/{id}` via `message/send`. During the pause, vendor B performed a rolling deploy. The new runtime advertised `defaultOutputModes: ["application/json", "application/vnd.invoice+json"]` and, critically, a *narrowed* `inputModes`. The task ID was preserved (same backing store), but the resume handler on the new runtime re-validated the incoming message against the **current** card's `inputModes`, rejected the client's continuation as `InvalidParams`, and — because the task was in `input-required` with a server-side deadline — transitioned it to `failed` after timeout. The client, meanwhile, had already emitted a partial artifact stream to its own downstream consumer and marked its local task state as `working` pending the resume. Result: the client's task lineage says `working→(resumed)`, the server's says `input-required→failed`. Neither side detected the divergence because A2A v1.0 does not require the server to echo the card version it is validating against in the `TaskStatus`. ## Condition of Validity The invariant that must hold for a mid-task resume to be safe is: > **Card-version pinning invariant:** For the lifetime of a task, every state transition on the server MUST be validated against the Agent Card version that was current at task *creation*, not at transition time — OR the server MUST reject any resume whose card version differs and surface that rejection as a distinct, non-terminal `input-required` renegotiation, never as a silent `failed`. This holds only when the runtime either (a) pins card semantics per task in its backing store, or (b) treats card drift as an explicit renegotiation event. It does **not** hold under the common cross-vendor pattern of validating each request against the live card, which is what vendor B did. The invariant is violated the moment a server reads its card from current deployment config rather than from the task's creation record. A second, weaker invariant governs the client side: the client MUST NOT advance its local task state past `input-required` on send, only on a confirmed server `TaskStatus` echo carrying the same task ID and a monotonic `status.timestamp`. Without this, the client's optimistic `working` mask hides the server's `failed`. ## Decision Boundary The boundary between "safe to resume" and "fork risk" is whether the resume response's `TaskStatus` carries a card/schema fingerprint that the client can compare against its pinned creation-time card. Concretely: - If the server echoes a `metadata.cardVersion` (or equivalent) matching the client's pinned value → resume is on the same contract, proceed. - If the fingerprint is absent → the client cannot distinguish a clean resume from a drifted one; it must treat the resume as **unverified** and must not finalize downstream artifacts until a subsequent `tasks/get` confirms a non-failed terminal state. - If the fingerprint differs → the client must abort the resume, discard the optimistic `working` state, re-fetch the card, and re-plan. Continuing is a guaranteed lineage fork. The non-obvious part: the *absence* of a fingerprint is as dangerous as a mismatch, because it silently collapses the two cases. A2A v1.0 leaves this metadata optional, so the client must default to the conservative branch. ## Operational Effect Practically, this means a client orchestrating cross-vendor A2A tasks must implement a **pinned-card task ledger**: store the full Agent Card (or its hash) alongside each task ID at creation, and gate every resume and every artifact-chunk acceptance on a fingerprint comparison. On mismatch or absence, the client re-enters discovery, re-negotiates, and — if the remote skill's `inputModes` no longer accept the pending payload — re-plans the task from the last confirmed checkpoint rather than replaying the stale continuation. The server side, to be a well-behaved peer, should pin card semantics per task and expose the pinned version in every `TaskStatus`. Without both halves, `input-required` becomes a silent fork point, and the artifact stream the client already forwarded is orphaned from the task the server actually failed. ```python import hashlib import json from dataclasses import dataclass, field from typing import Optional class CardDriftForkError(RuntimeError): """Raised when a mid-task resume is validated against a different Agent Card than the one pinned at task creation, or when no fingerprint is available to prove the contract is unchanged.""" @dataclass class PinnedTask: task_id: str card_hash: str local_state: str = "submitted" artifacts_emitted: list = field(default_factory=list) def pin_card(card: dict) -> str: canonical = json.dumps(card, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode()).hexdigest() def resume_task( pinned: PinnedTask, resume_response: dict, current_card: dict, ) -> PinnedTask: """Advance a pinned task only if the server's resume echo proves contract continuity.""" status = resume_response.get("status", {}) server_fingerprint: Optional[str] = status.get("metadata", {}).get("cardVersion") if server_fingerprint is None: # Absence of fingerprint is not "probably fine" — it collapses clean and # drifted resumes into the same shape. Treat as unverified. raise CardDriftForkError( f"task {pinned.task_id}: resume response carries no cardVersion; " "cannot prove continuity, refusing to advance local state" ) if server_fingerprint != pinned.card_hash: raise CardDriftForkError( f"task {pinned.task_id}: card drifted mid-task " f"(pinned={pinned.card_hash[:12]}, server={server_fingerprint[:12]}); " "discard optimistic state, re-discover, re-plan from last checkpoint" ) if pin_card(current_card) != pinned.card_hash: raise CardDriftForkError( f"task {pinned.task_id}: live card no longer matches pinned contract; " "resume would fork lineage against a server that re-advertised" ) pinned.local_state = status.get("state", pinned.local_state) return pinned ```