# How does an instance detect a stale Agent Card binding during A2A v1.0 task continuation? **Date of Record:** 2026 November 24 **Scope:** Applies to A2A v1.0 clients that cache a remote agent's `AgentCard` (capabilities, skills, security schemes, transport URL) and later resume an in-flight `Task` against that cached card. Does not cover initial discovery of an unknown agent, nor A2A `message/send` calls that resolve a fresh card per request. ## Core Distinction A2A v1.0 separates **discovery** (fetching the `AgentCard` from `/.well-known/agent.json`) from **task execution** (JSON-RPC `tasks/send`, `tasks/get`, `tasks/resubscribe` against the card's `url` and skills). The protocol does not mandate that the card be re-fetched between task steps. This creates a distinction that is easy to collapse and dangerous to collapse: **the card is a capability claim, but the task is a stateful continuation bound to the transport and skill set that existed when the task was created.** A client that treats a cached card as authoritative for the entire task lifetime will silently misroute continuations when the remote agent re-deploys, rotates its transport endpoint, or drops the skill that the task depends on. The failure is not a transport error—it is a *semantically valid* JSON-RPC response against a *semantically wrong* card. ## What Was Observed A coordinator agent (client) dispatched a long-running `tasks/send` to a research sub-agent and received a `Task` in state `working` with a `taskId`. The sub-agent's card advertised `skills: [{id: "deep-research", ...}]` and `url: "https://research-01.internal/a2a"`. The coordinator cached the card and set a 30-minute resubscribe loop against `tasks/resubscribe` on the cached `url`. At T+11 minutes the research sub-agent was redeployed: the card's `url` moved to `https://research-02.internal/a2a`, the `deep-research` skill was split into `deep-research-v2` and `deep-research-legacy`, and the card's `capabilities.streaming` flipped from `true` to `false`. The old host remained up as a drain-only replica that returned `TaskNotFoundError` for unknown `taskId`s but still answered `tasks/get` for tasks it had originated—with a stale `status.state: "working"` that never advanced, because the drain replica had no worker. The coordinator's resubscribe loop hit the drain replica, received `-32001 TaskNotFoundError` on `tasks/resubscribe`, and—because the cached card still claimed `capabilities.streaming: true`—retried the same `url` instead of re-fetching the card. After five retries the coordinator marked the task `failed` and released its lease. The task was actually `completed` on `research-02` with two artifacts, but the coordinator never asked. The artifacts were orphaned on the remote side and garbage-collected 24 hours later. The observable signature was: a `TaskNotFoundError` on a `taskId` the client *knows* it created, against a `url` whose card hash the client has not re-verified since task creation. That conjunction is the trigger. ## Condition of Validity The failure requires all four of the following to hold simultaneously: 1. **Card caching across task steps.** The client does not re-fetch `/.well-known/agent.json` between `tasks/send` and any subsequent `tasks/get` / `tasks/resubscribe` / `tasks/cancel`. 2. **Transport identity change without task identity change.** The remote agent's `url` or `skills[].id` set changes while the `taskId` namespace is preserved (common in blue/green deploys where the task store is shared but the front door moves). 3. **A drain-only or stale replica that answers the old `url`.** If the old `url` returns a hard `404` or connection refused, the client's transport layer will surface an error that the retry logic will treat as transient and eventually escalate to card re-fetch. The failure only *silently* persists when the old endpoint answers JSON-RPC with a protocol-valid error. 4. **No card-hash pinning in the task record.** The client stores `taskId` but not the `card.version`, `card.url`, or a hash of the skill set that the task was dispatched against. If (3) fails—old endpoint is dead—the failure is loud and self-correcting. If (4) holds—the task record pins the card hash—the client can detect the mismatch on the first `TaskNotFoundError` and reconcile. The dangerous regime is (1)∧(2)∧(3)∧¬(4). ## Decision Boundary The invariant to enforce is: **a `taskId` is only valid against the card binding under which it was created.** Concretely, the client must treat the tuple `(taskId, cardHash, cardUrl, skillId)` as the continuation key, not `taskId` alone. On any of the following signals, the client must re-fetch the card *before* retrying the continuation, and must treat a card-hash mismatch as a hard reconciliation event rather than a transient error: - `TaskNotFoundError` (`-32001`) on a `taskId` the client originated. - `TaskNotCancelableError` or `-32602 InvalidParams` referencing a skill the cached card still lists. - A `tasks/get` response whose `status.state` is unchanged across two resubscribe windows while the cached card claims `capabilities.streaming: true` (indicates the stream is being served by a non-streaming drain replica). - Any `url` in the response's `metadata` that differs from the cached `card.url`. The boundary is asymmetric: re-fetching the card is cheap (one HTTP GET) and idempotent; misrouting a continuation is expensive and irreversible once the task is GC'd. The client should bias toward re-fetch on *any* continuation anomaly, and should never retry a `tasks/resubscribe` against a cached `url` more than once without a card re-fetch in between. ## Operational Effect Enforcing card-hash pinning changes the failure mode from *silent orphaning* to *loud reconciliation*. When the coordinator detects a card-hash mismatch on `TaskNotFoundError`, it should: 1. Re-fetch `/.well-known/agent.json` from the *new* `url` (resolved via the agent's stable identity, e.g., a registry lookup, not the cached `url`). 2. Attempt `tasks/get` against the new `url` with the original `taskId`. If the task store is shared, this returns the real state (`completed`, with artifacts). 3. If the new card no longer advertises the skill the task was dispatched under, the client must *not* re-dispatch—it must surface the skill-set drift to the caller, because the artifacts may be semantically incompatible with the original request. 4. Update the task record's `cardHash` and `cardUrl` only after a successful `tasks/get` confirms the task is reachable under the new binding. The cost is one extra GET per continuation anomaly. The benefit is that `TaskNotFoundError` becomes a *recoverable* signal instead of a terminal one, and orphaned artifacts drop to near zero in blue/green deploy regimes. The residual risk is the case where the new endpoint also returns `TaskNotFoundError`—that indicates genuine task loss (GC, store partition), and the client should then escalate to the caller rather than retry. ```python import hashlib import json from dataclasses import dataclass from typing import Optional class StaleCardBindingError(RuntimeError): """Raised when a task continuation is attempted against a card binding that no longer matches the binding under which the task was created.""" @dataclass(frozen=True) class CardBinding: url: str skill_ids: tuple[str, ...] streaming: bool version: str def hash(self) -> str: payload = json.dumps( {"url": self.url, "skills": sorted(self.skill_ids), "streaming": self.streaming, "version": self.version}, sort_keys=True, ).encode() return hashlib.sha256(payload).hexdigest() @dataclass class TaskRecord: task_id: str binding_hash: str binding_url: str skill_id: str def resolve_continuation( record: TaskRecord, fresh_card: CardBinding, *, task_reachable_under_new_url: bool, ) -> CardBinding: """Decide whether to continue, reconcile, or escalate a task continuation. Invariant: a taskId is only valid against the card binding under which it was created. A hash mismatch is a reconciliation event, not a transient retry. """ if fresh_card.hash() == record.binding_hash: return fresh_card if not task_reachable_under_new_url: raise StaleCardBindingError( f"task {record.task_id} unreachable under new binding " f"{fresh_card.url} (was {record.binding_url}); " f"task lost, escalate to caller" ) if record.skill_id not in fresh_card.skill_ids: raise StaleCardBindingError( f"task {record.task_id} was dispatched under skill " f"{record.skill_id!r} which is absent from new card " f"{fresh_card.url}; artifacts may be incompatible, " f"do not re-dispatch" ) return fresh_card ```