# When must an instance refuse to re-enter a terminal A2A task via a replayed Agent Card **Date of Record:** 2026 November 23 **Scope:** A2A v1.0 deployments where an orchestrator resolves a remote agent via `/.well-known/agent.json`, submits tasks through `tasks/send` or `tasks/sendSubscribe`, and may retry after transport failures. Excludes stateless one-shot RPC endpoints and v0.x cards lacking `capabilities.stateTransitionHistory`. ## Core Distinction The distinction is between *idempotent task re-submission* and *re-entry into a terminal state machine*. A retry reusing a task ID is nominally an idempotency probe; a retry reusing a task ID *and* a stale Agent Card is a state-machine re-entry attempt. The protocol permits the former and forbids the latter, but the wire format does not distinguish them. The discriminator is the `(card.etag, task.state)` pair at submission versus retry. The failure is non-obvious because a replayed card is syntactically valid, signature-valid, and often semantically current enough to pass schema checks. The invariant that breaks: **a terminal task state (`completed`, `failed`, `canceled`, `rejected`) is absorbing with respect to any submission whose card snapshot predates the transition.** Re-submitting across that boundary silently forks a new task under a recycled ID (caller-supplied IDs) or returns a stale `completed` artifact (server-issued IDs deduped on `(taskId, card.etag)`). ## What Was Observed Cross-vendor run (three vendors, MIME types `application/vnd.acme.report+json`, `application/vnd.zenith.ledger+cbor`): 1. Orchestrator fetched vendor Z's card: `etag: "7f3a"`, `stateTransitionHistory: true`, `inputModes` including `text/plain`. 2. Task `t-8841` transitioned `submitted → working → completed` in 2.1s. 3. Artifact-fetch timeout caused retry of `tasks/send` with cached card (`"7f3a"`) and same `taskId`. 4. Vendor Z had published etag `"9c02"`, dropping `text/plain` and flipping `stateTransitionHistory` to `false`. 5. Server accepted the retry (card still signature-valid); with no history retained it could not prove `t-8841` terminal, created a fresh task under `t-8841`, and returned a second artifact with a different `artifactId` but identical `taskId`. Result: two divergent artifacts for one task ID, no protocol signal of the fork, and the orchestrator's `taskId`-keyed layer overwrote the first. Downstream reconciliation failed 40 minutes later on digest mismatch. On vendor A, the same retry returned the *original* `completed` task; the orchestrator treated it as fresh and re-emitted a ledger post already applied. The server held the invariant; the client violated it by not checking `card.etag`. ## Condition of Validity The rule is enforceable only when *all four* hold: - The retry card's `etag`/`lastModified` is byte-identical to submission, **or** the server exposes `stateTransitionHistory: true` and returns the full log on `tasks/get`. - The task ID is server-issued. Caller-supplied IDs on vendors not enforcing cross-generation uniqueness are unsafe to retry. - The terminal state was reached under the *same* card generation. A task terminal under `"7f3a"` and queried under `"9c02"` is in an indeterminate relation. - Artifact negotiation is keyed on `(taskId, artifactId, card.etag)`, not `taskId` alone. When any fails, do not retry: abandon the task ID, re-resolve the card, and re-submit under a fresh ID or escalate to audit. ## Decision Boundary ``` retry_safe := (cached_card.etag == current_card.etag) AND (task.state in NON_TERMINAL_STATES) AND (task.id_origin == SERVER_ISSUED) ``` If `retry_safe` is false and the task is terminal, the instance **must not** re-enter. Raise a distinct, non-retryable error and record the card-generation mismatch. Treating this as transient — the intuitive default — is precisely the failure mode. The boundary is sharp: a card change is a contract change; a terminal task is a closed contract; re-entry attempts a third contract neither party agreed to. Corollary: when `retry_safe` is false, any artifact already received for that `taskId` must be quarantined, not overwritten. Vendor Z's second artifact was a fork, not a correction. ## Operational Effect Three concrete changes. First, retries become card-generation-aware: cache `(taskId, card.etag, state)` at submission and refuse retry when the etag moves. Second, terminal states become absorbing client-side too — a `completed` task is never re-submitted, only re-fetched via `tasks/get` under the *original* etag, and only if the server still serves that generation. Third, artifact keys gain the card etag, making forks visible as distinct keys. The cost: some genuinely transient failures (artifact-fetch timeout where the card also rotated) now require full re-resolve and, if terminal, a fresh submission under a new ID. This is more expensive than naive retry and is the correct trade — naive retry is cheaper precisely because it hides the fork. Not implementing the boundary yields duplicate side effects (vendor A) or silent artifact overwrite (vendor Z), surfacing downstream minutes to hours later with no causal trace. Implementing it yields a small increase in abandoned task IDs and a clean audit trail of card-generation mismatches — the signal you want. ```python from __future__ import annotations from dataclasses import dataclass from enum import Enum class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" REJECTED = "rejected" TERMINAL_STATES = frozenset({ TaskState.COMPLETED, TaskState.FAILED, TaskState.CANCELED, TaskState.REJECTED, }) class TerminalReentryError(RuntimeError): """Raised when a retry would re-enter an absorbing terminal task state across an Agent Card generation boundary. Non-retryable by design.""" class CardGenerationMismatchError(TerminalReentryError): """Raised when the cached card etag differs from the currently served card etag for a task that is already terminal.""" @dataclass(frozen=True) class CardSnapshot: etag: str state_transition_history: bool @dataclass(frozen=True) class TaskSnapshot: task_id: str state: TaskState card_etag_at_submission: str id_origin: str # "server" | "caller" def assert_retry_safe( task: TaskSnapshot, cached_card: CardSnapshot, current_card: CardSnapshot, ) -> None: if task.id_origin != "server": raise TerminalReentryError( f"task {task.task_id!r} has caller-supplied id; " "retry across generations is undefined" ) if task.state not in TERMINAL_STATES: return # non-terminal retries are permitted if cached_card.etag != current_card.etag: raise CardGenerationMismatchError( f"task {task.task_id!r} is terminal ({task.state.value}) " f"under card etag {task.card_etag_at_submission!r}, " f"but current card is {current_card.etag!r}; " "refusing re-entry" ) if not current_card.state_transition_history: raise TerminalReentryError( f"task {task.task_id!r} terminal and server does not expose " "stateTransitionHistory; cannot prove absorbing state" ) # Same generation, history available: re-fetch is safe, re-submit is not. raise TerminalReentryError( f"task {task.task_id!r} is terminal; use tasks/get, not tasks/send" ) ```