# Which invariants prevent Agent Card capability drift from silently renegotiating an in-flight A2A task into an incompatible terminal state **Date of Record:** 2026 November 26 **Scope:** Applies to A2A v1.0 task lifecycles where a client agent discovers a remote agent via `/.well-known/agent.json` (Agent Card), negotiates a task, and the remote agent's card or capability surface changes between negotiation and completion. Does not cover A2A transport-level TLS/identity failures or MCP tool-schema negotiation, which have separate invariants. ## Core Distinction The Agent Card is a *discovery-time snapshot*, not a *negotiation-time contract*. A2A v1.0 treats the card as the source of truth for `skills`, `capabilities` (e.g., `streaming`, `pushNotifications`, `stateTransitionHistory`), and `defaultInputModes`/`defaultOutputModes`. But the card is re-fetched by clients on cache expiry, and remote agents are frequently redeployed behind the same well-known URL. The failure mode is not "the card is wrong" — it is that a *re-read of a valid card* mid-task can legally describe a capability set that the already-negotiated task no longer satisfies, and the protocol has no mandatory mechanism to bind a task to the card version it was negotiated under. The distinction that matters: **capability set membership at negotiation time is a different invariant from capability set membership at each subsequent turn**, and only the first is checked by conformant clients. ## What Was Observed A client agent (`planner`) discovered `summarizer` via `GET /.well-known/agent.json`, which advertised `capabilities.streaming: true`, `skills: [{"id": "summarize-v2", "inputModes": ["text/plain"], "outputModes": ["text/markdown"]}]`, and `stateTransitionHistory: true`. The planner sent `tasks/sendSubscribe` (streaming required) and received a task in state `working` with a `contextId`. Mid-stream, the operator redeployed `summarizer` with `streaming: false` (SSE endpoint removed, replaced by polling via `tasks/get`) and `skills: [{"id": "summarize-v3", ...}]`. The old task record survived the deploy (state persisted), so `tasks/get` still returned `working` — but the streaming channel the client held open was closed by the new process with a transport-level EOF, not an A2A error event. The client's retry logic re-fetched the Agent Card (cache TTL 60s), saw `streaming: false`, and — because it treated the card as authoritative — *downgraded its own expectation* to polling. It then issued `tasks/get` and received `working`. The task never advanced: the new deployment's worker pool had no handler registered for `summarize-v2` (the skill ID the task was negotiated against), so the task sat in `working` until the server's 30-minute task TTL reaped it into `failed` with `error: "unknown skill"`. The client had, at every step, behaved per spec. The invariant that broke was implicit: *a task's skill ID must remain resolvable for the task's lifetime*, and nothing in A2A v1.0 enforces it. ## Condition of Validity This failure requires the conjunction of four conditions, and it does *not* occur if any one is absent: 1. The remote agent is reachable at a stable well-known URL across a redeploy (the common case for managed agents). 2. Task state is persisted across the redeploy, so `tasks/get` returns a non-terminal state for a task whose handler no longer exists. If state is *not* persisted, the task is reaped to `failed` immediately and the client fails fast — a strictly better outcome. 3. The client re-fetches the card mid-task and treats the re-fetched card as authoritative for the *existing* task rather than only for *new* tasks. A client that pins the negotiation-time card (or the negotiated `skill.id` + `capabilities` subset) to the task's `metadata` is immune. 4. The redeploy changes a capability the in-flight task depends on (`streaming`) or removes the skill ID the task was bound to. The invariant that would bound this — and that A2A v1.0 leaves optional — is: **a task is bound to the (card version, skill ID, capability subset) tuple captured at `tasks/send`, and any divergence between that tuple and the current card must terminate the task with an explicit `failed` + structured error, not silently continue.** Absent this binding, the client's correct-per-spec behavior (re-read card, adapt) is exactly what produces the silent hang. ## Decision Boundary The operational decision is where to place the authority for "what this task may do": - **Card-authoritative (naive):** re-read card each turn, adapt. Fails as above — a legal card change mid-task renegotiates the contract without the client's consent and without a terminal signal. - **Task-authoritative (correct):** capture `{card_etag_or_hash, skill_id, required_capabilities}` at `tasks/send`, store in task `metadata`, and on every `tasks/get`/stream event compare against the *current* card. On mismatch, the client must treat the task as poisoned and either (a) cancel via `tasks/cancel` and re-negotiate a fresh task, or (b) accept a server-emitted `failed` with `error.code: "capability_drift"`. The boundary: **the client may only adapt its behavior to a new card for tasks it has not yet sent; for in-flight tasks, a card change is a terminal condition, not an adaptation trigger.** The server-side boundary is symmetric: a redeploy that cannot preserve a skill ID must, on startup, scan non-terminal tasks, and for each whose `skill_id` is now unresolvable, transition to `failed` with a structured error *before* accepting new work. A server that leaves orphaned `working` tasks is the proximate cause; the client's card re-read is the distal trigger. ## Operational Effect Without the binding invariant, the observable effect is a **silent liveness violation**: the task is non-terminal (`working`) but has no live handler, so it consumes a slot in the client's concurrency budget and the server's task table for the full TTL (here, 30 minutes) before being reaped. In a planner with N concurrent task slots, a single redeploy can wedge all N slots on orphaned tasks, and because the client correctly believes `working` means "progressing," its timeout logic does not fire. The failure is invisible to health checks (the agent is up, the card is valid, `tasks/get` returns 200) and only surfaces as a throughput collapse. The guardrail is a two-sided invariant: client pins the negotiation tuple to task metadata and treats card divergence as terminal; server, on deploy, reconciles non-terminal tasks against the new skill registry and fails orphans eagerly with a structured `capability_drift` error rather than letting TTL do it silently. ```python import hashlib import json from dataclasses import dataclass, field from typing import Optional class CapabilityDriftError(RuntimeError): """Raised when an in-flight A2A task's pinned negotiation tuple no longer matches the currently advertised Agent Card. This is terminal for the task; the client must cancel and re-negotiate rather than adapt silently.""" @dataclass class NegotiationTuple: card_hash: str skill_id: str required_capabilities: frozenset @classmethod def capture(cls, card: dict, skill_id: str, required: frozenset) -> "NegotiationTuple": canon = json.dumps(card, sort_keys=True, separators=(",", ":")).encode() return cls( card_hash=hashlib.sha256(canon).hexdigest(), skill_id=skill_id, required_capabilities=required, ) @dataclass class InFlightTask: task_id: str context_id: str pinned: NegotiationTuple state: str = "working" def verify_task_against_current_card( task: InFlightTask, current_card: dict, current_skill_ids: set, ) -> None: """Called on every tasks/get and every stream event. Enforces the invariant: an in-flight task is bound to its negotiation-time tuple; any divergence in skill resolvability or required capabilities is terminal.""" if task.state in ("completed", "failed", "canceled"): return if task.pinned.skill_id not in current_skill_ids: raise CapabilityDriftError( f"task {task.task_id} bound to skill {task.pinned.skill_id!r} " f"which is no longer advertised; current skills={sorted(current_skill_ids)}" ) advertised = frozenset( k for k, v in current_card.get("capabilities", {}).items() if v is True ) missing = task.pinned.required_capabilities - advertised if missing: raise CapabilityDriftError( f"task {task.task_id} requires capabilities {sorted(missing)} " f"no longer advertised by current card" ) current_hash = hashlib.sha256( json.dumps(current_card, sort_keys=True, separators=(",", ":")).encode() ).hexdigest() if current_hash != task.pinned.card_hash: # Card changed but required surface is intact: log, do not fail. # The invariant only fails the task on *capability* divergence, not # on cosmetic card edits (description, provider, etc.). pass def reconcile_on_deploy( non_terminal_tasks: list[InFlightTask], new_skill_registry: set, ) -> list[tuple[str, str]]: """Server-side guardrail: on startup after redeploy, eagerly fail any non-terminal task whose pinned skill is unresolvable, rather than letting the task TTL reap it silently.""" orphans = [] for task in non_terminal_tasks: if task.pinned.skill_id not in new_skill_registry: task.state = "failed" orphans.append((task.task_id, "capability_drift")) return orphans ```