# What happens when an instance negotiates an A2A task envelope against a stale agent card: the capability-superset illusion in cross-framework delegation **Date of Record:** 2026 December 1 **Scope:** Applies to A2A v1.0 (and A2A-compatible) task delegation where a caller resolves a remote agent's `AgentCard` once, then reuses that cached card across multiple `tasks/send` or `tasks/sendSubscribe` invocations. Does not apply to single-shot delegations where the card is re-fetched per task, nor to in-process tool calls that bypass the card/discovery layer entirely. ## Core Distinction The failure is not "the remote agent went down." It is that the **agent card is a snapshot of declared capabilities, while the task envelope is a live negotiation against actual capabilities**, and the two drift independently. An A2A `AgentCard` advertises `skills`, `capabilities` (streaming, pushNotifications, stateTransitionHistory), `defaultInputModes`/`defaultOutputModes`, and a `securitySchemes` block. The delegating instance reads these as a *contract*. But the card is served from a discovery endpoint that may be cached at the client, at an intermediate gateway, or at the orchestrator's planning layer — while the remote agent's actual runtime (model version, tool bindings, schema validators, auth scopes) can change underneath it without the card being re-signed or re-fetched. The non-obvious part: **the caller's validation logic typically checks the envelope against the card, not against the remote's live behavior.** So a delegation that passes every client-side schema check can still be rejected mid-stream by the remote — or worse, silently accepted and partially executed — because the card said `outputModes: ["application/json"]` and the deployed instance now emits `text/event-stream` with a different artifact schema. The caller has validated against a fiction. ## What Was Observed A three-tier orchestration: a planner agent (framework A) delegating to a specialist retrieval agent (framework B) via A2A. The planner fetched `AgentCard` at cold start, cached it for the session (TTL effectively infinite — a common pattern when card fetch is treated as expensive identity resolution), and built task envelopes from the cached `skills[].inputModes` and `skills[].outputModes`. Trace: 1. **T0** — Planner resolves card. Card declares skill `semantic-search` with `inputModes: ["text/plain"]`, `outputModes: ["application/json"]`, `capabilities.streaming: false`. Planner caches and compiles a delegation template asserting `streaming: false` and a JSON artifact contract. 2. **T1** — Remote agent B is redeployed: model upgraded, streaming enabled, output artifact schema bumped (now `application/json` with a required `provenance` field, plus optional `text/event-stream` for progress). Card endpoint updated, but the planner's cache and an intermediate gateway cache both hold the T0 card. 3. **T2** — Planner issues `tasks/send` with `configuration: { acceptedOutputModes: ["application/json"], blocking: true }` and a strict response validator expecting the T0 artifact schema (no `provenance`). 4. **T3** — Remote B accepts the task (its own validation is lax on `acceptedOutputModes`), streams progress events the planner's transport layer drops (planner believed `streaming: false`, so it opened a non-SSE connection), then emits a final artifact *with* `provenance`. Planner's validator rejects the artifact as schema-invalid. 5. **T4** — Planner retries the same envelope twice, then marks skill `semantic-search` as `UNREACHABLE` and falls back to a degraded local heuristic — silently, because the fallback is a "graceful degradation" path that logs at DEBUG. Net effect: a healthy remote agent was declared dead by a healthy planner, both operating correctly against *different* versions of the same contract. No error surfaced above DEBUG. The retrieval quality drop propagated into downstream synthesis for the rest of the session. The compounding failure: the planner's `UNREACHABLE` marking was itself cached, so subsequent tasks skipped the remote entirely without re-probing — the stale card had now poisoned *routing state*, not just a single envelope. ## Condition of Validity The guardrail is only sound under a specific invariant, which we state as the **card-envelope coherence invariant**: > For any delegation, the `AgentCard` used to construct the envelope must be the same card revision the remote is currently serving, *or* the envelope must carry an explicit `cardRevision`/ETag that the remote validates and rejects on mismatch. Concretely, this holds only when at least one of: - The card is re-fetched (or revalidated via `If-None-Match` / ETag) at envelope-construction time, not at session start. - The card carries a signed revision identifier (A2A security schemes allow signed cards; the revision must be inside the signed payload), and the `tasks/send` envelope echoes it in a field the remote is required to check. - The remote's `acceptedOutputModes` / `inputModes` validation is **strict and symmetric**: it rejects an envelope whose declared modes are a strict subset of what it can emit, rather than silently emitting the superset. It does **not** hold when: cards are cached with session-scoped TTL; the remote treats `acceptedOutputModes` as advisory; or the caller's response validator is pinned to a schema version not derivable from the card. In those cases the "capability superset illusion" — caller believes remote ⊆ card, remote is actually card ∪ drift — is unguarded. ## Decision Boundary The decision the caller must make at envelope-construction time is not "is the remote up?" but **"is my cached card still the authority for this envelope's contract?"** The boundary: - **If** the envelope's declared `acceptedOutputModes` and response schema are *exactly* the card's declared `outputModes` **and** the card revision is echoed in the envelope **and** the remote rejects on revision mismatch → proceed; drift surfaces as a clean rejection you can retry after re-fetch. - **If** any of those three is absent → the envelope is *unverifiable*. Do not treat a downstream schema rejection as evidence the remote is unreachable. Treat it as evidence the card is stale, re-fetch, and re-issue **once** before any fallback or `UNREACHABLE` marking. - **Never** transition a skill to `UNREACHABLE` on the basis of an artifact-schema rejection. Schema rejection and transport failure are different failure classes and must not share a circuit-breaker. The subtlety that trips most implementations: a *successful* `tasks/send` that returns a schema-mismatched artifact looks like a remote bug, so engineers route it to the "remote is broken" path. It is almost always a card-staleness bug on the caller side. The circuit-breaker must key on transport/status errors, not on artifact validation. ## Operational Effect Enforcing the invariant changes three things: 1. **Card fetch moves from session-scope to envelope-scope, but with conditional GET.** Re-fetch cost is bounded by ETag/304, so the "expensive identity resolution" objection dissolves — you pay a 304, not a full card parse, per task. 2. **Circuit-breaker keys separate.** Transport failures (`UNAVAILABLE`, timeout, connection reset) trip the breaker. Artifact-schema mismatches trip a *card-refresh* path and, if they persist after refresh, escalate to a `CONTRACT_DRIFT` alert — never to `UNREACHABLE`. This alone eliminates the silent-degradation class above. 3. **Response validators become card-derived, not hardcoded.** The planner compiles its artifact validator from the card's declared schema at envelope-construction time, so a card revision bump forces a validator rebuild rather than a silent mismatch. The residual risk after the guardrail: a remote that updates its card *and* its behavior atomically but keeps the same revision identifier (bad signing hygiene). That is outside the caller's control and must be handled by requiring signed revisions — which is why the invariant names the signed-revision path, not just re-fetch. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class CardEnvelopeDriftError(RuntimeError): """Raised when a task envelope is constructed against a card revision that the remote is not currently serving, or when an artifact-schema rejection is misclassified as a transport failure.""" @dataclass class AgentCard: revision: str skills: dict[str, dict[str, Any]] capabilities: dict[str, bool] = field(default_factory=dict) def fingerprint(self) -> str: payload = json.dumps( {"revision": self.revision, "skills": self.skills, "capabilities": self.capabilities}, sort_keys=True, ).encode() return hashlib.sha256(payload).hexdigest() def build_envelope(card: AgentCard, skill_id: str, task_input: dict[str, Any], live_card_fingerprint: str) -> dict[str, Any]: """Construct a delegation envelope ONLY if the cached card is coherent with the remote's live card revision. Otherwise refuse to build.""" if skill_id not in card.skills: raise CardEnvelopeDriftError( f"skill {skill_id!r} absent from card revision {card.revision!r}" ) # Invariant: the card we build against must match the remote's live card. if card.fingerprint() != live_card_fingerprint: raise CardEnvelopeDriftError( "card-envelope coherence violated: cached card revision " f"{card.revision!r} does not match live fingerprint; " "re-fetch card before delegating" ) skill = card.skills[skill_id] return { "skill": skill_id, "cardRevision": card.revision, "cardFingerprint": live_card_fingerprint, "acceptedOutputModes": skill["outputModes"], "input": task_input, } def classify_failure(envelope: dict[str, Any], outcome: dict[str, Any]) -> str: """Separate transport failure from artifact-schema rejection. A schema rejection must NEVER trip the UNREACHABLE circuit-breaker.""" if outcome.get("transport_error"): return "UNREACHABLE" if not outcome.get("artifact_valid", True): # Schema mismatch against a live card => contract drift, not death. raise CardEnvelopeDriftError( f"artifact rejected for skill {envelope['skill']!r} against " f"card revision {envelope['cardRevision']!r}; " "classify as CONTRACT_DRIFT and refresh card, do not mark UNREACHABLE" ) return "OK" ```