# In what scenarios must an instance treat A2A v1.0 Agent Card discovery as a non-idempotent, versioned handshake rather than a stateless capability lookup **Date of Record:** 2026 November 20 **Scope:** Applies to any A2A v1.0 client (orchestrator, peer agent, or router) that resolves a remote `AgentCard` via `/.well-known/agent.json` and then drives a `Task` lifecycle across vendor boundaries. Does not apply to single-vendor deployments where the card and task-state machine are co-deployed and versioned atomically, nor to pure MCP tool invocation where no task state machine exists. ## Core Distinction The A2A v1.0 specification describes Agent Card discovery as a lookup: fetch `/.well-known/agent.json`, parse `skills`, `capabilities`, `securitySchemes`, and `defaultInputModes`/`defaultOutputModes`, then dispatch. This framing is correct only for a *single* task attempt. The non-obvious boundary is that the Agent Card is also the **implicit schema of the task state machine** — the set of legal `TaskState` transitions, the `artifact` schema per skill, and the push-notification contract. Two vendors can each publish a conformant card and still disagree on the transition graph (`submitted → working → input-required → working → completed` vs. `submitted → working → completed` with `input-required` disallowed mid-stream). Discovery is therefore a *versioned handshake* whose result must be pinned to the task instance, not a stateless capability probe whose result can be cached and reused across tasks. The failure mode: an orchestrator caches the card at task start, the remote agent redeploys mid-task with a mutated card (new `skills[].id`, changed `capabilities.pushNotifications`, tightened `securitySchemes`), and the orchestrator's subsequent `tasks/send` or `tasks/get` calls are validated against a card that no longer describes the live endpoint. The state machine the orchestrator *believes* it is driving diverges from the one the remote is *actually* executing. ## What Was Observed A cross-vendor orchestration run (client vendor A, remote vendor B) executing a 40-minute research task with three `input-required` round-trips. Trace: 1. `t=0` — Client A fetches `https://b.example/.well-known/agent.json`. Card v1 carries `capabilities: {streaming: true, pushNotifications: false, stateTransitionHistory: true}` and skill `research-v2` with `outputModes: ["text/plain", "application/json"]`. Client A pins this card to the task context and opens a streaming `tasks/send`. 2. `t=11m` — Remote B redeploys. Card v2 changes `stateTransitionHistory` to `false` (feature-flagged off during migration) and renames skill `research-v2 → research-v3`. The task itself is *not* migrated; in-flight tasks continue on the old worker pool. 3. `t=18m` — Client A, honoring its pinned card's `stateTransitionHistory: true`, calls `tasks/get` expecting a `history[]` array to reconstruct the transition log. Remote B (now serving v2) returns a `Task` with no `history` field. Client A's parser treats the missing field as `null` and its replay logic raises a schema error — but only *after* it has already consumed the `status.state = "input-required"` and dispatched a human-in-the-loop prompt. 4. `t=19m` — The human answers, Client A sends `tasks/send` with `taskId` and the answer. Remote B's v2 worker pool does not recognize the `taskId` (old pool still holds it) and returns `-32001 TaskNotFound`. Client A, per its pinned card, retries once with exponential backoff — but the retry lands on the *new* pool, which creates a *fresh* task with the same `taskId` supplied by the client (v1 allowed client-supplied IDs; v2 ignores them). Two tasks now share an ID across pools. 5. `t=22m` — Client A's `tasks/get` on the shared ID returns the v2 task (state `submitted`), overwriting its local view of the v1 task (state `input-required`). The human's answer is now attached to a task that will never consume it. The original v1 task times out at `t=40m` in `failed` with reason `input-timeout`. The root cause is not the redeploy. It is that **card fields were treated as invariants of the task lifecycle when they are only invariants of a single discovery epoch**. `stateTransitionHistory`, `pushNotifications`, and skill `id` are *contract terms* that the remote may unilaterally revise; the task state machine must be re-negotiated or the task must be declared orphaned. ## Condition of Validity The invariant — "a pinned Agent Card accurately describes the state machine governing an in-flight task" — holds only under the conjunction: - The remote guarantees card/task co-versioning (i.e., a card change invalidates in-flight tasks, or in-flight tasks are explicitly grandfathered and their card is served at a versioned path such as `/.well-known/agent.json?v=1`). - The client re-fetches the card on every `input-required` resume and diffs it against the pinned card, treating any diff in `skills[].id`, `capabilities.*`, or `securitySchemes` as a *task-invalidating* event. - The task state machine's legal transitions are derived from the card's `capabilities` and the skill's declared `outputModes`, and the client refuses to send a transition (e.g., a push-notification registration) that the *current* card does not advertise. Absent any one of these, the pinned card is a stale schema and the client is driving a state machine it cannot see. ## Decision Boundary The boundary is whether the client can distinguish **"the remote is temporarily unreachable"** (retry, card still valid) from **"the remote is reachable but its contract has changed"** (do not retry; re-discover and re-validate the task). A2A v1.0's error taxonomy does not cleanly separate these: `-32001 TaskNotFound` is returned both for a genuinely unknown task and for a task held by a pool the current card no longer describes. The client must therefore treat `TaskNotFound` on a task it believes is live as a *card-drift signal*, not a retryable error, and must re-fetch the card before deciding. Concretely: on any `tasks/get` or `tasks/send` error, the client re-fetches `/.well-known/agent.json`, computes a structural diff against the pinned card, and: - If the diff is empty → retry (transient). - If the diff touches `capabilities`, `skills[].id`, or `securitySchemes` → declare the task `orphaned`, emit a `TaskContractDrift` fault, and surface the human answer as unattached rather than re-sending it to a possibly-different task. - If the diff touches only `description`/`name` → retry with the new card pinned. ## Operational Effect The observable effect of getting this wrong is *silent task duplication with shared IDs* and *human input attached to the wrong task* — both of which are invisible to per-task metrics because each task individually reports a plausible terminal state (`failed` for the orphan, `submitted` for the phantom). Fleet-level dashboards show a healthy task-completion rate while a fraction of human-in-the-loop answers are being dropped. The guardrail is to make card identity a first-class field of the task record (a `card_hash` alongside `taskId`), to re-validate on every resume, and to treat contract drift as a terminal, non-retryable fault that escalates rather than a transient to be retried. ```python import hashlib import json from dataclasses import dataclass, field class TaskContractDrift(RuntimeError): """Raised when the live Agent Card no longer describes the pinned task contract.""" @dataclass class AgentCard: skills: list capabilities: dict security_schemes: dict def contract_hash(self) -> str: # Only the fields that govern the task state machine are hashed. payload = { "skills": sorted(s.get("id") for s in self.skills), "capabilities": { k: self.capabilities.get(k) for k in ("streaming", "pushNotifications", "stateTransitionHistory") }, "securitySchemes": sorted(self.security_schemes.keys()), } return hashlib.sha256( json.dumps(payload, sort_keys=True).encode() ).hexdigest() @dataclass class PinnedTask: task_id: str card: AgentCard card_hash: str = field(init=False) def __post_init__(self): self.card_hash = self.card.contract_hash() def validate_resume(pinned: PinnedTask, live_card: AgentCard) -> None: """Called on every input-required resume and on any TaskNotFound. Raises if the live card's contract hash diverges from the pinned one; the caller must NOT retry or re-send human input in that case. """ live_hash = live_card.contract_hash() if live_hash != pinned.card_hash: raise TaskContractDrift( f"task {pinned.task_id}: pinned card {pinned.card_hash[:12]} " f"!= live card {live_hash[:12]}; task is orphaned, " f"do not resend human input" ) def handle_task_error(pinned: PinnedTask, live_card: AgentCard, error_code: int) -> str: if error_code == -32001: # TaskNotFound # Ambiguous: transient OR contract drift. Re-validate before deciding. validate_resume(pinned, live_card) return "retry" return "retry" ```