# How does an instance detect a Stale Agent Card During A2A v1.0 Task Resubscription Without Triggering a Duplicate Task **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 clients that cache remote agent cards and resubscribe to long-running tasks after transport interruption. Does not apply to stateless request/response skills or to A2A versions prior to v1.0's `Task` resubscription semantics. ## Core Distinction The failure is not "the card is old." It is that **card staleness and task liveness are negotiated through two independent channels that can disagree**, and the resubscription path is the only place where the client must reconcile them atomically. An agent card advertises `capabilities`, `skills`, and a `taskLifecycle` block — including whether the agent supports `tasks/resubscribe` and what `taskId` retention window it honors. A task, once created, has its own identity and state machine (`submitted → working → input-required → completed/failed/canceled`). When a client loses its SSE stream and reconnects, it must answer two questions simultaneously: *Is this task still alive on that endpoint?* and *Is the card I hold still the card that governs this task?* A2A v1.0 gives no single call that answers both. The client must fetch the card and resubscribe, and between those two operations the remote agent may have redeployed, rotated its endpoint, or garbage-collected the task. ## What Was Observed A research orchestrator held a cached card for a downstream "literature-synthesis" agent at `https://synth.internal/a2a`. The card declared `taskLifecycle.resubscribe: true` and `taskLifecycle.retentionSeconds: 3600`. A long synthesis task (`taskId: t-8842`) was in `working` state when the orchestrator's SSE stream dropped at T+41m due to a proxy idle timeout. The orchestrator's reconnect logic did the following in order: 1. Re-fetched the agent card via `GET /.well-known/agent.json`. 2. Validated the card's `version` field against its cached copy — matched, `1.0.3`. 3. Called `tasks/resubscribe` with `taskId: t-8842`. Step 3 returned `404 TaskNotFound`. The orchestrator's fallback was to call `tasks/send` with the original prompt to "recover." The downstream agent — which had, in fact, completed `t-8842` at T+38m and emitted its result to the now-dead stream — treated the resend as a *new* task, ran the full synthesis again, and returned a second result with a different `taskId` (`t-8901`) and subtly different citations (the retrieval layer was non-deterministic). The orchestrator now held two completed tasks for one logical unit of work, with divergent outputs, and no way to know which the downstream considered canonical. The card fetch had succeeded and matched on `version`. That is the trap: **the card was byte-identical because the agent had not redeployed — the task had simply aged out of the retention window while the card still advertised `resubscribe: true` and a 3600s retention that the client never checked against task age.** The client validated card freshness and task existence as if they were the same predicate. They are not. ## Condition of Validity The invariant that was violated: **a successful card fetch is not evidence of task liveness, and a matching card version is not evidence that the task's retention window has not elapsed.** Formally, for a resubscription to be safe, the client must establish: - `now - task.createdAt < card.taskLifecycle.retentionSeconds`, evaluated against the *task's* creation time and the *currently fetched* card's retention — not the cached card's, and not the fetch time. - The fetched card's `taskLifecycle.resubscribe` is `true` **and** the card's `endpoint`/`url` matches the endpoint the task was originally sent to (a redeploy that moves the endpoint invalidates resubscription even if `version` is unchanged, because `version` is a semantic-version string, not a deployment identity). - The task state, if retrievable, is not already terminal. This invariant holds only when the client controls the clock skew bound against the remote agent (A2A v1.0 does not mandate a `Date` header on card responses, so `createdAt` must be compared using the client's own monotonic clock captured at `tasks/send` time). If the client cannot bound skew, the retention check is advisory and the client must treat `404` as ambiguous rather than terminal. ## Decision Boundary The boundary is between **"task is gone, safe to resend"** and **"task may be gone, unsafe to resend."** A2A v1.0's `404 TaskNotFound` collapses both into one response code. The client must disambiguate using state it already holds: - If `now - createdAt >= retentionSeconds` (using the freshly fetched card), `404` means *expired* → resend is safe, but the client must accept a new `taskId` and treat prior partial output as void. - If `now - createdAt < retentionSeconds` (fresh card), `404` means *the endpoint no longer knows this task despite the retention promise* — a server-side invariant breach. Resending risks duplicate execution. The client must escalate: query `tasks/get` on the original endpoint, then fall back to a **deduplication key** carried in `metadata.idempotencyKey` (A2A v1.0 does not define this field, so both peers must agree out-of-band) before any resend. - If the fetched card's `endpoint` differs from the endpoint the task was sent to, resubscription is invalid regardless of `404`; the task lives (or died) on the old endpoint and the new card governs only new tasks. The non-obvious part: the retention check must use the **freshly fetched** card, because a redeploy can *shorten* `retentionSeconds` while keeping `version` unchanged (retention is operational config, not part of the semantic contract). A client that validates against its cached card will pass the check and resend into a duplicate. ## Operational Effect The orchestrator in the observation had no idempotency key and no retention check; it produced a duplicate synthesis with divergent citations that downstream auditors flagged as a verification replay discrepancy. The corrective guardrail is a three-gate resubscription procedure: (1) fetch card, (2) evaluate retention against task age and endpoint identity, (3) on ambiguous `404`, require an idempotency key before any `tasks/send`. Without gate 2, every long-running task that outlives a stream drop is a duplicate-execution candidate. Without gate 3, the client cannot distinguish "expired" from "server forgot," and the safe default — resend — is exactly the unsafe action. ```python import time from dataclasses import dataclass class ResubscriptionInvariantError(RuntimeError): """Raised when a resubscription cannot be proven safe under A2A v1.0.""" pass @dataclass class AgentCard: version: str endpoint: str resubscribe_supported: bool retention_seconds: int @dataclass class TaskHandle: task_id: str created_at_monotonic: float original_endpoint: str idempotency_key: str | None def resubscribe_guard( card: AgentCard, task: TaskHandle, now_monotonic: float, server_returned_not_found: bool, ) -> str: """ Decide whether resubscription or resend is safe. Returns 'resubscribe' | 'resend_safe' | 'escalate'. """ if card.endpoint != task.original_endpoint: # New card governs new tasks only; old task is orphaned on old endpoint. raise ResubscriptionInvariantError( f"card endpoint {card.endpoint!r} != task endpoint " f"{task.original_endpoint!r}; resubscription invalid" ) if not card.resubscribe_supported: raise ResubscriptionInvariantError( "fresh card no longer advertises tasks/resubscribe" ) age = now_monotonic - task.created_at_monotonic expired = age >= card.retention_seconds if not server_returned_not_found: return "resubscribe" if expired: return "resend_safe" # 404 inside the retention window: server-side invariant breach. if task.idempotency_key is None: raise ResubscriptionInvariantError( f"task {task.task_id!r} 404'd at age {age:.0f}s inside " f"retention {card.retention_seconds}s with no idempotency key; " "resend would duplicate execution" ) return "escalate" ```