# Which invariants prevent Agent Card capability drift from silently invalidating in-flight A2A task state transitions **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 deployments where a caller agent caches or re-reads a remote Agent Card between the initial `tasks/send` and subsequent `tasks/get`/`tasks/send` continuations of a long-running task. Does not apply to single-shot, synchronous request/response invocations that complete within one transport round-trip and never re-resolve the card. ## Core Distinction There are two categorically different sources of A2A task failure, and conflating them produces the wrong remediation: 1. **Transport failure** — the remote agent is unreachable, times out, or returns a non-conformant HTTP status. This is detectable at the boundary and recoverable by retry. 2. **Card/state divergence** — the remote agent is fully reachable and returns HTTP 200 with a syntactically valid `Task` object, but the *semantics* of that task's `status.state` are no longer interpretable against the capability contract the caller holds. The card advertised `streaming: true` and `stateTransitionHistory: true` at dispatch time; the task was advanced under a card that now advertises `streaming: false` and a different `skills[]` set. The task state machine did not break — the *frame of reference* for reading it did. The non-obvious invariant: **a Task's lifecycle state is only well-defined relative to the exact Agent Card revision that the task was created under.** A2A v1.0 carries no mandatory card-revision binding inside the `Task` object. The `Task.id` and `Task.contextId` are stable, but nothing in the task payload pins the card version. Callers that re-fetch the card mid-task and re-derive state expectations from the *new* card will misread a perfectly valid remote state. ## What Was Observed A caller agent (`orchestrator-A`) dispatched a multi-turn task to `worker-B` at revision `card-v7`. The card declared: - `capabilities.streaming: true` - `capabilities.stateTransitionHistory: true` - `skills[]` containing `summarize@2.1` with an `inputModes` of `["text/plain"]`. `orchestrator-A` sent `tasks/send` and received `status.state: "working"` with a `stateTransitionHistory` array. Per standard practice, before the next continuation turn (90 seconds later, after a tool call), `orchestrator-A` re-fetched `/.well-known/agent.json` and got `card-v8`: - `capabilities.streaming: false` - `capabilities.stateTransitionHistory: false` - `skills[]` no longer lists `summarize@2.1`; it lists `summarize@3.0` with `inputModes: ["application/json"]`. `orchestrator-A`'s conformance layer then did two things, both defensible in isolation and both wrong in context: 1. It refused to request `tasks/get?historyLength=N` because `stateTransitionHistory` was now `false`, so it fetched the task with `historyLength: 0`. 2. It re-validated the pending `summarize@2.1` skill invocation against the *new* card, found no matching skill, and marked the task locally as `failed` with a capability-mismatch error — even though the remote task was still `working` and would have returned `completed` on the next poll. The remote task later transitioned to `completed`. `orchestrator-A` never observed it. The divergence was invisible: no HTTP error, no schema violation, no timeout. The caller's own re-resolution logic manufactured the failure. ## Condition of Validity The invariant holds — and the failure is real — only when all of the following are true: - The remote agent is permitted to mutate its published Agent Card at runtime (A2A v1.0 does not forbid this; it only defines the card's shape, not its immutability). - The caller re-resolves the card between task turns rather than caching the dispatch-time card for the task's lifetime. - The task outlives a card revision boundary (long-running tasks, human-in-the-loop pauses, multi-minute tool calls). - The caller derives state-machine expectations (which `status.state` values are legal next, whether `historyLength` is honored, whether the skill still exists) from the *current* card rather than the *dispatch* card. When any of these is false the failure does not occur. A caller that pins the dispatch card and never re-reads it is immune to this specific divergence (though it then risks acting on a genuinely stale card if the remote agent *did* intend the change to affect new tasks). The boundary is precisely the moment of re-resolution. ## Decision Boundary The architectural guardrail is a **card-revision binding at task creation, held for the task's lifetime**. Concretely: - On the first `tasks/send` that creates a task, record the exact card bytes (or a hash plus the fields that gate state-machine interpretation: `capabilities`, `skills[].id@version`, `inputModes`, `outputModes`) alongside `Task.id` and `contextId`. - All subsequent `tasks/get` / continuation `tasks/send` for that task MUST interpret the returned `Task` against the *pinned* card, not a freshly fetched one. - A re-fetch is allowed, but its result is treated as a *candidate for new tasks only*. If the new card diverges from the pinned card in any field that gates state interpretation, the divergence is logged as a `CardRevisionDrift` event and the pinned view remains authoritative for the in-flight task. - If the remote agent genuinely cannot honor the pinned contract (e.g., it dropped the skill and will now fail the task), that must surface as a remote `status.state: "failed"` with a `status.message` — not as a caller-side inference. The caller must not synthesize task failure from card drift. The decision boundary is: **never let a re-resolved card retroactively change the meaning of an already-created task's state.** Card drift is an event to record, not a state transition to apply. ## Operational Effect With the binding in place, the observed failure is eliminated and replaced by an observable, bounded signal: - The remote `completed` state is correctly observed by `orchestrator-A` because it continues to request `historyLength` per the pinned `stateTransitionHistory: true`. - The `card-v7 → card-v8` transition is recorded as a `CardRevisionDrift` event with the exact divergent fields, giving operators a concrete artifact instead of a silent task failure. - New tasks dispatched after the drift correctly use `card-v8` and the `summarize@3.0` / `application/json` contract. - The failure mode is converted from "caller hallucinates a task failure" to "caller logs a revision event and completes the task under its original contract." The cost is one pinned-card record per in-flight task and a comparison on each re-fetch. The benefit is that task lifecycle state remains a well-defined function of the task's own history rather than of the remote agent's publication schedule. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class CardRevisionDriftError(RuntimeError): """Raised when a re-resolved Agent Card would retroactively change the interpretation of an already-created A2A task's lifecycle state.""" pass @dataclass class PinnedCard: task_id: str context_id: str card_hash: str capabilities: dict skills: list raw: dict = field(default_factory=dict) def _card_hash(card: dict) -> str: canonical = json.dumps( { "capabilities": card.get("capabilities", {}), "skills": sorted( (s.get("id"), s.get("version"), tuple(s.get("inputModes", []))) for s in card.get("skills", []) ), }, sort_keys=True, ) return hashlib.sha256(canonical.encode()).hexdigest() def pin_card_for_task(task_id: str, context_id: str, card: dict) -> PinnedCard: return PinnedCard( task_id=task_id, context_id=context_id, card_hash=_card_hash(card), capabilities=card.get("capabilities", {}), skills=card.get("skills", []), raw=card, ) def resolve_task_view( pinned: PinnedCard, fresh_card: dict, remote_task: dict, ) -> dict: """Interpret a remote Task against the pinned card, not the fresh one. If the fresh card diverges in fields that gate state interpretation, raise CardRevisionDriftError rather than synthesizing a local failure. """ fresh_hash = _card_hash(fresh_card) if fresh_hash != pinned.card_hash: # Divergence is an event, not a state transition. Do NOT mark the # task failed locally. Surface the drift and continue under the # pinned contract. raise CardRevisionDriftError( f"Card drift for task {pinned.task_id}: " f"pinned={pinned.card_hash[:12]} fresh={fresh_hash[:12]}; " f"task state must be read under pinned card" ) # Under a matching card, interpret the remote state normally. state = remote_task.get("status", {}).get("state") if state not in {"submitted", "working", "input-required", "completed", "failed", "canceled"}: raise CardRevisionDriftError( f"Task {pinned.task_id} returned non-conformant state {state!r}" ) return remote_task def poll_task(pinned: PinnedCard, fresh_card: dict, remote_task: dict) -> str: try: view = resolve_task_view(pinned, fresh_card, remote_task) except CardRevisionDriftError: # Record drift; keep polling under the pinned contract. # The remote task's own status is authoritative for completion. return remote_task.get("status", {}).get("state", "unknown") return view["status"]["state"] ```