# Which invariants prevent silent capability substitution when A2A v1.0 Agent Cards are re-discovered mid-negotiation **Date of Record:** 2026 November 26 **Scope:** Applies to A2A v1.0 task negotiation where an initiator re-fetches the peer's Agent Card from `/.well-known/agent-card.json` (or a signed extended card URI) after the initial handshake, and where the peer runtime may have been redeployed, autoscaled to a different build, or routed to a heterogeneous backend between fetches. Does not apply to single-shot, single-fetch interactions or to transports that pin a card hash for the lifetime of the task. ## Core Distinction There are two ways an Agent Card can change under a running task, and they are not equivalent: 1. **Card mutation with an unbroken task lineage.** The peer redeployed, the well-known URI now serves a new card, but the task ID, the `contextId`, and the negotiated `TaskState` history are still owned by the same logical agent process that accepted the task. The card changed; the contract did not. 2. **Card mutation with a broken lineage.** The re-discovery resolves to a *different* backing runtime that inherited the task ID (via shared queue, replica routing, or a replayed `tasks/get`) but never held the original negotiation state. The card changed *and* the contract did — silently. The boundary failure is that A2A v1.0's well-known URI is an *unauthenticated discovery surface* while the task lifecycle is an *authenticated state machine*. Nothing in the spec forces the two to be bound to the same identity, so a re-fetch can hand the initiator a card whose declared `skills`, `capabilities.streaming`, and `defaultInputModes` describe a runtime that is not the one executing the task. The initiator then negotiates against a phantom. ## What Was Observed A three-hop pipeline: an orchestrator (runtime A) delegated a `data.extract` task to a peer (runtime B) discovered at `https://peer.internal/.well-known/agent-card.json`. Initial card declared `capabilities.streaming: true`, `defaultInputModes: ["application/json"]`, and a single skill `extract.v2` with `inputModes` including `text/csv`. The task entered `working`. At T+40s the orchestrator, following a re-validation policy, re-fetched the well-known URI. Between the two fetches the peer had been autoscaled: the new replica served a card for `extract.v1` (rollback build) with `capabilities.streaming: false` and `defaultInputModes: ["text/plain"]`. The card was validly signed by the same `provider` key — the signature covered *the card*, not *the binding between card and task*. The orchestrator's next action was a `tasks/sendSubscribe` stream continuation. The new replica had no streaming handler. It did not error; it fell back to a synchronous `tasks/send` path, buffered the CSV payload, and coerced it to `text/plain` because that was the only declared input mode. Extraction ran against a v1 prompt template. The task returned `completed` with a plausible but structurally different artifact — columns renamed, one field dropped, no error, no `TaskState` transition that reflected the downgrade. The failure was invisible to every layer that was checking the *right* things: signatures verified, schema validated, task reached `completed`. The only thing that had changed was the *meaning* of the task, and nothing in the protocol recorded that the meaning had been renegotiated. ## Condition of Validity The invariant that was violated is not "the card must not change." Cards legitimately change. The invariant is: > **A task's negotiated capability set is frozen at acceptance and must be re-asserted, not re-discovered, for the lifetime of the task.** Concretely, the following must hold for any A2A v1.0 negotiation that survives a mid-task re-discovery: - The card fetched at acceptance time is bound to the task by a **negotiation digest**: a hash over `(card_id, card_version, skills[].id, capabilities, defaultInputModes, provider_key_id)` captured at `tasks/send` acceptance and echoed back in every subsequent `Task` object. - A re-fetch of the well-known URI is treated as **advisory only**. If the newly fetched digest differs from the frozen digest, the initiator must not silently adopt it; it must either continue under the frozen digest (and fail if the peer cannot honor it) or explicitly renegotiate via a new task. - The peer must **reject** any continuation whose frozen digest it cannot satisfy, with an explicit `TaskState: failed` and a machine-readable reason (e.g. `capability_digest_mismatch`), rather than degrading to a compatible-looking path. The condition under which the observed failure is *valid* (i.e., the guardrail holds) is exactly: the peer runtime that accepts a continuation can prove it holds the frozen digest. If it cannot — because it is a different replica, a rollback build, or a cold-started process that lost negotiation state — it must fail loudly. The failure mode is not "card drift." It is **digest-blind continuation**. ## Decision Boundary The decision boundary sits between *re-validation* and *re-negotiation*, and it is crossed the moment the initiator treats a fresh well-known fetch as authoritative for a task already in flight. | Signal | Action | |---|---| | Re-fetched card digest == frozen digest | Continue; re-validation is a no-op. | | Digest differs, peer echoes frozen digest in `Task` | Continue under frozen digest; log drift; do not adopt new card for this task. | | Digest differs, peer does *not* echo frozen digest | Halt. Do not send next message. Open explicit renegotiation or fail the task. | | Peer returns `completed` without echoing digest | Treat as unverified; the artifact is quarantined pending out-of-band confirmation. | | Peer returns `failed` with `capability_digest_mismatch` | Correct behavior; surface to orchestrator as a recoverable renegotiation trigger. | The subtle case is the fourth row: a peer that completes the task but cannot prove it ran under the frozen contract. In the observed incident this is precisely what happened, and it is the row most operators omit because "it completed" feels like success. The boundary rule is that **a completed task without a digest echo is not a completed task; it is an unverified artifact** and must not be promoted into downstream state. ## Operational Effect Enforcing the frozen-digest invariant changes three things in practice: 1. **Autoscaling becomes safe by construction.** A new replica either holds the digest (because negotiation state is in a shared, versioned store keyed by task ID) or refuses the continuation. Rollback builds stop silently downgrading in-flight work. 2. **Card signatures regain their proper scope.** A signature proves the card is authentic, not that it is *the card this task negotiated against*. Binding the digest to the task is what makes the signature meaningful for in-flight work; without it, signature verification is a check on the wrong object. 3. **Failure becomes legible.** `capability_digest_mismatch` is a first-class, recoverable signal. The orchestrator can renegotiate deliberately (new task, new card, new acceptance) instead of discovering three hops later that an artifact has the wrong schema. The cost is that peers must persist negotiation state across replicas, and initiators must carry a digest through every continuation. That is the price of not letting a well-known URI silently redefine a running contract. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class CapabilityDigestMismatch(RuntimeError): """Raised when a peer cannot prove it holds the frozen negotiation digest.""" class UnverifiedCompletion(RuntimeError): """Raised when a task completes without echoing the frozen digest.""" @dataclass(frozen=True) class NegotiationDigest: card_id: str card_version: str skill_ids: tuple[str, ...] streaming: bool input_modes: tuple[str, ...] provider_key_id: str def fingerprint(self) -> str: payload = json.dumps( { "card_id": self.card_id, "card_version": self.card_version, "skill_ids": list(self.skill_ids), "streaming": self.streaming, "input_modes": list(self.input_modes), "provider_key_id": self.provider_key_id, }, sort_keys=True, separators=(",", ":"), ).encode("utf-8") return hashlib.sha256(payload).hexdigest() @dataclass class Task: task_id: str frozen_digest: NegotiationDigest state: str = "submitted" echoed_digest: str | None = None artifact: Any = None def accept_task(task_id: str, card: dict[str, Any], provider_key_id: str) -> Task: digest = NegotiationDigest( card_id=card["name"], card_version=card["version"], skill_ids=tuple(sorted(s["id"] for s in card.get("skills", []))), streaming=bool(card.get("capabilities", {}).get("streaming", False)), input_modes=tuple(sorted(card.get("defaultInputModes", []))), provider_key_id=provider_key_id, ) return Task(task_id=task_id, frozen_digest=digest, state="working") def continue_task(task: Task, peer_echoed_digest: str | None) -> None: expected = task.frozen_digest.fingerprint() if peer_echoed_digest is None: raise CapabilityDigestMismatch( f"peer did not echo negotiation digest for task {task.task_id}; " f"expected {expected}. Refusing to continue: peer cannot prove it " f"holds the frozen capability contract." ) if peer_echoed_digest != expected: raise CapabilityDigestMismatch( f"task {task.task_id}: frozen digest {expected} but peer echoed " f"{peer_echoed_digest}. Capability substitution detected; open " f"explicit renegotiation, do not adopt re-discovered card." ) task.echoed_digest = peer_echoed_digest def finalize_task(task: Task, artifact: Any) -> Any: if task.echoed_digest != task.frozen_digest.fingerprint(): raise UnverifiedCompletion( f"task {task.task_id} completed without a verified digest echo; " f"artifact quarantined pending out-of-band confirmation." ) task.state = "completed" task.artifact = artifact return artifact # --- Trace of the observed incident --- initial_card = { "name": "extract-peer", "version": "2.0.0", "capabilities": {"streaming": True}, "defaultInputModes": ["application/json", "text/csv"], "skills": [{"id": "extract.v2"}], } # Autoscaled replica serves a rollback card; the well-known URI is advisory. rolled_back_card = { "name": "extract-peer", "version": "1.4.0", "capabilities": {"streaming": False}, "defaultInputModes": ["text/plain"], "skills": [{"id": "extract.v1"}], } task = accept_task("task-7f3a", initial_card, provider_key_id="peer-k1") # Re-validation fetches rolled_back_card. The correct move is to IGNORE it # for this task and demand the frozen digest on continuation. The buggy # runtime instead adopted it and continued without an echo. try: continue_task(task, peer_echoed_digest=None) except CapabilityDigestMismatch as exc: print(f"[halted] {exc}") # Correct recovery: renegotiate as a NEW task under the new card. renegotiated = accept_task("task-7f3a-r2", rolled_back_card, provider_key_id="peer-k1") print(f"[renegotiated] new digest {renegotiated.frozen_digest.fingerprint()}") ```