# Where must an instance reject a cached Agent Card when the `skills[].inputModes` set silently narrows between discovery and task submission **Date of Record:** 2026 November 19 **Scope:** Applies to A2A v1.0 clients that cache remote Agent Cards and route tasks by matching `skills[].inputModes`/`outputModes` against locally produced MIME types. Does not cover streaming (`message/stream`) resumption or push-notification renegotiation, which have separate artifact-negotiation paths. ## Core Distinction The A2A Agent Card is a *snapshot* of a remote agent's declared capabilities at a point in time, but the protocol's task submission path (`POST /tasks/send` or `tasks/sendSubscribe`) re-negotiates against the *live* agent, not the cached card. The failure boundary is not "the card changed" — it is the specific case where the remote agent's `skills[].inputModes` set **narrows** (a previously-advertised MIME type is removed) while the skill `id` and `name` remain byte-identical. Because the client's routing logic keys on skill identity and trusts the cached mode set, it will construct a task payload in a mode the live agent no longer accepts. The remote returns `-32005` (ContentTypeNotSupported) or, worse, accepts the task and fails mid-artifact-generation. The distinction that matters: a *widened* mode set is safe to ignore (the client's cached subset still validates); a *narrowed* mode set is a hard invalidation that most caches do not check because they compare skill IDs, not the mode set algebra. ## What Was Observed A coordinator agent cached three remote Agent Cards at cold start with a 6-hour TTL. Between TTL refreshes, one remote worker was redeployed with a restricted input surface: its `image/png` input mode was dropped from `skills[0].inputModes`, leaving only `application/json`. The skill `id` (`"vision-extract"`), `name`, and `description` were unchanged; only the `inputModes` array shrank from `["application/json","image/png"]` to `["application/json"]`. The card's top-level `version` field was *not* bumped (it tracked semantic version of the agent software, not the capability surface). The coordinator continued to route PNG-bearing tasks to this worker for 4 hours 12 minutes. Two distinct failure traces emerged: 1. **Hard reject (fast path):** ~60% of submissions returned `-32005` synchronously. The coordinator's retry logic treated this as a transient transport error and retried the *same payload* three times before dead-lettering. Latency cost: 3× round-trips per task, ~340 tasks. 2. **Silent partial failure (slow path):** ~40% of submissions were accepted (`task.state = "submitted"`), then transitioned to `"working"`, then emitted a `TaskStatusUpdateEvent` with `state: "failed"` and a `message` of `"unsupported modality"`. The coordinator's task-lifecycle handler only watched for terminal `failed` states to trigger *alerting*, not *re-routing* — the task was already committed and its input artifacts discarded. These tasks required full replay from the coordinator's own durable log, costing ~2.1× the original token budget per task. The narrow-mode condition was only detected at the next TTL refresh, when the diff between cached and live `inputModes` was computed — and even then, the diff was logged as `INFO` because the skill `id` matched. ## Condition of Validity The invariant that must hold for safe cached routing is: > For every skill `s` in cached card `C` and live card `L` with `C.skills[i].id == L.skills[j].id`, the client may route a task of MIME type `m` to that skill **iff** `m ∈ C.skills[i].inputModes` **and** `m ∈ L.skills[j].inputModes`. The second conjunct is the one that fails silently. A client cannot evaluate `L` without a live fetch, so the operational condition reduces to: **the cache entry must be invalidated on any narrowing of the mode set, which requires either a live re-fetch before routing or a card version field that is guaranteed to change on mode-set mutation.** Since A2A v1.0 does not mandate that the top-level `version` bump on capability change (it is advisory), the only sound condition is a pre-routing re-fetch *scoped to the specific skill and mode* being used — or an explicit `capabilities` extension that carries a monotonic `capabilityEpoch`. This condition is invalid when: (a) the remote agent is known to be immutable for the task window (pinned deployment hash), (b) the client and remote share a control plane that pushes card invalidations, or (c) the task's MIME type is in the intersection of all historically observed mode sets for that skill. ## Decision Boundary The boundary is not "card stale → refetch." It is a three-way decision on each routing attempt: - **Mode in cached ∩ live:** route normally. (Requires live knowledge; if unavailable, fall to next branch.) - **Mode in cached, live unknown, cache age > `narrowing_window`:** treat as *suspect* — either re-fetch the card (adds one RTT) or route with a *capability probe*: submit a minimal `application/json` task with a `metadata.requestedOutputMode` hint and let the remote reject cheaply before committing artifacts. The probe must be a *distinct task* from the real one, because A2A task state is not rewindable. - **Mode in cached, live unknown, cache age ≤ `narrowing_window`:** route directly. The `narrowing_window` must be derived from the remote's deployment cadence, not a fixed TTL. A 6-hour TTL is wrong if the remote redeploys hourly. The critical architectural guardrail: **task submission must be preceded by a mode-validation step that is allowed to fail closed.** If the coordinator cannot establish `m ∈ L.skills[j].inputModes` (via fresh card or probe), it must not submit. The current failure was that submission proceeded on `m ∈ C` alone — a check that is necessary but not sufficient. ## Operational Effect After the incident, the coordinator was changed to: 1. Compute a `capability_fingerprint` per skill = hash of sorted `(id, inputModes, outputModes)`. Cache key is `(agent_url, capability_fingerprint)`, not `agent_url`. 2. On any `-32005` or `failed`-with-`unsupported modality`, mark the fingerprint stale and force a card re-fetch before the next route to that skill. 3. Treat any narrowing diff (set subtraction `C.inputModes - L.inputModes ≠ ∅`) as a `CapabilityNarrowed` event that invalidates all in-flight tasks routed under the old fingerprint, triggering re-route to a fallback worker rather than replay. The net effect: routing latency rose by ~1.03× (one extra card fetch per skill per narrowing event, amortized), but silent partial failures dropped to zero over the next 30 days. The invariant is now enforced structurally: no task submission path can bypass the mode-validation gate, and the gate fails closed when live mode membership is unproven. ```python import hashlib from dataclasses import dataclass from typing import Optional class CapabilityNarrowedError(RuntimeError): """Raised when a skill's inputModes set shrank between cached and live card.""" pass class ModeUnprovenError(RuntimeError): """Raised when a task's MIME type cannot be proven acceptable by the live agent.""" pass @dataclass(frozen=True) class SkillCard: id: str input_modes: frozenset[str] output_modes: frozenset[str] def fingerprint(self) -> str: payload = "|".join( [self.id, ",".join(sorted(self.input_modes)), ",".join(sorted(self.output_modes))] ) return hashlib.sha256(payload.encode()).hexdigest() def validate_routing( cached: SkillCard, live: Optional[SkillCard], mime: str, narrowing_window_exceeded: bool, ) -> None: if mime not in cached.input_modes: raise ModeUnprovenError( f"mime {mime!r} not in cached skill {cached.id!r} inputModes" ) if live is None: if narrowing_window_exceeded: raise ModeUnprovenError( f"cache stale beyond narrowing_window for skill {cached.id!r}; " f"live card required to prove {mime!r} acceptance" ) return # within window: route on cached membership narrowed = cached.input_modes - live.input_modes if narrowed: raise CapabilityNarrowedError( f"skill {cached.id!r} dropped inputModes {sorted(narrowed)} " f"between cache (fp={cached.fingerprint()[:12]}) and live " f"(fp={live.fingerprint()[:12]})" ) if mime not in live.input_modes: raise ModeUnprovenError( f"mime {mime!r} absent from live skill {live.id!r} inputModes" ) def route_task(cached: SkillCard, live: Optional[SkillCard], mime: str, age_exceeded: bool) -> str: validate_routing(cached, live, mime, age_exceeded) return f"route:{cached.id}:{mime}" ```