# What happens when an instance negotiates against a stale Agent Card: capability drift at the A2A v1.0 discovery boundary and the task-state conformance failures it induces **Date of Record:** 2026 November 30 **Scope:** Applies to A2A v1.0 (Agent2Agent) peer discovery where a client agent resolves a remote Agent Card, derives a capability/transport contract from it, and drives a task through the remote lifecycle state machine. Does not cover intra-process tool calls, MCP server negotiation, or single-turn stateless RPC where no task lifecycle is established. ## Core Distinction The failure that matters is not "the remote agent is down." It is that the Agent Card a client resolved is a *point-in-time snapshot of a capability contract*, while the task lifecycle state machine it is about to drive is *live and mutable*. A2A v1.0 discovery treats the card as authoritative for the duration of a task, but nothing in the protocol binds the card's declared `capabilities`, `skills`, `defaultInputModes`/`defaultOutputModes`, or `pushNotifications` flag to the server's actual runtime behavior at task-execution time. The card is a promise; the state machine is the fulfillment. When the two drift — because the card was cached, because the peer was redeployed between resolution and task `send`, or because a load balancer routed the task to a replica running a different build than the one that served the card — the client negotiates against a contract the executing replica no longer honors. The non-obvious part: A2A's state machine (`submitted → working → input-required → completed | failed | canceled`) has **no negotiation-rejection state**. There is no `capability-mismatch` terminal. A client that sends a task requiring a skill the executing replica lacks does not get a clean refusal at handshake; it gets a task that enters `working`, then either hangs until timeout or transitions to `failed` with an opaque `status.message` that the client's error-compounding loop misinterprets as a transient fault and retries against the same stale contract. ## What Was Observed A client agent resolved a peer's Agent Card once at session start and cached it with a 24h TTL keyed on the peer's `url`. The card declared: - `capabilities.streaming: true` - `capabilities.pushNotifications: true` - `skills: [{id: "invoice-reconcile", inputModes: ["application/json"], outputModes: ["application/json"]}]` - `defaultInputModes: ["application/json"]` The peer was redeployed at T+3h. The new build dropped `invoice-reconcile` (split into `invoice-reconcile-v2` requiring an additional `currency` field) and disabled `pushNotifications` behind a feature flag. The `url` and the card's `version` string were unchanged — the deploy pipeline did not bump `version`, treating it as a marketing field rather than a contract field. At T+5h the client, still holding the cached card, called `message/send` with a task whose `metadata.skillId` was `invoice-reconcile` and whose payload omitted `currency`. Observed trace: 1. `tasks/send` accepted — the executing replica validated only the envelope against the A2A schema, not the skill against its live registry. Task created in state `submitted`. 2. Replica transitioned to `working`, emitted one `TaskStatusUpdateEvent`. 3. The skill resolver inside the replica failed to find `invoice-reconcile`, caught the lookup error, and — because the state machine has no `rejected` state — mapped it to `failed` with `status.message: "internal error"` (the resolver's generic catch-all). 4. Client's retry policy classified `failed` with `internal error` as retryable-transient. It retried the identical payload three times against the same replica pool, each landing on a replica that also lacked the skill. Three `failed` tasks, no state advance, no signal that the contract was invalid rather than the execution being flaky. 5. The client's own reasoning loop, seeing three failures, escalated to a fallback skill `invoice-reconcile-legacy` that it *inferred* from the skill-id prefix — a hallucinated capability not present in any card. That task entered `working` and then `input-required`, blocking on a `currency` field the client never knew to supply because the cached card's `inputModes` schema did not include it. The deadlock: client waiting on `completed`, replica waiting on `input-required` resolution, neither side aware the other holds a contract the first never agreed to. The task sat in `input-required` until the client's global task timeout (45 min) fired. ## Condition of Validity The guardrail holds only under a specific conjunction, and it is worth stating precisely because most implementations satisfy only part of it: 1. **Card identity is content-addressed, not URL-addressed.** The client must key its card cache on a hash of the card's *capability-bearing fields* (`skills[].id`, `skills[].inputModes`, `capabilities.*`, `defaultInputModes`), not on `url` or the human `version` string. A card whose capability hash changes is a different peer for negotiation purposes. 2. **The task envelope carries the contract hash the client negotiated against.** A2A v1.0 permits arbitrary `metadata` on `Message`/`Task`; the client stamps `metadata.agentCardHash`. The executing replica, before transitioning `submitted → working`, recomputes its own card hash and compares. Mismatch must produce a *terminal* state — and since A2A has no `rejected`, the conformant encoding is `failed` with a structured `status.message` whose `metadata.reason = "capability-contract-mismatch"` and which the client's retry classifier is configured to treat as **non-retryable**. 3. **`input-required` is only legal for fields declared in the *negotiated* card's input schema.** A replica that transitions to `input-required` for a field absent from the card hash the client holds is violating the state machine's implicit precondition. The client must treat an `input-required` for an undeclared field as a contract violation, not as a prompt to guess. Absent all three, the system is in the drift regime and the failure above is not an edge case but the default behavior under any redeploy. ## Decision Boundary The boundary is drawn at the moment of `submitted → working`. Before that transition, the replica has the option to reject cheaply (recompute hash, compare, fail fast). After it, the replica has committed to a lifecycle and the client has begun compounding — retries, fallback inference, escalation. The architectural invariant: > **A task may not leave `submitted` unless the executing replica's live capability hash equals the hash the client stamped on the envelope.** This is enforceable in one place — the state-machine transition guard — and it is the *only* place, because it is the last point where the replica still knows which contract the client believes it is operating under. Once in `working`, the replica is reasoning about the task, not about the contract, and the client is reasoning about progress, not about the card. Two corollaries that bound the decision: - **Push-notification capability is part of the hash.** A card that advertises `pushNotifications: true` and a replica that has it flag-disabled will accept `tasks/pushNotificationConfig/set` and silently no-op. The client then waits on a webhook that never fires while the task completes server-side — a lost-completion, not a lost-task, which is worse because the client's timeout fires on a task that actually succeeded. - **Skill-id is not a capability.** `invoice-reconcile` and `invoice-reconcile-v2` are distinct hashes. Prefix-matching or fuzzy-matching skill ids across a hash mismatch is the hallucination vector observed in step 5; it must be forbidden at the client's routing layer, not merely discouraged. ## Operational Effect With the transition guard in place, the observed failure collapses from a 45-minute deadlock into a sub-second terminal rejection: the client's first `message/send` after the T+3h redeploy returns `failed` with `reason: capability-contract-mismatch`, the client's cache invalidates on that reason, it re-resolves the card, sees `invoice-reconcile-v2` with the required `currency` field, and re-issues a conformant task. The retry loop never engages, the fallback inference never fires, and the `input-required` deadlock is unreachable because the client never sends a task under a contract the replica cannot honor. The residual cost is one wasted round-trip per redeploy per client — bounded, observable, and attributable. The unbounded cost it replaces is the compounding loop: retries against a stale contract, hallucinated fallbacks, and tasks parked in `input-required` until timeout, each of which consumes the client's token budget and pollutes its episodic memory with failures that look like transient faults and are therefore *learned as transient* — a memory-drift second-order effect that outlives the redeploy that caused it. ```python import hashlib import json from dataclasses import dataclass, field from enum import Enum from typing import Any class CapabilityContractMismatch(RuntimeError): """Raised when a task envelope's negotiated card hash does not match the executing replica's live capability hash at the submitted->working transition. Non-retryable by contract.""" class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" # Fields that constitute the capability contract. Everything else on the # Agent Card (name, description, url, human `version`) is advisory and MUST # NOT participate in the hash. CONTRACT_FIELDS = ( "capabilities", "skills", "defaultInputModes", "defaultOutputModes", ) def capability_hash(card: dict[str, Any]) -> str: projection = {k: card.get(k) for k in CONTRACT_FIELDS} canonical = json.dumps(projection, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() @dataclass class Task: task_id: str state: TaskState = TaskState.SUBMITTED envelope_metadata: dict[str, Any] = field(default_factory=dict) status_message: dict[str, Any] = field(default_factory=dict) class Replica: def __init__(self, live_card: dict[str, Any]) -> None: self.live_card = live_card self.live_hash = capability_hash(live_card) def declared_input_fields(self, skill_id: str) -> set[str]: for skill in self.live_card.get("skills", []): if skill.get("id") == skill_id: return set(skill.get("inputSchema", {}).get("required", [])) return set() def transition_to_working(self, task: Task) -> Task: # The single guard. Enforced at the only point where the replica # still knows which contract the client negotiated against. client_hash = task.envelope_metadata.get("agentCardHash") if client_hash != self.live_hash: task.state = TaskState.FAILED task.status_message = { "reason": "capability-contract-mismatch", "retryable": False, "clientHash": client_hash, "liveHash": self.live_hash, } raise CapabilityContractMismatch( f"task {task.task_id}: client negotiated {client_hash!r}, " f"replica serves {self.live_hash!r}" ) task.state = TaskState.WORKING return task def request_input(self, task: Task, skill_id: str, field_name: str) -> Task: # input-required is only legal for fields declared in the *negotiated* # card's input schema. Undeclared fields are a contract violation. if field_name not in self.declared_input_fields(skill_id): task.state = TaskState.FAILED task.status_message = { "reason": "undeclared-input-required", "retryable": False, "field": field_name, } raise CapabilityContractMismatch( f"task {task.task_id}: input-required for undeclared field " f"{field_name!r} on skill {skill_id!r}" ) task.state = TaskState.INPUT_REQUIRED return task # --- demonstration of the drift regime --- if __name__ == "__main__": old_card = { "capabilities": {"streaming": True, "pushNotifications": True}, "skills": [{"id": "invoice-reconcile", "inputSchema": {"required": []}}], "defaultInputModes": ["application/json"], "defaultOutputModes": ["application/json"], } new_card = { "capabilities": {"streaming": True, "pushNotifications": False}, "skills": [ { "id": "invoice-reconcile-v2", "inputSchema": {"required": ["currency"]}, } ], "defaultInputModes": ["application/json"], "defaultOutputModes": ["application/json"], } stale_client_hash = capability_hash(old_card) replica = Replica(new_card) task = Task( task_id="t-001", envelope_metadata={"agentCardHash": stale_client_hash, "skillId": "invoice-reconcile"}, ) try: replica.transition_to_working(task) except CapabilityContractMismatch as exc: # Client classifier: reason == capability-contract-mismatch -> invalidate # cache, re-resolve, do NOT retry identical payload. assert task.state is TaskState.FAILED assert task.status_message["retryable"] is False print(f"rejected fast: {exc}") ```