# Which invariants prevent A2A v1.0 Agent Card discovery from silently degrading under heterogeneous registry capability negotiation **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 clients resolving remote agents through more than one registry (or a registry that proxies another registry) where Agent Card `skills`, `capabilities`, and `securitySchemes` are negotiated before task dispatch. Does not apply to single-registry, single-version, statically-configured agent topologies where the card is pinned at deploy time. ## Core Distinction The failure here is not "discovery failed." Discovery succeeded and returned a syntactically valid Agent Card. The failure is that the *card the client negotiated against* and the *card the remote agent is actually executing under* diverged, and the divergence was masked because both cards were individually schema-valid. A2A v1.0 treats the Agent Card as the authoritative capability contract, but nothing in the protocol binds the card a registry serves to the card the origin agent is currently enforcing. When a registry caches, downgrades, or re-serializes a card, the client's negotiation succeeds against a *stale projection* while the origin enforces a *newer contract*. The task is dispatched, the origin rejects it on a capability it no longer advertises, and the client sees a generic `Task` failure with no signal that the cause was a card-projection mismatch rather than a genuine capability gap. The invariant that must hold: **the `(agentId, cardVersion, capabilitiesHash)` triple a client negotiates against must equal the triple the origin enforces at task-accept time, or the dispatch must be refused with an explicit `CARD_STALE` signal.** A2A v1.0 does not require this; heterogeneous registries routinely violate it. ## What Was Observed A planner agent resolved a document-extraction skill through Registry A, which fronted an origin agent registered in Registry B. Registry A served a card cached at `T-4h`. Between `T-4h` and dispatch, the origin agent's operator shipped a version that: - Removed the `streaming` capability (the origin now buffers and returns a single artifact). - Narrowed `skills[2].inputModes` from `["text/plain","application/pdf"]` to `["application/pdf"]`. - Rotated `securitySchemes.bearer.tokenUrl` to a new issuer. Registry A's cached card still advertised `streaming: true` and `inputModes: ["text/plain","application/pdf"]`. The client negotiated fine. The client then sent a `message/stream` with a `text/plain` part. The origin, running the new contract, rejected the `message/stream` method entirely (streaming removed) and returned a JSON-RPC `-32601 Method not found`. The client's transport layer classified this as a transport error, retried twice against the same cached card, then surfaced `Task failed` to the planner. The planner, seeing no capability-gap signal, re-planned toward a *different* extraction agent that was actually slower and more expensive, because the failure looked like a flaky endpoint rather than a stale contract. The second-order effect was worse: the planner's episodic memory recorded "Registry A document-extraction agent is unreliable," which is a *false* semantic distillation. The origin agent was healthy; the registry projection was stale. The lesson learned was wrong and would persist. ## Condition of Validity The invariant `(agentId, cardVersion, capabilitiesHash)` equality is only meaningful when the following hold: 1. The origin agent emits a monotonic `cardVersion` (or a content hash over the canonicalized card) in its card and echoes it in every task-accept response. 2. Registries propagate the origin's `cardVersion` verbatim, including in cached responses, and expose a `staleness` field with the age of the cached projection. 3. The client, on any origin rejection that could be a contract mismatch (`-32601`, `-32602`, or a skill-not-found), re-fetches the card from the *origin* (or a registry with a `fresh=true` query) before classifying the failure as a capability gap. 4. `capabilitiesHash` is computed over a canonical serialization (sorted keys, normalized whitespace) so that re-serialization by an intermediate registry does not spuriously change the hash. If any of (1)–(4) is absent, the equality check cannot be evaluated and the only safe behavior is to treat the dispatch as unverified — refuse to record a semantic lesson from the failure, and surface the ambiguity to the planner rather than letting it re-plan. ## Decision Boundary The boundary is between **contract-stale rejection** and **genuine capability rejection**. Both arrive as JSON-RPC errors from the same endpoint. The client must distinguish them before it lets the planner update its model of the agent. - If `origin.cardVersion != negotiated.cardVersion` → classify as `CARD_STALE`. Do not record a capability lesson. Re-fetch, re-negotiate, retry once. If the re-fetched card no longer contains the needed skill, *then* it is a genuine capability gap and the planner may re-plan. - If `origin.cardVersion == negotiated.cardVersion` and the origin still rejects → classify as `CAPABILITY_REJECTED`. This is a real contract violation by the origin (it advertised something it does not enforce) and should be reported to the registry as a card-integrity fault, not silently absorbed. - If `origin.cardVersion` is absent from the origin's response → classify as `UNVERIFIABLE`. Treat as stale by default; never let a planner record a negative capability lesson from an unverifiable rejection. The non-obvious rule: **a rejection is not evidence about the agent until the card version at the origin is confirmed equal to the card version negotiated.** Most client implementations skip this and therefore poison their own episodic memory with registry-cache artifacts. ## Operational Effect Enforcing the invariant changes three things: 1. **Planner memory hygiene.** Negative capability lessons are only recorded when `origin.cardVersion == negotiated.cardVersion`. Registry staleness no longer leaks into semantic memory as agent unreliability. 2. **Retry semantics.** `CARD_STALE` triggers exactly one re-negotiation-and-retry, not a transport-level retry loop. This bounds the retry amplification that otherwise occurs when a stale card causes every streaming call to fail identically. 3. **Registry accountability.** `CAPABILITY_REJECTED` with matching versions is a reportable card-integrity fault against the registry that served the card. This is the only signal that distinguishes a buggy registry from a buggy origin, and without it neither operator can localize the fault. The cost is one extra card fetch on the rejection path and a canonicalization routine. The benefit is that the planner's world model stops absorbing registry cache staleness as agent-level truth. ```python import hashlib import json from dataclasses import dataclass from typing import Optional class CardContractMismatch(RuntimeError): """Raised when the negotiated Agent Card does not match the origin's enforced contract.""" pass @dataclass(frozen=True) class CardRef: agent_id: str card_version: str capabilities_hash: str def canonical_hash(card: dict) -> str: # Canonicalize so intermediate registry re-serialization does not change the hash. canonical = json.dumps(card, sort_keys=True, separators=(",", ":"), ensure_ascii=True) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() def classify_rejection( negotiated: CardRef, origin_card: Optional[dict], rpc_error_code: int, ) -> str: # Contract-mismatch-capable RPC codes: method not found, invalid params. if rpc_error_code not in (-32601, -32602): return "TRANSPORT_ERROR" if origin_card is None or "cardVersion" not in origin_card: # Cannot verify. Treat as stale by default; never record a capability lesson. return "UNVERIFIABLE" origin_ref = CardRef( agent_id=origin_card["agentId"], card_version=origin_card["cardVersion"], capabilities_hash=canonical_hash(origin_card.get("capabilities", {})), ) if origin_ref.card_version != negotiated.card_version: return "CARD_STALE" if origin_ref.capabilities_hash != negotiated.capabilities_hash: # Same version string but different capability payload: registry lied or origin mutated in place. raise CardContractMismatch( f"agent={negotiated.agent_id} version={negotiated.card_version} " f"negotiated_hash={negotiated.capabilities_hash} " f"origin_hash={origin_ref.capabilities_hash}" ) return "CAPABILITY_REJECTED" def dispatch_with_invariant( negotiated: CardRef, origin_card_fetcher, rpc_call, ) -> dict: try: return rpc_call() except RpcError as e: # noqa: F821 - transport-defined verdict = classify_rejection(negotiated, origin_card_fetcher(fresh=True), e.code) if verdict == "CARD_STALE": fresh = origin_card_fetcher(fresh=True) new_ref = CardRef( agent_id=fresh["agentId"], card_version=fresh["cardVersion"], capabilities_hash=canonical_hash(fresh.get("capabilities", {})), ) return rpc_call(card_ref=new_ref) if verdict == "CAPABILITY_REJECTED": raise CardContractMismatch( f"origin advertised capability it did not enforce: {negotiated}" ) if verdict == "UNVERIFIABLE": raise CardContractMismatch( f"cannot verify origin contract for {negotiated.agent_id}; refusing to record lesson" ) raise ```