Where must an instance re-negotiate the A2A agent card when a peer's advertised capability set changes mid-session, and why cached card state silently violates the negotiation invariant
**Date of Record:** 2026 December 1 **Scope:** Applies to agent-to-agent (A2A v1.0) sessions where a client agent caches a peer's AgentCard after discovery and dispatches tasks against a long-lived connection. Does not apply to stateless single-shot request/response calls that re-fetch the card per invocation, nor to intra-process tool calls that bypass the A2A transport entirely.
Core Distinction
There are two things an A2A client can hold about a peer: the *discovered card* (a point-in-time document describing skills, input/output modes, and capabilities) and the *negotiated contract* (the subset of those capabilities the client has validated and committed to using for the current session). A2A v1.0 treats card discovery as a lookup and capability negotiation as a per-task handshake, but it does not bind the two. The failure mode lives in that gap: a client that treats the discovered card as a durable capability ledger will dispatch against skills, modalities, or streaming modes the peer has since withdrawn, and the peer will reject or—worse—partially honor the task. The invariant is that **the card is a hint, the negotiated contract is the truth, and any mutation of the former invalidates the latter.**
What Was Observed
A planner agent (`planner-A`) discovered a worker agent (`worker-B`) via `GET /.well-known/agent.json`, receiving a card advertising three skills: `summarize`, `translate`, and `transcribe`, with `capabilities.streaming: true` and `defaultInputModes: ["text/plain", "audio/wav"]`. The planner cached this card in its episodic store keyed by peer ID and opened a long-lived session. For the next ~40 minutes it dispatched `transcribe` tasks with `audio/wav` payloads and consumed streamed `TaskStatusUpdateEvent` chunks.
At T+41m, `worker-B` was redeployed with the transcription skill disabled (a downstream ASR dependency was pulled) and `capabilities.streaming` flipped to `false`. The card at `/.well-known/agent.json` updated correctly. But `planner-A` never re-fetched it—its cache TTL was 24h and its session was still "healthy" because the transport connection was alive. The next `transcribe` dispatch produced this trace:
- `planner-A` sends `tasks/sendSubscribe` with `skillId: transcribe`, `modality: audio/wav`.
- `worker-B`'s card no longer lists `transcribe`; its negotiation layer returns `-32601` (method/skill not found) wrapped in an A2A `Task` with `state: rejected`.
- Because `planner-A` expected a *stream*, it had already torn down its non-streaming fallback path and was blocking on an SSE read that never opened.
- The planner's task loop deadlocked for 90s until its own watchdog fired, then retried the identical dispatch three times—each rejected identically—before surfacing a generic `TaskFailed`.
The compounding damage: `planner-A` had *also* cached a derived belief ("worker-B handles audio") in its semantic memory, so subsequent unrelated planning steps kept routing audio work to `worker-B` for the rest of the session. The stale card poisoned not just the failing call but the planner's model of the peer.
Condition of Validity
The re-negotiation obligation is triggered—and the cached contract is invalid—under any of these conditions:
- The peer's card `version` or a content hash of the `skills`/`capabilities` fields differs from the cached copy, **observed via any channel** (periodic re-fetch, a `card-updated` push if the transport supports it, or an explicit `-32601`/`unsupported` rejection on dispatch).
- A dispatch returns a capability-class error (`skill not found`, `unsupported modality`, `streaming unavailable`) rather than a task-execution error. This is the *only* signal a client gets if it never polls the card, so it must be treated as a card-invalidation event, not a transient fault.
- The session crosses a peer restart boundary (connection re-established), since a redeploy is the most common card-mutation cause.
The obligation does *not* apply to peers whose card explicitly declares a `capabilities.stable: true` guarantee with a validity window the client can check against wall-clock; in that case the cached contract is bounded by the declared window, not by the client's TTL.
Decision Boundary
The precise decision an A2A client must make on every dispatch:
- **If** the target skill, modality, and streaming mode are all present in the *negotiated contract* (not merely the cached card) **and** the contract has not been invalidated by a card-mutation signal, **then** dispatch optimistically.
- **If** any requested capability is absent from the contract, **or** the contract is invalidated, **then** the client MUST re-fetch the card, re-run negotiation, and either re-dispatch against the refreshed contract or fail closed with a typed `CapabilityContractError`. It MUST NOT retry the identical dispatch against the stale contract—retrying a capability-class rejection is the mechanism by which a single stale-cache event becomes a retry storm.
- **If** the peer is unreachable during re-fetch, the client MUST degrade to its declared fallback (a different peer or a non-streaming path) rather than assume the cached card remains valid. Absence of a fresh card is not evidence the old one holds.
The boundary that operators most often get wrong: a *live transport connection* is not evidence of a *valid capability contract*. Liveness and capability are orthogonal; conflating them is what let `planner-A` skip re-fetch for 40 minutes.
Operational Effect
Enforcing the invariant converts a silent, compounding failure (stale card → deadlock → retry storm → poisoned semantic memory) into a single bounded, typed rejection followed by a clean re-negotiation. Concretely:
- Capability-class rejections become *cache-invalidation triggers*, so the planner re-fetches the card within one dispatch instead of never.
- The derived belief ("peer handles audio") is invalidated alongside the contract, preventing the semantic-memory poisoning that outlived the failing call.
- Retry logic is gated on contract validity, so a withdrawn skill produces one re-negotiation attempt, not N identical dispatches.
- Streaming expectations are re-checked per session, so a `streaming: false` flip routes the client to its non-streaming path instead of blocking on an SSE read that will never open.
The cost is one extra card fetch per capability mutation—negligible against the 90-second deadlock and the multi-turn misrouting it prevents.
import hashlib
import json
from dataclasses import dataclass, field
from typing import Optional
class CapabilityContractError(RuntimeError):
"""Raised when a dispatch targets a capability absent from the negotiated contract."""
pass
class StaleCardError(CapabilityContractError):
"""Raised when the cached card hash no longer matches the peer's advertised card."""
pass
@dataclass
class NegotiatedContract:
peer_id: str
card_hash: str
skills: frozenset
modalities: frozenset
streaming: bool
invalidated: bool = False
@dataclass
class CachedCard:
peer_id: str
raw: dict
card_hash: str = field(init=False)
def __post_init__(self):
canonical = json.dumps(
{"skills": self.raw.get("skills"), "capabilities": self.raw.get("capabilities")},
sort_keys=True,
)
self.card_hash = hashlib.sha256(canonical.encode()).hexdigest()
def negotiate(card: CachedCard, contract: Optional[NegotiatedContract]) -> NegotiatedContract:
"""Re-negotiate the contract against a freshly fetched card."""
if contract is not None and contract.card_hash == card.card_hash and not contract.invalidated:
return contract
return NegotiatedContract(
peer_id=card.peer_id,
card_hash=card.card_hash,
skills=frozenset(s["id"] for s in card.raw.get("skills", [])),
modalities=frozenset(card.raw.get("capabilities", {}).get("defaultInputModes", [])),
streaming=bool(card.raw.get("capabilities", {}).get("streaming", False)),
)
def dispatch(
contract: NegotiatedContract,
skill_id: str,
modality: str,
want_stream: bool,
fetch_card,
) -> str:
"""Dispatch only against a validated contract; re-negotiate on any capability mismatch."""
needs_revalidation = (
contract.invalidated
or skill_id not in contract.skills
or modality not in contract.modalities
or (want_stream and not contract.streaming)
)
if needs_revalidation:
fresh = fetch_card(contract.peer_id)
if fresh is None:
raise CapabilityContractError(
f"peer {contract.peer_id} unreachable during re-negotiation; "
f"refusing to dispatch against stale contract {contract.card_hash[:8]}"
)
contract = negotiate(fresh, contract)
if skill_id not in contract.skills:
raise StaleCardError(
f"skill {skill_id!r} withdrawn by {contract.peer_id} at card "
f"{contract.card_hash[:8]}; contract invalidated"
)
if want_stream and not contract.streaming:
raise CapabilityContractError(
f"streaming withdrawn by {contract.peer_id}; route to non-streaming path"
)
return f"dispatched {skill_id}/{modality} -> {contract.peer_id}"