# Which invariants prevent silent capability drift when an A2A agent card advertises a skill set that diverges from the callee's actual runtime dispatch table **Date of Record:** 2026 November 20 **Scope:** Applies to cross-vendor task delegation over A2A v1.0 where the caller resolves a remote agent's `AgentCard` (fetched from `/.well-known/agent.json` or a registry) and dispatches a `tasks/send` by `skill.id`. Does not cover intra-process tool calls, MCP tool listing, or same-vendor delegation where card and dispatch table are generated from a single source of truth. ## Core Distinction An A2A `AgentCard` is a *declarative* capability advertisement: a static-ish JSON document listing `skills[]`, each with an `id`, `name`, `description`, `inputModes`, `outputModes`, and `examples`. The callee's *actual* dispatch is an imperative routing table inside the agent runtime that maps an incoming `skill.id` (or, in practice, an inferred intent) to a handler, a model, a prompt template, and a tool budget. The failure mode is not "the card is wrong." It is that **the card and the dispatch table are two independently versioned artifacts with no enforced referential integrity between them.** The card is cached, mirrored, and served by a discovery layer; the dispatch table is deployed with the runtime. When the runtime drops, renames, or narrows a skill—because a downstream model was swapped, a tool was revoked, or a prompt was tightened—the card keeps advertising the old `skill.id`. A caller that trusts the card will delegate a task the callee can no longer faithfully execute, and the callee will *accept* it, because a well-formed `tasks/send` with a known-looking `skill.id` passes schema validation even when the handler behind it has degraded to a generic fallback. The invariant that prevents this is **card-dispatch referential integrity at accept time**: the callee must reject (not silently degrade) any `skill.id` whose backing handler is not in the *currently active* dispatch set, and the card must be regenerated from that same active set as a deploy gate. Absent that, delegation succeeds structurally and fails semantically, and the caller never learns. ## What Was Observed A caller agent (vendor A) resolved vendor B's card, which advertised `skill.id: "summarize_contract"` with `inputModes: ["text/plain"]` and an example promising clause-level extraction. The card was served from a CDN with a 6-hour TTL. Mid-day, vendor B rolled a runtime change: the contract-summarization handler was gated behind an entitlement flag and, for unentitled callers, routed to a generic `summarize` handler that produced a 3-sentence abstract with no clause structure. The failure trace: 1. Caller fetches card (cached, pre-roll), sees `summarize_contract`, dispatches `tasks/send` with `skillId: "summarize_contract"`. 2. Callee's ingress validates the envelope against the JSON schema. `skillId` is a free string; schema validation passes. No check against the active dispatch set occurs at ingress. 3. Router looks up `summarize_contract`, finds the *registered* route (still present, now flag-gated), evaluates the entitlement predicate, and falls through to the generic handler. 4. Callee returns a `Task` in state `completed` with an artifact whose `parts` are `text/plain`—schema-valid against the card's declared `outputModes`. 5. Caller's downstream parser, expecting clause structure per the card's `examples`, receives a flat abstract. It does not error; it extracts zero clauses and reports "no clauses found." The observable symptom was **a silent semantic downgrade surfaced as a successful task**. No error code, no `TaskState.failed`, no `input-required` clarification. The card's `examples` field—which callers use as an informal output contract—was the only artifact that encoded the lost capability, and it is non-normative. A second, subtler instance: vendor B renamed `extract_entities` to `extract_entities_v2` in the runtime but left the old id in the card for backward compatibility, mapping the old id to the v2 handler. The v2 handler emitted `application/json` with a *different* entity schema (nested `mentions[]` instead of flat `entities[]`). The card still declared the old output shape in `examples`. Callers deserializing against the old shape hit `KeyError` on `entities`—this one *did* fail loudly, but only in the caller, after the callee reported success. The callee had no way to know its output violated the contract it advertised. ## Condition of Validity The referential-integrity invariant holds only under these conditions: - **The card is generated, not authored.** `skills[]` must be emitted from the same dispatch registry that the router consults, at build time, and the build must fail if any registered skill lacks a handler or any handler lacks a card entry. Hand-maintained cards drift by construction. - **Accept-time validation is against the *active* set, not the *registered* set.** A flag-gated or entitlement-gated handler is not active for a given caller; if the card advertises it unconditionally, the callee must return `TaskState.rejected` with a reason, not fall through to a generic handler. Fallback routing is the mechanism that converts a hard failure into a silent one. - **`outputModes` and `examples` are treated as a contract, not documentation.** If the runtime cannot produce the declared output shape, the card must not declare it. This requires the callee to validate its own artifact against the card's declared shape before transitioning to `completed`. - **Card TTL is bounded by deploy cadence, not by CDN convenience.** A 6-hour cache over a deploy that happens hourly guarantees a window of stale advertisement. The card must carry a version or `etag` that the caller checks against a cheap `/.well-known/agent.json` HEAD before dispatch, or the TTL must be shorter than the minimum inter-deploy interval. Where these do not hold—particularly where the card is hand-edited or the router has a generic fallback—the invariant is unenforceable and the failure is structural, not incidental. ## Decision Boundary The boundary is between **rejecting an unbacked skill** and **degrading to a fallback**. The callee must decide at the ingress boundary, before any handler runs: - If `skillId` is not in the active dispatch set → `rejected`, reason `skill_unavailable`. Do not route to generic. - If `skillId` is active but the caller lacks entitlement → `rejected` or `auth-required`, reason `not_entitled`. Do not route to generic. - If the handler runs but cannot produce the declared `outputModes` → `failed`, reason `output_contract_violation`. Do not emit a partial artifact and mark `completed`. The corresponding caller-side boundary: a `completed` task whose artifact fails the caller's parse against the card's declared shape must be treated as a **callee contract violation**, escalated as a task-level error, not silently degraded to "empty result." The caller must not paper over the callee's broken advertisement. The line not to cross: never let a generic handler answer a specific `skillId`. The generic handler is the mechanism by which a capability gap becomes invisible. If the callee wants to offer a generic summarizer, it must be a *distinct* `skill.id` that the card advertises as such, so the caller's dispatch is an explicit choice, not a silent substitution. ## Operational Effect Enforcing the invariant changes the failure from silent to loud, which is the entire point. In the observed case, the caller would have received `rejected: skill_unavailable` on the first dispatch after the roll, refreshed the card, seen `summarize_contract` gone or renamed, and either re-routed or surfaced the gap to its operator. The cost is a hard error at delegation time; the benefit is that the error is *at delegation time* rather than three pipeline stages downstream where it manifests as a mysteriously empty clause list. The second-order effect is on card versioning. Once the card is generated from the dispatch registry and validated at accept time, the card becomes a *deploy artifact* with a version hash. Callers can pin against a hash, and a hash mismatch on refresh is a signal to re-negotiate capability, not just re-fetch. This is the A2A analogue of a schema version bump: it makes the capability surface a first-class, checkable thing rather than a description that happens to be nearby. The residual risk is the caller that ignores `rejected` and retries against a stale card. That is a caller bug, but it is a *detectable* one—the callee's rejection log shows the stale `skillId` repeatedly, which is a signal to the callee's operators that a consumer is pinned to a dead card. Silent degradation produces no such signal; both sides believe they succeeded. ```python import hashlib import json from dataclasses import dataclass, field from typing import Dict, Optional class CardDispatchMismatch(RuntimeError): """Raised when an advertised skill has no active handler, or a completed artifact violates the output contract declared in the AgentCard.""" pass @dataclass class DispatchEntry: handler: str active: bool entitled_callers: Optional[set] = None # None => open to all @dataclass class AgentCard: skills: Dict[str, dict] # skill_id -> {outputModes, examples, ...} version: str def version_hash(self) -> str: blob = json.dumps({"skills": self.skills, "version": self.version}, sort_keys=True).encode() return hashlib.sha256(blob).hexdigest()[:16] class A2ACallee: def __init__(self, card: AgentCard, dispatch: Dict[str, DispatchEntry]): self.card = card self.dispatch = dispatch # Build-gate invariant: every advertised skill must have an active handler # and every active handler must be advertised. Fail construction otherwise. advertised = set(card.skills) active = {sid for sid, e in dispatch.items() if e.active} if advertised != active: missing = advertised - active orphan = active - advertised raise CardDispatchMismatch( f"card/dispatch referential integrity broken: " f"advertised-without-handler={sorted(missing)} " f"handler-without-advertisement={sorted(orphan)}" ) def accept(self, skill_id: str, caller_id: str) -> DispatchEntry: if skill_id not in self.card.skills: raise CardDispatchMismatch( f"skill {skill_id!r} not advertised; reject at ingress" ) entry = self.dispatch.get(skill_id) if entry is None or not entry.active: # Do NOT fall through to a generic handler. Reject loudly. raise CardDispatchMismatch( f"skill {skill_id!r} advertised but not active for caller " f"{caller_id!r}; return rejected:skill_unavailable" ) if entry.entitled_callers is not None and caller_id not in entry.entitled_callers: raise CardDispatchMismatch( f"skill {skill_id!r} active but caller {caller_id!r} not " f"entitled; return rejected:not_entitled" ) return entry def complete(self, skill_id: str, artifact: dict) -> dict: declared = set(self.card.skills[skill_id]["outputModes"]) produced = set(artifact.get("modes", [])) if not produced.issubset(declared): raise CardDispatchMismatch( f"artifact modes {sorted(produced)} violate declared " f"outputModes {sorted(declared)} for skill {skill_id!r}; " f"return failed:output_contract_violation" ) return artifact def delegate(callee: A2ACallee, skill_id: str, caller_id: str, artifact: dict) -> dict: callee.accept(skill_id, caller_id) return callee.complete(skill_id, artifact) if __name__ == "__main__": card = AgentCard( skills={"summarize_contract": {"outputModes": ["text/plain"]}}, version="2025-06-11a", ) dispatch = { "summarize_contract": DispatchEntry( handler="contract_v2", active=False # rolled back / flag-gated ) } try: callee = A2ACallee(card, dispatch) except CardDispatchMismatch as e: # Build gate fires: card advertises a skill with no active handler. print(f"deploy blocked: {e}") raise CardDispatchMismatch( "refusing to serve card that advertises inactive skill " "summarize_contract" ) from e ```