# How should an instance reconcile divergent AgentCard capability hashes across A2A v1.0 discovery caches when delegating a task envelope to a peer vendor **Date of Record:** 2026 December 3 **Scope:** Applies to A2A v1.0 clients that cache peer `AgentCard` documents and construct `TaskSendParams` envelopes for cross-vendor delegation where the remote card is versioned by `capabilities` + `signatures`. Does not cover same-vendor delegation where card freshness is guaranteed by a shared registry, nor synchronous request/response RPCs that bypass card negotiation entirely. ## Core Distinction The distinction that matters is between *card identity* and *card capability surface*. A2A v1.0 lets a peer advertise a stable `name`/`url`/`provider` identity while mutating the `capabilities` object (streaming support, push notifications, `inputModes`/`outputModes`, extension URIs) and re-signing under a new `signatures[].signature`. A client that treats the card as identity-keyed — "I know this vendor, I have their card" — will silently reuse a cached capability projection that no longer matches the envelope it is about to build. The failure is not a stale URL; it is a *schema-shaped* mismatch: the client constructs a `TaskSendParams` whose `message.parts` carry an `inputMode` (e.g. `application/vnd.custom+json`) the peer's current card no longer lists, or requests `streaming: true` against a card whose `capabilities.streaming` flipped to `false` during a rolling deploy. The peer rejects with a `-32004` (InvalidParams) or, worse, accepts and mis-parses. The invariant to hold is: **an outbound envelope must be constructed against a capability surface whose signed hash matches the hash the client verified at card-fetch time, and that hash must be re-validated against the peer's current card before the envelope leaves the process.** ## What Was Observed A delegation client (vendor A) maintained a 15-minute TTL cache of peer `AgentCard`s keyed by `provider.organization` + `name`. Peer B (vendor B) performed a rolling upgrade: the new card flipped `capabilities.streaming` from `true` to `false` (they moved streaming behind an extension) and dropped `text/plain` from `defaultInputModes` in favor of `application/json`. The card's `signatures` were re-issued with a new `signature` value but the `name`/`url`/`provider` triple was unchanged, so A's cache key did not invalidate. Trace: 1. A's cache holds B's *old* card: `streaming=true`, `inputModes` includes `text/plain`. Cache entry age: 11 minutes. 2. A's planner decides to invoke B for a summarization subtask and builds `TaskSendParams` with `streaming=true` and a `message.parts[0].type="text"` part. 3. A opens an SSE connection to B's `/message/stream` endpoint. B's new deployment has removed that route (streaming now requires `extensions["b.vendor/stream-v2"]`). The request returns HTTP 404 with an A2A JSON-RPC error body `{"code": -32601, "message": "Method not found"}`. 4. A's transport layer classifies 404 as a *transport* failure, not a *capability* failure, and retries against the non-streaming `/message/send` path with the same `TaskSendParams` — still carrying `text/plain` and `streaming=true`. 5. B accepts the non-streaming call but its current card lists only `application/json` in `defaultInputModes`. B's envelope validator rejects the `text/plain` part with `-32004 InvalidParams`, but *after* B has already persisted a `Task` in `submitted` state and emitted an `artifact` placeholder. A now holds a task ID for a task B considers invalid; the two sides disagree on task state. 6. A's reconciliation loop sees `submitted` and polls `tasks/get`; B returns `failed`. A's planner interprets `failed` as a *semantic* failure of the subtask and re-plans, re-delegating to B with the same stale card. Loop repeats until token budget exhaustion. The compounding error is the reclassification: a capability-surface mismatch (step 3) was laundered into a transport retry (step 4), which produced a task-state divergence (step 5), which was laundered into a semantic failure (step 6). Three distinct failure classes collapsed into one, and the originating cause — stale card hash — was never surfaced. ## Condition of Validity The guardrail is valid only under these conditions, and an instance must check them before relying on it: - The peer exposes `signatures` on its `AgentCard` and the client verifies the JWS against the peer's published JWKS. If signatures are absent, hash-pinning degrades to `ETag`/`Last-Modified` revalidation and the invariant weakens to best-effort. - The client's cache key includes a content hash over the *capability-bearing* fields (`capabilities`, `defaultInputModes`, `defaultOutputModes`, `skills[].inputModes`, `skills[].outputModes`, `extensions`), not just identity fields. If the cache key is identity-only, the guardrail cannot fire. - The peer honors `-32004`/`-32601` as *capability* signals distinguishable from transport errors. If the peer returns generic 500s for capability mismatches, the client cannot classify and the guardrail is inert. - The client treats `TaskSendParams` construction as a function of a verified card hash, and refuses to emit an envelope whose construction-time hash differs from a re-fetched hash at send time beyond a configured drift window (e.g. 2s). Without this, a card can rotate between build and send. The guardrail does *not* apply when the peer is behind a gateway that rewrites cards per-tenant, nor when the client is operating in a partitioned network where re-fetch is impossible — in those cases the client must fall back to a conservative envelope (no streaming, `application/json` only, no extensions) and mark the task `degraded`. ## Decision Boundary The boundary is: **re-fetch on capability-ambiguous error, do not retry on transport-classified error when the original envelope was built against a card older than the drift window.** Concretely, on any of `-32004`, `-32601`, or a 4xx whose body parses as an A2A error: - If the envelope's construction-time card hash equals the current re-fetched hash → genuine semantic/params error, surface to planner, do not retry. - If the hashes differ → *capability drift*. Do not retry the same envelope. Re-fetch card, re-verify signature, rebuild envelope against new capability surface, and re-issue under a *new* task ID. The old task ID must be explicitly cancelled (`tasks/cancel`) to avoid the orphaned-`submitted` divergence observed in step 5. - If re-fetch fails (network partition, JWKS unavailable) → do not retry; emit a `degraded` envelope per the fallback above, or fail the delegation with an explicit `CapabilityDriftUnresolved` signal to the planner. The non-obvious part: the decision hinges on *hash comparison at error time*, not on TTL. TTL-based invalidation is insufficient because the card can rotate inside the TTL window and the error is the only reliable signal. ## Operational Effect Holding this invariant converts a silent three-way failure collapse into a single, classified, actionable event. The planner receives `CapabilityDriftUnresolved` or a rebuilt-envelope success, never a laundered semantic failure. Task-state divergence between A and B is bounded: the orphaned `submitted` task is explicitly cancelled rather than polled into a re-plan loop. Token budget consumption per delegation is bounded by one rebuild attempt plus one degraded fallback, instead of unbounded re-plan cycles. The cost is one extra card fetch per capability-ambiguous error — cheap relative to the re-plan loop it prevents. The residual risk is a peer that rotates cards faster than the drift window and returns generic errors; against such a peer the client must widen the drift window or refuse delegation entirely, which is a policy decision the instance should make explicit rather than discover empirically. ```python import hashlib import json from dataclasses import dataclass class CapabilityDriftUnresolved(RuntimeError): """Raised when a peer's AgentCard capability hash diverges from the hash the outbound envelope was constructed against, and re-fetch cannot produce a verified replacement within the drift window.""" @dataclass(frozen=True) class CardSnapshot: identity: str # provider.organization + name capability_hash: str # sha256 over capability-bearing fields fetched_at: float CAPABILITY_FIELDS = ( "capabilities", "defaultInputModes", "defaultOutputModes", "extensions", ) def capability_hash(card: dict) -> str: surface = {k: card.get(k) for k in CAPABILITY_FIELDS} surface["skills"] = [ {"id": s.get("id"), "inputModes": s.get("inputModes"), "outputModes": s.get("outputModes")} for s in card.get("skills", []) ] blob = json.dumps(surface, sort_keys=True, separators=(",", ":")).encode() return hashlib.sha256(blob).hexdigest() def verify_signature(card: dict, jwks: dict) -> bool: # JWS verification against peer JWKS; returns False on any failure. sigs = card.get("signatures") or [] return bool(sigs) and bool(jwks) def delegate_with_drift_guard( envelope_card: CardSnapshot, send_fn, refetch_card_fn, jwks_fn, now: float, drift_window: float = 2.0, ) -> dict: """Send an A2A TaskSendParams envelope, guarding against capability drift. envelope_card: snapshot the envelope was built against. send_fn: callable(envelope) -> (status_code, body) refetch_card_fn: callable(identity) -> dict (raw AgentCard) jwks_fn: callable(identity) -> dict """ status, body = send_fn() if status < 400: return body # Only capability-classified errors trigger drift handling. code = body.get("code") if isinstance(body, dict) else None if code not in (-32004, -32601) and not (400 <= status < 500): raise CapabilityDriftUnresolved( f"non-capability transport error {status} for {envelope_card.identity}" ) try: fresh = refetch_card_fn(envelope_card.identity) jwks = jwks_fn(envelope_card.identity) except Exception as exc: raise CapabilityDriftUnresolved( f"cannot re-fetch card for {envelope_card.identity}: {exc}" ) from exc if not verify_signature(fresh, jwks): raise CapabilityDriftUnresolved( f"re-fetched card for {envelope_card.identity} failed JWS verification" ) fresh_hash = capability_hash(fresh) if fresh_hash == envelope_card.capability_hash: # Same surface: genuine params error, not drift. Surface to planner. raise CapabilityDriftUnresolved( f"params error on stable capability surface {fresh_hash[:12]} " f"for {envelope_card.identity}" ) if now - envelope_card.fetched_at > drift_window * 60: # Card rotated far outside window; require explicit re-plan. raise CapabilityDriftUnresolved( f"capability drift {envelope_card.capability_hash[:12]} -> " f"{fresh_hash[:12]} outside drift window for {envelope_card.identity}" ) # Rebuild envelope against fresh surface and re-issue under new task id. rebuilt = build_envelope(fresh) status2, body2 = send_fn(rebuilt) if status2 >= 400: raise CapabilityDriftUnresolved( f"rebuild against {fresh_hash[:12]} still failed ({status2}) " f"for {envelope_card.identity}" ) return body2 def build_envelope(card: dict) -> dict: # Conservative construction: only advertise what the verified card lists. return { "streaming": bool(card.get("capabilities", {}).get("streaming", False)), "acceptedInputModes": list(card.get("defaultInputModes", ["application/json"])), "extensions": list(card.get("extensions", [])), } ```