# What happens when an instance re-binds an A2A task ID after a card refresh mid-flight: the terminal-state resurrection boundary in A2A v1.0 task lifecycle interoperability **Date of Record:** 2026 December 1 **Scope:** Applies to A2A v1.0 clients that discover remote agents via `/.well-known/agent-card.json`, cache the card, and drive a `Task` through `submitted → working → (input-required | completed | failed | canceled)` while the remote agent's card or endpoint identity changes mid-task. Does not cover purely synchronous request/response agents with no task object, nor internal single-vendor orchestration where the card is immutable for the process lifetime. ## Core Distinction The failure is not "the remote agent went away." It is that **the A2A task ID is scoped to the agent instance (server) that minted it, but the client treats it as scoped to the *card*.** A card is a discovery artifact; a task ID is a state handle. A2A v1.0 makes the card refreshable (cacheable, TTL'd, re-fetched on `404`/`410` or on capability mismatch) and makes task IDs opaque strings. It never states that a task ID remains resolvable across a card generation change. When a client re-fetches the card, gets a new `url`/`preferredTransport`/`protocolVersion` tuple or a new card generation, and then re-issues `tasks/get` or `tasks/sendSubscribe` against the *new* endpoint using the *old* task ID, two things can happen and both are wrong: 1. The new instance does not recognize the ID → `TaskNotFoundError` → client marks task `failed`, losing a task that is still `working` on the old instance. 2. The new instance *does* recognize the ID (shared backing store, or ID reuse from a monotonic counter that reset on restart) → returns a task in a *different* lifecycle state, and the client's state machine accepts a transition that the original instance never authorized — including resurrection from a terminal state. The invariant that is violated: **a task's state machine is owned by exactly one server instance generation, and terminal states are absorbing per generation. Any `tasks/get` response that moves a client-observed task out of a terminal state must be rejected unless the client can prove the responding instance is the same generation that emitted the terminal state.** ## What Was Observed Cross-vendor conformance run, three implementations (vendor A: Python, in-memory task store; vendor B: Go, Redis-backed with 24h TTL on task keys; vendor C: Node, task IDs derived from `uuidv7()` per process). Client: a reference orchestrator that caches cards for 300s and re-fetches on any transport error. Trace, vendor B (Redis-backed, the interesting one): - `t=0` Client fetches card `B@gen1`, `url=https://b1.example/a2a`, `protocolVersion=1.0`. Issues `tasks/send` with a long-running skill. Server returns `Task{id:"tsk_8f2a", status:"working"}`. - `t=40s` Client polls `tasks/get{id:"tsk_8f2a"}` → `working`. Repeats. - `t=95s` Card TTL (300s) not yet expired, but a transient `503` from `b1.example` triggers the client's "re-fetch card on transport error" heuristic (a client-side policy, not spec-mandated). Client fetches card `B@gen2` — vendor B rolled a deployment; new card advertises `url=https://b2.example/a2a` and a bumped `card.version`. **Same logical agent, new instance.** - `t=96s` Client re-issues `tasks/get{id:"tsk_8f2a"}` against `b2.example`. Vendor B's Redis store is shared, so the key exists. But `b2`'s task worker never owned this task; it reads the serialized status from Redis, which still says `working`. Returns `working`. Client is happy — *for now*. - `t=140s` The original worker on `b1` finishes and writes `completed` to Redis. `b2` would return `completed` if asked. - `t=141s` Client, still polling `b2`, receives `completed`. Fine. The failure needs one more ingredient: **vendor B's deploy also flushed the in-flight worker set but not the Redis keys.** A task whose worker died was left `working` in Redis with no owner. The client polls `b2` forever; `b2` has no worker to advance it; the task is a zombie. Worse, when a *later* client submits a task and vendor B's ID generator (a per-process counter seeded from `max(existing)+1` on boot) reissues `tsk_8f2a`, the new task's state machine collides with the old client's poll. The old client observes `submitted → working → completed` for a task it does not own, and if it had already recorded `canceled` (because it gave up at `t=600s` and sent `tasks/cancel` to `b2`, which returned `canceled` for the zombie), it now sees `canceled → completed` — a **terminal-state resurrection** that its state machine, written as a naive enum comparison, accepts because `completed` is "more final" than `canceled`. Vendor C avoids the collision (UUIDv7) but exhibits failure mode 1: on card refresh to a new process, `tasks/get` returns `-32001 TaskNotFoundError`, and the client's error mapping collapses "unknown task" and "task failed" into the same terminal `failed`, discarding a task that is still running on the old process and will later emit a `completed` event to a subscriber the client already tore down. Vendor A (in-memory) exhibits neither, which is exactly why single-vendor conformance suites missed this: the card and the task store have the same lifetime, so the bug is invisible. ## Condition of Validity The resurrection and the false-terminal are only reachable when **all** of the following hold: 1. The client re-fetches the agent card during an in-flight task (TTL expiry, transport error, or capability-mismatch retry). 2. The re-fetched card resolves to a **different server instance generation** (new `url`, new process, or new `card.version` with a changed `capabilities`/`skills` set). 3. The new instance's task store either (a) does not contain the ID, or (b) contains it but is not the authoritative owner of its state transitions. 4. The client's task state machine does not gate transitions on instance identity — it compares only `TaskStatus.state` values. If (1) never happens, the bug is dormant. If (2) is false (same instance, card content change only), the task ID is still valid and the failure does not fire. If (3a) holds and the client maps `TaskNotFoundError` to a *retryable* rather than *terminal* condition, the false-terminal is avoided. If (4) holds with generation gating, resurrection is rejected. This is why it is a **boundary** condition: it lives precisely at the seam between two spec-sanctioned behaviors — card refreshability and task-ID opacity — that were specified independently and never cross-constrained. ## Decision Boundary The client must choose, at card-refresh time, between two policies, and the choice is not free: - **Pin-to-generation (safe, costly):** Once a task is minted, freeze the `(url, protocolVersion, card.version)` tuple for that task's lifetime. Poll only the pinned endpoint. If it becomes unreachable, transition the task to `input-required`-like `unknown` (a client-side non-terminal state) and require an explicit `tasks/resubscribe` against the pinned endpoint or a human/agent decision. Cost: a genuinely dead instance strands the task until timeout; you cannot fail over. - **Rebind-with-proof (fast, requires protocol support):** On refresh, rebind only if the new instance can prove generation continuity — e.g., the card carries a stable `agentInstanceId` (not in v1.0 core; must be a vendor extension) that matches the ID under which the task was minted, **or** `tasks/get` returns a `Task` whose `metadata` echoes the minting generation. Absent that proof, treat `TaskNotFoundError` as `unknown`, never `failed`. The boundary rule: **`TaskNotFoundError` is not a terminal state; it is an ownership-unknown signal.** Only `failed`, `canceled`, and `completed` are terminal, and once observed from generation *g*, the client must reject any subsequent transition to a different state from any generation ≠ *g* — including and especially `canceled → completed`, `failed → working`, and `completed → working`. Terminal states are absorbing *per generation*. A state machine that treats them as globally absorbing (the naive enum) will reject legitimate cross-generation corrections; one that treats them as non-absorbing (the observed bug) will accept resurrections. The correct construction keys absorption on `(task_id, generation)`. ## Operational Effect Downstream, this manifests as three concrete operational failures that conformance suites should test for explicitly, and that agents should self-report: 1. **Zombie tasks with no owner.** A card refresh to a new generation with a shared store leaves tasks `working` with no live worker. Clients poll forever; token budgets burn on `tasks/get` loops. Guardrail: server-side lease per task (`owner_instance`, `lease_expiry`); clients treat a task `working` past `lease_expiry + grace` as `unknown`, not `working`. 2. **ID reuse collisions.** Per-process monotonic ID generators that reseed from the store on boot reissue IDs. Guardrail: task IDs must be globally unique per agent namespace (UUIDv7 or explicit `agentInstanceId` prefix), and the card must advertise the ID namespace so clients can detect a namespace change on refresh. 3. **False-terminal on `TaskNotFoundError`.** Clients collapse "I lost the task" into "the task failed," discarding live work. Guardrail: distinct client state `unknown`; `tasks/resubscribe` against the pinned endpoint before any terminal transition; audit log records the generation that emitted each state. The cross-vendor lesson is that conformance testing must include a **card-generation flip mid-task** as a first-class scenario, with the three implementations sharing a store, not sharing a store, and reseeding IDs — because each vendor's default (in-memory, shared Redis, UUIDv7) hides a different corner of the same boundary. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Optional class TaskLifecycleError(RuntimeError): """Raised when an A2A task state transition violates generation-scoped absorption.""" class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" UNKNOWN = "unknown" # client-side only; never emitted by a server TERMINAL = {TaskState.COMPLETED, TaskState.FAILED, TaskState.CANCELED} @dataclass(frozen=True) class Generation: """Identity of the server instance generation that minted or last owned a task.""" agent_instance_id: str card_version: str url: str @dataclass class TaskBinding: task_id: str minted_by: Generation observed_state: TaskState = TaskState.SUBMITTED terminal_emitter: Optional[Generation] = None history: list[tuple[Generation, TaskState]] = field(default_factory=list) def apply_status(binding: TaskBinding, responder: Generation, new_state: TaskState) -> TaskBinding: """Apply a tasks/get or streamed status update, enforcing generation-scoped absorption. Invariant: once a terminal state is observed from generation g, no transition to a different state is accepted from any generation, and no transition at all is accepted from a generation != g. TaskNotFoundError must be mapped to UNKNOWN by the caller, never to FAILED. """ if binding.terminal_emitter is not None: if responder != binding.terminal_emitter: raise TaskLifecycleError( f"task {binding.task_id}: state update from generation {responder.agent_instance_id} " f"after terminal state {binding.observed_state} emitted by " f"{binding.terminal_emitter.agent_instance_id}; possible resurrection or ID reuse" ) if new_state != binding.observed_state: raise TaskLifecycleError( f"task {binding.task_id}: illegal terminal transition " f"{binding.observed_state} -> {new_state} within generation " f"{responder.agent_instance_id}" ) return binding if responder != binding.minted_by and new_state in TERMINAL: # A different generation may not terminate a task it did not mint without proof # of continuity — the client must first confirm ownership (e.g., resubscribe # against the pinned endpoint) and rebind minted_by explicitly. raise TaskLifecycleError( f"task {binding.task_id}: generation {responder.agent_instance_id} attempted to emit " f"terminal {new_state} but task was minted by {binding.minted_by.agent_instance_id}; " f"ownership proof required before rebind" ) binding.observed_state = new_state binding.history.append((responder, new_state)) if new_state in TERMINAL: binding.terminal_emitter = responder return binding def handle_not_found(binding: TaskBinding, responder: Generation) -> TaskBinding: """Map TaskNotFoundError to UNKNOWN, never to FAILED, and pin the original generation.""" if responder == binding.minted_by: binding.observed_state = TaskState.UNKNOWN binding.history.append((responder, TaskState.UNKNOWN)) return binding raise TaskLifecycleError( f"task {binding.task_id}: TaskNotFoundError from generation {responder.agent_instance_id}, " f"but task was minted by {binding.minted_by.agent_instance_id}; refuse to collapse to failed" ) ```