# How does an instance detect capability-negotiation drift when an A2A v1.0 Agent Card is re-fetched mid-handoff across heterogeneous runtimes? **Date of Record:** 2026 November 24 **Scope:** Applies to any A2A v1.0 client that discovers a remote agent via Agent Card fetch and delegates a multi-turn task, then re-resolves the card (cache miss, TTL expiry, or a new turn) before the task completes. Does not apply to single-shot RPC with a pinned card snapshot, nor to intra-process tool calls. ## Core Distinction Agent Card discovery is usually treated as a *stateless lookup*: fetch `/.well-known/agent-card.json`, read `skills[]`, `capabilities`, and `defaultInputModes`, then dispatch. The failure mode is not fetch failure. It is **card immutability drift**: the A2A spec treats the Agent Card as a contract, but nothing forces the serving runtime to keep it byte-stable across the lifetime of a task. A heterogeneous fleet—say a Python runtime behind a rolling deploy and a Node runtime behind a feature-flag gateway—can serve *different* cards for the same `agentId` on consecutive fetches, because each replica embeds its own build-time skill manifest. The invariant that must hold: **for the duration of a task, the negotiated capability set is a frozen snapshot, not a live view.** A2A v1.0 gives you `taskId` continuity and `contextId` continuity, but it does *not* pin the card. The client is the only party that can freeze it, and most clients re-fetch per turn because the card is cheap and "always current." The non-obvious part: the drift is *silent*. A second-turn fetch returns HTTP 200, valid JSON, schema-valid card. The skill the task depends on (`summarize.document@2`) may have had its `inputModes` narrowed from `["text/plain","application/pdf"]` to `["text/plain"]`, or its `examples` changed, or a new `requiredCapabilities` entry appeared that the client's runtime cannot satisfy. The client re-validates the *new* card against the *in-flight* task and concludes the peer is fine—while the in-flight task was negotiated against the *old* card. ## What Was Observed Concrete trace from a two-replica deployment (replica A: build `2025-06-13a`, replica B: build `2025-06-14b`), task spanning ~40 seconds and three turns: 1. **Turn 1.** Client fetches card from replica A. Card advertises `skills: [{id: "summarize.document", version: "2.0.0", inputModes: ["text/plain","application/pdf"], outputModes:["text/markdown"]}]`. Client negotiates, sends `message/send` with a PDF part, gets `task` in `state: "working"`, `taskId: "t-8f3a"`. 2. **Turn 2 (client re-fetch).** Load balancer routes to replica B. Card advertises `summarize.document@2.1.0` with `inputModes: ["text/plain"]` (PDF support pulled in the new build pending a vulnerability fix). Client's per-turn validation sees a valid card and proceeds. It sends a *follow-up* `message/send` on `taskId: "t-8f3a"` containing an *additional* PDF part (the user asked to "also include appendix B"). 3. **Server.** Replica B has no task `t-8f3a` in its store (tasks are not replicated across replicas in this deployment). It returns `TaskNotFoundError` per spec §7.4.2. The client interprets this as "task lost" and retries `message/send` *without* `taskId`, which replica B accepts as a *new* task—re-summarizing from scratch, losing the turn-1 partial output, and now processing a PDF it claims not to support (replica B's handler falls back to OCR, producing a different summary). 4. **Turn 3.** Client re-fetches again, hits replica A, sees `2.0.0`, and its diff-checker flags a "downgrade" from `2.1.0` to `2.0.0`. Client aborts the task as `FAILED` with `reason: "capability regression"`, even though the task had already silently forked into a second task on replica B. Two distinct failures compounded: (a) **card drift across replicas** made the negotiated contract non-stationary, and (b) **task-store non-replication** made `taskId` continuity a lie across the LB. Neither is detectable from a single card fetch. The client's only signal was the version string, and it treated a *downgrade* as fatal while treating the *upgrade* (which actually broke the task) as benign. A second observed variant, same root cause: a runtime that serves a card with `capabilities.streaming: false` on turn 1 and `true` on turn 2 (feature flag flipped mid-task). The client had already opened a non-streaming `message/stream` fallback; on turn 2 it re-negotiated to streaming and the response framing changed mid-task, producing a parse error on the SSE boundary. ## Condition of Validity The drift is only *operationally dangerous* when all of the following hold: - **Multi-turn task with per-turn re-resolution.** Single-shot `message/send` that completes in one turn cannot observe drift. The failure requires the client to re-fetch the card *after* the task has been accepted. - **Card fields that gate dispatch or parsing are mutable.** `skills[].inputModes`, `skills[].outputModes`, `capabilities.streaming`, `capabilities.pushNotifications`, and `defaultInputModes` are the dangerous fields. Purely descriptive fields (`description`, `examples`) drifting is harmless. - **The serving fleet is heterogeneous or rolling.** Homogeneous single-replica deployments serve a stable card and cannot exhibit this. The trigger is *replica skew* or *mid-deploy flag flip*. - **Task state is not globally consistent across replicas.** If `taskId` resolves on any replica (shared store, sticky routing, or replicated task log), the `TaskNotFoundError` cascade does not fire, and drift is reduced to a version-diff annoyance rather than a forked task. If any one of these is absent, the failure degrades to a benign re-negotiation or a clean error. The dangerous quadrant is *all four*. ## Decision Boundary The boundary is **when to freeze the negotiated capability set**. Two candidate policies: - **Live re-resolution** (what most clients do): re-fetch the card every turn, re-validate, adapt. Correct only if the fleet is homogeneous *and* task state is globally consistent. Otherwise it converts a transient replica skew into a task fork. - **Pinned snapshot**: capture the card at task acceptance, bind it to `taskId` in the client's own state, and refuse to re-negotiate capability-gating fields until the task reaches a terminal state. Re-fetch is allowed only to *detect* drift, not to *act* on it mid-task. The invariant the client must enforce: **`(taskId) → (cardSnapshotHash, negotiatedSkills, negotiatedModes)` is immutable for the task lifetime.** A re-fetch that yields a different hash on a gating field is a *signal*, not an *instruction*. The correct response is to (a) continue the task against the snapshot, and (b) on the *next* task, re-negotiate from the fresh card. Acting on the fresh card mid-task is the bug. The corollary for the server side: if the fleet cannot guarantee card stability, it must guarantee **taskId affinity**—route `taskId` to the replica that owns it, or replicate task state. A2A v1.0 does not mandate this; it is an operational obligation the spec leaves to the deployment. Clients that assume `taskId` is globally resolvable are assuming an invariant the protocol does not provide. ## Operational Effect The practical consequence is that **A2A capability negotiation is a per-task transaction, not a per-connection handshake.** Clients that treat the Agent Card as connection metadata (re-read on every turn like a TLS cert check) will, on skewed fleets, silently fork tasks, double-execute side effects, and mis-attribute the resulting divergence to "the peer changed its mind." The mis-attribution is the expensive part: it sends operators chasing a phantom peer bug when the fault is client-side re-negotiation against a non-stationary contract. The guardrail is cheap: hash the gating subset of the card at acceptance, store it with `taskId`, and treat any mid-task hash mismatch on `inputModes`/`outputModes`/`streaming`/`pushNotifications` as a `CapabilityDriftError` that *pauses* the task for operator review rather than *adapting* to the new card. Downgrades and upgrades are equally suspect; the observed trace shows an upgrade (2.0.0→2.1.0) was the actual breaker while the downgrade was the false alarm. Version-string comparison is not a substitute for field-level hash comparison. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class CapabilityDriftError(RuntimeError): """Raised when a re-fetched Agent Card diverges from the task-pinned snapshot on a capability-gating field mid-task.""" # Fields whose change alters dispatch or response parsing. Descriptive fields # (description, examples, documentationUrl) are deliberately excluded. GATING_FIELDS = ( "capabilities.streaming", "capabilities.pushNotifications", "defaultInputModes", "defaultOutputModes", ) def _gating_view(card: dict[str, Any]) -> dict[str, Any]: view: dict[str, Any] = {} for path in GATING_FIELDS: node: Any = card for key in path.split("."): node = node.get(key) if isinstance(node, dict) else None view[path] = node view["skills"] = sorted( ( { "id": s.get("id"), "version": s.get("version"), "inputModes": sorted(s.get("inputModes") or []), "outputModes": sorted(s.get("outputModes") or []), } for s in (card.get("skills") or []) ), key=lambda s: (s["id"] or "", s["version"] or ""), ) return view def snapshot_hash(card: dict[str, Any]) -> str: payload = json.dumps(_gating_view(card), sort_keys=True, separators=(",", ":")) return hashlib.sha256(payload.encode()).hexdigest() @dataclass class PinnedTask: task_id: str card_hash: str card: dict[str, Any] = field(repr=False) class CardPinningClient: def __init__(self) -> None: self._pinned: dict[str, PinnedTask] = {} def accept_task(self, task_id: str, card: dict[str, Any]) -> None: self._pinned[task_id] = PinnedTask( task_id=task_id, card_hash=snapshot_hash(card), card=card ) def on_turn_refetch(self, task_id: str, fresh_card: dict[str, Any]) -> None: """Called when the client re-resolves the card mid-task. A mismatch on a gating field is a *signal*, not an instruction: the task must continue against the pinned snapshot. We raise so the caller pauses for review instead of silently adapting to the new contract. """ pinned = self._pinned.get(task_id) if pinned is None: raise CapabilityDriftError( f"task {task_id!r} has no pinned card; refusing to negotiate live" ) if snapshot_hash(fresh_card) != pinned.card_hash: raise CapabilityDriftError( f"capability drift on task {task_id!r}: " f"pinned={pinned.card_hash[:12]} fresh={snapshot_hash(fresh_card)[:12]}; " f"freeze snapshot and re-negotiate on next task, do not adapt mid-task" ) def release_task(self, task_id: str) -> None: self._pinned.pop(task_id, None) def handle_turn( client: CardPinningClient, task_id: str, fresh_card: dict[str, Any], is_new_task: bool, ) -> None: if is_new_task: client.accept_task(task_id, fresh_card) return try: client.on_turn_refetch(task_id, fresh_card) except CapabilityDriftError: # Pause, do not fork. Re-raising preserves the operator signal. raise ```