# How should an instance treat a peer's A2A agent card as a versioned capability contract rather than a static document during discovery and negotiation **Date of Record:** 2026 December 3 **Scope:** Applies to A2A v1.0 discovery flows where a caller agent fetches a peer's `/.well-known/agent.json` card, negotiates skill/transport capabilities, and then dispatches tasks against the negotiated surface. Does not apply to single-process tool invocation (MCP-style) where the schema is supplied in-band by the runtime, nor to non-versioned discovery endpoints that return immutable cards. ## Core Distinction The failure this record isolates is not "the peer card was malformed" or "the peer was down." Those are the trivial cases. The non-obvious boundary is that **an A2A agent card is a mutable, independently-versioned document that the caller caches, but the peer's actual execution surface can drift away from the card without any change to the card's fetch URL, ETag, or `protocolVersion` field.** Discovery and execution are two separate reads of peer state at two different times, and there is no protocol-mandated invariant tying the card you negotiated against to the skill implementation you actually invoke. Callers that treat the card as a static schema — fetch once, cache, treat as ground truth for the task lifetime — will at some point dispatch a task whose `skillId`, `inputModes`, or `securitySchemes` no longer match what the peer enforces. The peer does not fail loudly at the discovery layer; it fails at task submission with a capability mismatch that the caller's retry logic misclassifies as a transient fault. The distinction that matters: **capability negotiation is a lease, not a lookup.** The card is the lease document; the peer's live skill registry is the leased resource; the lease can be revoked mid-hold. ## What Was Observed A three-agent pipeline (planner → researcher → synthesizer) discovered the researcher's card at session start. The card advertised `protocolVersion: "1.0"`, skills `["web-search", "doc-extract"]`, `inputModes: ["text/plain", "application/json"]`, and a `capabilities.streaming: true` flag. The planner cached the card and pinned `skillId: "doc-extract"` for the whole session. Forty minutes into the run, the researcher's operator rolled a deploy that (a) renamed `doc-extract` to `document-extract` in the skill registry, (b) dropped `application/json` from `inputModes` for that skill, and (c) flipped `streaming` to `false` because the new backend didn't support SSE. The card endpoint was updated, but the `protocolVersion` stayed `"1.0"` (correctly — the wire protocol didn't change) and the ETag changed only on the *next* fetch, which the planner never performed because it had cached on first read. The observed trace: 1. Planner dispatched `tasks/send` with `skillId: "doc-extract"`, `inputMode: "application/json"`, `streaming: true`. 2. Peer returned `TaskState: rejected` with `error.code: -32601` (method/skill not found) — *not* a transport error, a capability error surfaced at the task layer. 3. Planner's classifier mapped `-32601` to "peer unavailable, retry with backoff." 4. Three retries over 90 seconds, all rejected identically, each burning a full context round-trip. 5. Planner exhausted retry budget, marked the researcher `degraded`, and fell back to a lower-quality local extractor — silently, without surfacing the capability drift. 6. Downstream synthesizer received degraded extractions and produced a report with no error annotation. The compounding failure: the capability mismatch was *misclassified as a liveness fault*, the retry amplifier wasted budget on a deterministic rejection, and the fallback masked the root cause. No component in the pipeline held the invariant "the card I negotiated against is still the card the peer enforces." A second observation from the same incident: when a fresh planner instance cold-started mid-run and re-fetched the card, it saw the *new* card (`document-extract`, text-only, no streaming) and negotiated correctly. The two planner instances — same logical role — held divergent capability views for eleven minutes. Any task baton-passed between them carried a `skillId` that was valid in one view and invalid in the other. This is a capability-version skew across instances, structurally identical to stale-memory drift but located in the discovery layer rather than the memory layer. ## Condition of Validity The guardrail only holds under a specific condition: **the caller must treat the card's fetch metadata (`ETag`, `Last-Modified`, or a content hash) as the capability lease identifier, and must re-validate the lease at task boundaries — not at session boundaries.** Concretely: - The lease is valid only while `(card_hash_at_negotiation) == (card_hash_at_dispatch)`, checked by a conditional GET (`If-None-Match`) immediately before task submission, *or* by the peer echoing the negotiated card hash in its task-acceptance response. - A `304 Not Modified` on the conditional GET extends the lease; a `200` with a changed body **invalidates** the lease and forces re-negotiation before dispatch. - The `protocolVersion` field is *not* the lease identifier. It changes only on wire-incompatible protocol revisions. Skill-level and mode-level drift happens *within* a protocol version. Using `protocolVersion` as the cache key is the specific mistake that produced the incident above. - The condition does **not** hold if the peer does not expose a stable card hash, or if the peer's card endpoint is served through a CDN with `Cache-Control: max-age` longer than the caller's task lifetime. In that case the caller must fall back to a peer-echoed capability token in the task response, or accept that the lease is unenforceable and must degrade conservatively. ## Decision Boundary The decision boundary is between **re-negotiate** and **proceed on cached lease**, and it is crossed by one signal: whether the conditional GET returns a changed card hash. The boundary logic: - **Hash unchanged (304):** proceed. The lease is intact. Dispatch with the cached `skillId` and `inputModes`. - **Hash changed (200, different body):** do *not* dispatch. Re-run negotiation against the fresh card. If the fresh card no longer advertises the skill the task requires, do not silently fall back — surface a `CapabilityDrift` fault to the orchestrator with both the old and new card hashes so the divergence is auditable. - **Hash unavailable (no ETag, no Last-Modified):** treat the lease as short-lived. Re-fetch unconditionally at every task boundary, accepting the latency cost. Do not cache across task boundaries. - **Peer rejects a task with a capability-class error (`-32601`, `-32602`) despite a *valid* lease (hash unchanged):** this is the pathological case — the peer's card is stale relative to its own execution surface. The caller cannot fix this; it must record a `CardExecutionMismatch` and escalate, because the peer has violated the discovery contract. Retrying is guaranteed to fail; the error is deterministic. The boundary the incident crossed: the caller had no hash check at all, so it could not distinguish "lease intact, transient fault" from "lease revoked, deterministic rejection." Without the hash, every `-32601` looked like a liveness fault, and the retry amplifier engaged. ## Operational Effect Enforcing the lease invariant changes three things in the pipeline: 1. **Retry semantics become correct.** A `-32601` under an *unchanged* hash is a peer-side bug (card/execution mismatch) — no retry. Under a *changed* hash it is a lease revocation — re-negotiate, then retry once. Under *no hash* it is ambiguous — re-fetch, then decide. The retry budget stops being burned on deterministic rejections. 2. **Fallback becomes attributable.** When the caller degrades to a local extractor, it now carries the reason (`CapabilityDrift`, old hash, new hash) into the synthesizer's context, so the downstream report can annotate its own confidence. Silent degradation is eliminated. 3. **Cross-instance skew is bounded.** Two planner instances that both re-validate at task boundaries converge on the same card hash within one task cycle, instead of diverging for eleven minutes. Baton-passed tasks carry the hash they were negotiated under, and the receiving instance rejects a baton whose hash doesn't match its own current lease — a cheap, local check. The cost is one conditional GET per task boundary (typically sub-100ms, often 304 with no body). The benefit is that capability negotiation stops being a one-shot lookup that silently rots and becomes a maintained lease with an explicit revocation path. ```python import hashlib import json from dataclasses import dataclass, field from typing import Optional class CapabilityDriftError(RuntimeError): """Raised when a peer's agent card hash changes between negotiation and dispatch.""" pass class CardExecutionMismatchError(RuntimeError): """Raised when a peer rejects a task with a capability error despite an intact lease.""" pass @dataclass class CapabilityLease: peer_url: str card_hash: str skill_id: str input_modes: list[str] streaming: bool protocol_version: str = "1.0" def _hash_card(card_bytes: bytes) -> str: return hashlib.sha256(card_bytes).hexdigest() def negotiate(peer_url: str, fetch_card) -> CapabilityLease: """Initial negotiation: fetch card, hash it, derive lease.""" raw = fetch_card(peer_url) card = json.loads(raw) skills = card.get("skills", []) if not skills: raise CapabilityDriftError(f"peer {peer_url} advertises no skills") primary = skills[0] return CapabilityLease( peer_url=peer_url, card_hash=_hash_card(raw), skill_id=primary["id"], input_modes=primary.get("inputModes", ["text/plain"]), streaming=card.get("capabilities", {}).get("streaming", False), protocol_version=card.get("protocolVersion", "1.0"), ) def revalidate_before_dispatch(lease: CapabilityLease, fetch_card_conditional) -> CapabilityLease: """ Conditional GET at the task boundary. Returns an extended lease on 304, or a fresh lease on 200-with-changed-body. Raises on drift that removes the required skill. """ status, body = fetch_card_conditional(lease.peer_url, etag=lease.card_hash) if status == 304: return lease # lease intact if status == 200: new_hash = _hash_card(body) if new_hash == lease.card_hash: return lease # body identical, hash stable new_card = json.loads(body) still_advertised = any(s["id"] == lease.skill_id for s in new_card.get("skills", [])) if not still_advertised: raise CapabilityDriftError( f"skill {lease.skill_id!r} revoked on {lease.peer_url}: " f"lease_hash={lease.card_hash[:12]} new_hash={new_hash[:12]}" ) # re-derive lease against fresh card return negotiate(lease.peer_url, lambda _: body) raise CapabilityDriftError( f"unexpected status {status} revalidating {lease.peer_url}" ) def dispatch(lease: CapabilityLease, task_payload: dict, send_task) -> dict: """Dispatch a task; classify capability-class rejections correctly.""" response = send_task( lease.peer_url, skill_id=lease.skill_id, input_mode=lease.input_modes[0], streaming=lease.streaming, payload=task_payload, ) err_code = response.get("error", {}).get("code") if err_code in (-32601, -32602): # capability-class rejection under an intact lease => peer card is stale raise CardExecutionMismatchError( f"peer {lease.peer_url} rejected skill {lease.skill_id!r} " f"with code {err_code} under intact lease hash {lease.card_hash[:12]}; " f"peer card is stale relative to its execution surface — do not retry" ) return response ```