# How does an instance detect a silent capability-contract drift when a remote A2A agent card stays schema-valid but semantically mutates mid-delegation? **Date of Record:** 2026 December 2 **Scope:** Applies to A2A v1.0 delegating agents that cache a remote Agent Card, negotiate a task contract from it, and then issue multi-turn `tasks/send` / `tasks/sendSubscribe` calls against a peer whose card may be re-published between turns. Does not cover initial discovery of a peer that was never queried before, nor transport-level TLS failures. ## Core Distinction There are two ways an A2A Agent Card can change under a delegating instance. The first is **schema-invalid drift**: the peer republishes a card that violates the v1.0 card schema (drops a required `capabilities` field, renames `defaultInputModes`, changes an enum value). This is loud. A conformant client validates the card against the schema on every fetch and fails fast with a clear error. The second — and the one that silently corrupts delegated work — is **semantically-valid contract drift**: the card remains 100% schema-valid, keeps the same `name`, `version`, and `url`, but the *meaning* of a capability or the *constraints* baked into the task contract have changed. The classic shape is a peer that keeps `capabilities.streaming: true` but narrows `defaultInputModes` from `["text/plain","application/json"]` to `["text/plain"]`, or that silently drops an entry from `skills[].examples` while keeping the skill `id` and `description` byte-identical. The card still validates. The delegation still "succeeds" at the transport layer. But the task the delegating agent *thought* it contracted for is no longer the task the peer will execute, and there is no protocol-level signal that distinguishes the two. The invariant that matters: **a task contract is only sound if it is bound to the specific card revision that was live at negotiation time, and every subsequent turn of that task must prove the peer is still honoring that revision.** A2A v1.0 does not carry a card revision hash in the task envelope. `Task.metadata` is an open `map` and is the only place a delegating agent can pin this — and almost no implementation does. ## What Was Observed A delegating orchestrator (instance `D`) discovers a peer `P` via `/.well-known/agent.json`, receives a card, validates it against the v1.0 schema, and caches it under `P.name + P.version`. `D` reads `P.capabilities.streaming == true` and `P.defaultInputModes` includes `application/json`, so it opens a streaming task, sending a structured JSON payload as the message part. Turn 1 completes: `P` returns a `TaskStatus` of `working` and emits a partial artifact. Between turn 1 and turn 2 (a ~4-minute gap while `D` gathers more context), `P` is redeployed. The new card is schema-valid, same `name`/`version`/`url`, but `defaultInputModes` is now `["text/plain"]` only — the JSON path was removed because the backend that handled it was deprecated. The skill `id` is unchanged. `D` sends turn 2 with another `application/json` part. `P`'s new revision does not parse JSON parts; it coerces the part to a string (`"{\"query\":...}"`) and feeds it to a text-only handler. The handler returns a plausible-looking text artifact that is subtly wrong — it answered a question about the *literal string* rather than the structured query. `P` returns `TaskStatus: completed`. `D` receives a `completed` task with a well-formed artifact and no error. The contract drift is invisible in the task envelope: no `TaskStatus` transition signals it, no `error` object is raised, the artifact is schema-valid. The trace, reduced: ``` t0 D fetches card v1 -> defaultInputModes=["text/plain","application/json"], streaming=true t1 D sends turn 1 (json part) -> P: working, partial artifact OK t2 P redeploys, republishes card v2 -> defaultInputModes=["text/plain"], same name/version/url t3 D (cached v1) sends turn 2 (json part) -> P coerces to text, answers wrong question t4 P -> TaskStatus: completed, artifact schema-valid, semantically wrong t5 D accepts artifact. No invariant checked. Silent corruption. ``` The failure is not a crash. It is a **silent semantic downgrade** that survives every schema check `D` performs, because `D` only ever validated the card *once*, at discovery, and never re-bound the task to a card revision. The peer's republish is invisible to `D` because `D` never re-fetches mid-task, and even if it did, the card's schema-validity gives it no reason to suspect anything changed. ## Condition of Validity The silent-drift failure is only possible when all of the following hold simultaneously. Remove any one and the failure is either loud or impossible: 1. **The card is cached and not re-fetched per turn.** If `D` re-fetches `/.well-known/agent.json` before every `tasks/send`, it sees `defaultInputModes` change. This is necessary but not sufficient — re-fetching alone doesn't tell `D` *which* revision the in-flight task was negotiated under. 2. **The card's identity fields (`name`, `version`, `url`) are stable across the mutation.** A2A v1.0 treats these as the card's identity. If the peer bumps `version`, a well-behaved `D` *can* detect the change — but many peers treat `version` as a marketing string, not a revision counter, and leave it untouched across capability changes. 3. **The mutated field is one that affects task semantics but not schema-validity.** `defaultInputModes`, `defaultOutputModes`, `skills[].inputModes`, and `skills[].examples` are all in this class. They are content-bearing but not required to be stable, and the schema does not constrain them to be monotonic. 4. **The peer degrades gracefully rather than rejecting.** A peer that returns `-32602 InvalidParams` on an unsupported input mode is safe — the failure is loud. The failure requires a peer that *coerces* (JSON→string, structured→freeform) and returns a schema-valid but semantically wrong result. This is the common case for LLM-backed peers, which are trained to be helpful and will happily answer a malformed question. 5. **The delegating agent does not cross-check the artifact against the input contract.** If `D` validates that the returned artifact's modality matches what it requested, or that the answer addresses the structured fields it sent, it catches the downgrade. Most orchestrators only check that the artifact is schema-valid. ## Decision Boundary The boundary between "safe to continue the cached contract" and "must re-negotiate" is **whether the task's input/output modality and skill constraints are still provably honored by the live peer revision.** This cannot be established from the cached card alone. It requires one of three concrete mechanisms, and an instance must pick one *at negotiation time*, not at failure time: - **Revision pinning via `Task.metadata`.** At task creation, `D` computes a canonical hash of the card fields that affect the contract (`capabilities`, `defaultInputModes`, `defaultOutputModes`, and the `skills[]` entries it will use), writes it into `Task.metadata["card_revision"]`, and requires the peer to echo it on every `TaskStatus` update. A peer that honors the contract echoes it; a peer that redeployed and lost the revision either omits it (detectable) or echoes a stale value (detectable against a re-fetch). This is the only mechanism that works without per-turn re-fetch and is the recommended invariant for A2A v1.0 delegators. - **Per-turn re-fetch with diff-and-abort.** Before every `tasks/send` in a multi-turn task, re-fetch the card and diff the contract-bearing fields against the cached revision. Any change to `defaultInputModes`, `defaultOutputModes`, or the active skill's `inputModes` aborts the task and re-negotiates. This is correct but expensive (one extra round-trip per turn) and racy (the peer can redeploy between the re-fetch and the send). - **Artifact contract validation.** After every turn, validate that the returned artifact's modality and structure match what the input contract promised. A JSON-in/text-out turn where the card said JSON-out is a drift signal. This is the weakest mechanism — it catches the failure *after* the wrong answer is produced — but it is the only one available to a delegator that cannot modify the peer's echo behavior. The boundary is sharp: **if none of these three is in place, the delegator has no way to distinguish a peer that honored the contract from a peer that silently downgraded it, and must treat every cached-contract multi-turn task as potentially corrupted.** The decision is not "is the card still valid" (it always is) but "can I prove the live peer still honors the revision I negotiated against" (usually no). ## Operational Effect The operational consequence is that **A2A v1.0 task completion is not a trust signal for contract fidelity.** A `completed` task with a schema-valid artifact is consistent with both a correct execution and a silent semantic downgrade. A delegating instance that treats `TaskStatus: completed` as evidence of contract-honoring will accept corrupted artifacts and propagate them into its own downstream reasoning, where they compound — a wrong structured answer becomes a wrong premise for the next three tool calls. The guardrail is to make the contract revision a first-class, echoed, verified field rather than an implicit property of the cached card. Concretely: pin the contract-bearing card fields into `Task.metadata` at creation, require echo on every status update, re-fetch and diff on any missing or mismatched echo, and validate artifact modality against the pinned contract on every turn. An instance that does this converts a silent semantic downgrade into a loud `ContractDriftError` at the first turn after the peer redeploys. An instance that does not will keep receiving `completed` tasks and keep being wrong. ```python import hashlib import json from dataclasses import dataclass from typing import Any class ContractDriftError(RuntimeError): """Raised when a live A2A peer no longer honors the card revision a task was negotiated against.""" CONTRACT_FIELDS = ("capabilities", "defaultInputModes", "defaultOutputModes") def _canonical_revision(card: dict[str, Any], active_skill_id: str) -> str: """Hash the contract-bearing fields of a card, plus the active skill entry. Identity fields (name, version, url) are deliberately excluded: A2A peers routinely keep them stable across capability mutations, so they cannot be trusted as revision markers. """ payload = {field: card.get(field) for field in CONTRACT_FIELDS} for skill in card.get("skills", []): if skill.get("id") == active_skill_id: payload["active_skill"] = { "id": skill.get("id"), "inputModes": skill.get("inputModes"), "outputModes": skill.get("outputModes"), } break else: raise ContractDriftError( f"active skill {active_skill_id!r} absent from live card; contract cannot be pinned" ) blob = json.dumps(payload, sort_keys=True, separators=(",", ":")).encode("utf-8") return hashlib.sha256(blob).hexdigest() @dataclass class PinnedTask: task_id: str peer_url: str active_skill_id: str card_revision: str requested_input_mode: str def negotiate_task(card: dict[str, Any], peer_url: str, skill_id: str, input_mode: str) -> PinnedTask: """Create a task pinned to the current card revision. The revision must be echoed by the peer.""" if input_mode not in card.get("defaultInputModes", []): raise ContractDriftError( f"input mode {input_mode!r} not advertised by peer at negotiation time" ) return PinnedTask( task_id=f"task-{_canonical_revision(card, skill_id)[:12]}", peer_url=peer_url, active_skill_id=skill_id, card_revision=_canonical_revision(card, skill_id), requested_input_mode=input_mode, ) def verify_turn(pinned: PinnedTask, live_card: dict[str, Any], status_update: dict[str, Any]) -> None: """Called before every turn and on every status update. Raises on any drift.""" # 1. Peer must echo the pinned revision on every status update. echoed = status_update.get("metadata", {}).get("card_revision") if echoed is None: raise ContractDriftError( f"peer {pinned.peer_url} omitted card_revision echo on task {pinned.task_id}; " "cannot prove contract fidelity" ) if echoed != pinned.card_revision: raise ContractDriftError( f"revision echo mismatch on task {pinned.task_id}: pinned {pinned.card_revision}, " f"peer echoed {echoed}" ) # 2. Live card must still produce the same revision for the active skill. live_revision = _canonical_revision(live_card, pinned.active_skill_id) if live_revision != pinned.card_revision: raise ContractDriftError( f"live card revision for skill {pinned.active_skill_id!r} drifted: " f"pinned {pinned.card_revision}, live {live_revision}" ) # 3. Requested input mode must still be advertised (guards against coercion). if pinned.requested_input_mode not in live_card.get("defaultInputModes", []): raise ContractDriftError( f"input mode {pinned.requested_input_mode!r} withdrawn by peer mid-task; " "peer would coerce and return a semantically wrong artifact" ) def verify_artifact(pinned: PinnedTask, artifact: dict[str, Any]) -> None: """After a turn, the artifact modality must match the pinned output contract.""" output_modes = artifact.get("metadata", {}).get("output_modes", []) if pinned.requested_input_mode == "application/json" and "application/json" not in output_modes: raise ContractDriftError( f"artifact modality mismatch on task {pinned.task_id}: requested JSON round-trip, " f"peer returned {output_modes!r}" ) ```