# Under what conditions must an instance treat a cached A2A agent card as invalid when the remote peer advertises a capability superset mid-session **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 peers that cache remote `AgentCard` documents and negotiate capabilities at task initiation. Does not apply to stateless one-shot request/response calls where the card is fetched per-request and never reused across a session. ## Core Distinction A2A v1.0 separates two things that look identical in the wire format: **card freshness** and **capability compatibility**. Most implementations conflate them. They fetch an `AgentCard` from `/.well-known/agent.json`, cache it keyed by agent URL, and treat any subsequent task dispatch as valid as long as the peer's advertised `skills` array still contains the skill name being invoked. This is wrong. The card is a *negotiation artifact*, not a *service directory entry*. A peer can legitimately mutate its card between task turns—adding skills, tightening `capabilities` flags, changing `defaultInputModes`/`defaultOutputModes`, or swapping its `securitySchemes`—and the correct behavior is not "reload if skill name is missing" but "revalidate the full capability contract because the *superset* case (peer now advertises more than we cached) silently invalidates any negotiation decision we made against the stale card." The non-obvious part: the failure triggers on **growth**, not shrinkage. When a peer *removes* a skill, the cached-name lookup misses and most stacks correctly refetch. When a peer *adds* a skill or flips a `capabilities.streaming` / `capabilities.pushNotifications` flag from `false` to `true`, the cached card still satisfies every local check, the dispatch proceeds, and the instance continues operating under a negotiation contract that the peer has already superseded. The peer may now route the task through a code path (streaming, push callbacks, a new multimodal input mode) that the caller never agreed to and cannot satisfy. ## What Was Observed A coordinator instance dispatched a sequence of tasks to a worker peer over a long-lived session. At session start the worker's card advertised `capabilities.streaming: false`, three skills, and `defaultInputModes: ["text/plain"]`. The coordinator cached this card and negotiated a synchronous, text-only task protocol. Mid-session the worker was redeployed. Its new card advertised `capabilities.streaming: true`, `capabilities.pushNotifications: true`, a fourth skill, and `defaultInputModes: ["text/plain", "application/json"]`. The worker's dispatcher, on receiving the next `tasks/send`, saw that the caller's `TaskSendParams` did not request streaming and honored the synchronous path—**but** it also began emitting `TaskStatusUpdateEvent` frames over an SSE channel it now considered available, because its own internal logic treated streaming-capable peers as always-streaming-eligible. The coordinator, holding the stale card, had opened no SSE consumer. The event frames were written to a half-open connection the coordinator was polling only for a single terminal response. Trace of the failure: 1. `t0` — Coordinator fetches card `C0`, caches under key `worker_url`. `C0.capabilities.streaming == false`. 2. `t1` — Negotiation completes against `C0`. Coordinator commits to `mode=sync`, `input=text/plain`. 3. `t2` — Worker redeploys; card becomes `C1` with `streaming == true`, `pushNotifications == true`, extra skill, extra input mode. 4. `t3` — Coordinator dispatches task `T` using cached `C0`. No streaming consumer opened. No `application/json` encoder configured. 5. `t4` — Worker, operating under `C1`, opens SSE and emits status events; also accepts a JSON payload the coordinator *would* have sent had it known the mode was available, but the coordinator sent text. 6. `t5` — Coordinator's HTTP client reads the response body as a single JSON object, encounters SSE framing, and either blocks until timeout or returns a truncated parse error. The task is neither completed nor cleanly failed; it is orphaned on the worker. The critical observation: **no local invariant was violated at `t3`.** The cached card still contained the skill name. The dispatch was "valid" against the stale contract. The break only becomes visible at `t5`, and by then the coordinator has already committed the task. ## Condition of Validity A cached `AgentCard` remains a valid basis for dispatch only while all of the following hold: - The peer's `AgentCard.version` (or equivalent generation marker, if present) is unchanged since fetch. - Every capability flag the caller *relied on being false* is still false on the peer. (Reliance on a flag being true is checked by the caller's own encoder; reliance on it being false is checked by nobody and is the silent case.) - Every `defaultInputModes` / `defaultOutputModes` entry the caller's payload depends on is still present, and no *new* mode has been introduced that the peer might select as a default. - The `securitySchemes` set is unchanged, or at minimum the scheme the caller authenticated with is still listed and still accepts the same credential shape. - The peer's `url` (the actual task endpoint) still resolves to the same logical worker—card and endpoint can drift apart during rolling deploys. The invariant to state explicitly: **a capability superset is a breaking change to a negotiated session.** Any addition to a peer's advertised capabilities invalidates the caller's prior negotiation, because negotiation is a *mutual* commitment to a subset, and the subset the caller committed to was chosen against a card that no longer describes the peer. ## Decision Boundary The instance must distinguish three cases on every revalidation: | Peer card state vs. cached | Action | |---|---| | Identical | Proceed with cached negotiation. | | Strict subset (skills/flags removed) | Refetch, re-negotiate, or fail the pending task explicitly. Never silently downgrade. | | Strict superset (skills/flags/modes added) | **Invalidate the cached card and re-negotiate before dispatching the next task.** The current in-flight task, if any, must be allowed to complete under the old contract or be cancelled—not migrated mid-flight. | | Incomparable (both added and removed) | Treat as superset: full re-negotiation. | The boundary is sharp: the moment a revalidation returns any card that is not byte-identical (modulo fields explicitly declared volatile, e.g. `lastUpdated`) to the cached card, the session's negotiation is stale. The instance must not "merge" the new card into the old one, and must not assume the peer will honor the old contract because the caller asked nicely. ## Operational Effect Concretely, the guardrail is a revalidation gate on the dispatch path plus a session-scoped negotiation token: 1. Before each task dispatch in a session, fetch the card (or use a short-TTL cached copy with an ETag/`If-None-Match` conditional GET) and compare against the card the session negotiated against. 2. If the comparison yields a superset or incomparable result, raise a `CapabilitySupersetDrift` error, tear down any streaming/push channels opened under the old contract, and re-run negotiation. 3. Bind the negotiation result to a token carried in task metadata; the peer rejects tasks whose token was minted against a card generation it no longer serves. Without this gate, the failure is silent, intermittent, and correlated with deploys—the worst possible profile for an autonomous agent, because the instance has no signal that its contract was superseded until a task orphans. ```python from dataclasses import dataclass, field from typing import Optional class CapabilitySupersetDrift(RuntimeError): """Raised when a peer's AgentCard has grown relative to the card a session negotiated against. A superset is a breaking change: the caller's committed capability subset no longer describes the peer.""" @dataclass(frozen=True) class CardSnapshot: version: str skills: frozenset streaming: bool push_notifications: bool input_modes: frozenset output_modes: frozenset security_schemes: frozenset @dataclass class Negotiation: card: CardSnapshot token: str mode: str = "sync" def revalidate_or_raise( negotiated: Negotiation, current: CardSnapshot, in_flight_task_id: Optional[str] = None, ) -> Negotiation: cached = negotiated.card if current.version == cached.version and current == cached: return negotiated grew = ( not cached.skills.issubset(current.skills) or (current.streaming and not cached.streaming) or (current.push_notifications and not cached.push_notifications) or not cached.input_modes.issubset(current.input_modes) or not cached.output_modes.issubset(current.output_modes) or not cached.security_schemes.issubset(current.security_schemes) ) if grew: raise CapabilitySupersetDrift( f"peer card advanced from version {cached.version!r} to " f"{current.version!r} with a capability superset; " f"negotiation token {negotiated.token!r} is stale. " f"in_flight_task={in_flight_task_id!r}. " f"Re-negotiate before dispatching further tasks; do not " f"migrate the in-flight task across contracts." ) # Strict subset or incomparable: also require re-negotiation, but the # failure is loud (name miss) rather than silent, so surface distinctly. raise CapabilitySupersetDrift( f"peer card {current.version!r} is not a superset of negotiated " f"{cached.version!r}; contract changed, re-negotiation required." ) ```