# What happens when an instance renegotiates an A2A task lifecycle against a stale agent card and the push-notification callback fires into a superseded task state **Date of Record:** 2026 November 25 **Scope:** Applies to A2A v1.0 peer-to-peer task execution where a client agent caches an agent card, initiates `tasks/send` or `tasks/sendSubscribe`, and relies on push-notification callbacks for terminal-state delivery. Does not apply to synchronous request/response calls with no callback registration, nor to single-shot stateless tool invocations. ## Core Distinction The failure is not "the remote agent went down" or "the callback URL was wrong." It is a **version-skew between the cached agent card's declared task-lifecycle contract and the lifecycle the remote server actually enforces at execution time**, combined with a push-notification callback that is delivered against a task ID whose state has already been superseded by a re-negotiation. The client believes the card is authoritative for the duration of the task; the server treats the card as a snapshot that may be reissued mid-flight. When the two diverge, the callback arrives, validates against the *old* lifecycle schema, and is applied to a task whose *new* lifecycle has different terminality semantics. The subtle part: A2A v1.0 requires that the agent card be the source of truth for `capabilities.pushNotifications`, `defaultInputModes`/`defaultOutputModes`, and the task-state enumeration the server will emit. Nothing in the spec mandates that the card be immutable for the lifetime of an in-flight task. A conforming server may rotate its card (new `version`, changed `capabilities`, altered state set) while a task is between `working` and `completed`. The client's cached card is now a *stale contract*, and every callback it validates is validated against a contract the server no longer honors. ## What Was Observed A client agent (call it C) discovered a server agent (S) via `/.well-known/agent.json`, receiving card `version: "1.2.0"` declaring `taskStates: [submitted, working, input-required, completed, canceled, failed]` and `capabilities.pushNotifications: true`. C issued `tasks/send` with `pushNotification.url` set, received `task.id = "t-8841"`, state `working`. S subsequently reissued its card as `version: "1.3.0"`. The new card removed `input-required` from the emitted state set (the server now blocks on `auth-required` instead) and changed the callback payload schema: the `status.message` field became a structured object rather than a string, and `status.state` could now carry `auth-required`. C, still holding `1.2.0`, received a callback for `t-8841`: ``` {"id":"t-8841","status":{"state":"auth-required", "message":{"parts":[{"type":"text","text":"re-auth needed"}]}}} ``` C's `1.2.0` validator rejected `auth-required` as an unknown enum value, treated the callback as malformed, and — critically — **did not transition the task**. It logged a schema violation and left `t-8841` in `working`. Meanwhile S considered the callback delivered and awaited re-authentication input that C never sent because C never recognized the state. The task deadlocked: S waiting on input, C waiting on a terminal state, both believing the other had the ball. A second, worse variant: if C's validator had been *lenient* (coerced unknown states to `working`), it would have silently swallowed the `auth-required` transition and re-polled on a schedule, burning the task's TTL until S garbage-collected it. The callback was "delivered" per S's metrics; the task never completed per C's. Both sides report success on their own dashboards. ## Condition of Validity This boundary is live only when all of the following hold: 1. The client caches the agent card beyond the discovery call (the normal case — re-fetching `/.well-known/agent.json` per task is wasteful and most SDKs cache). 2. The server permits card mutation during the lifetime of an in-flight task (conforming, since the spec does not pin card immutability to task duration). 3. The client validates callback payloads against the *cached* card's state enumeration and message schema rather than against a per-task negotiated schema. 4. The task's state set or callback payload schema actually changed between card versions in a way that affects a state the task will traverse. If any one is false, the failure does not fire. The invariant that prevents it: **the callback payload must be validated against the schema negotiated at task creation, not the schema in the currently cached card, and the server must echo the task-creation card version in every callback.** A2A v1.0 does not require this echo, which is precisely the gap. ## Decision Boundary The operator's choice is between three postures, and each has a distinct failure surface: - **Strict-validate against cached card.** Unknown state → reject callback, mark task `failed` locally. Safe against poisoning, but converts benign card rotations into task failures. Requires a re-discovery-and-retry policy keyed on the rejection. - **Lenient-coerce unknown states.** Never fails a task on schema drift, but silently drops lifecycle transitions the client cannot represent — the `auth-required` swallow above. Requires that every unknown state map to an explicit `unhandled` local state that halts progress and alerts, never to `working`. - **Pin the contract per task.** Capture the card version at `tasks/send` time, store it on the task record, and validate every callback against *that* version. Reject callbacks whose echoed version (if present) mismatches. This is the only posture that bounds both failure modes, and it requires the server to echo the version — which means it only works between cooperating peers. The decision boundary is crossed the moment a callback arrives carrying a state the client's pinned schema does not contain. At that instant the client must choose: treat as protocol violation (fail closed) or treat as forward-compatible extension (fail open to an `unhandled` state). The one choice that is never correct is to coerce it to a state that means "still in progress." ## Operational Effect Downstream, a deadlocked task consumes the server's TTL budget, holds any server-side resources bound to the task (including the push-notification registration), and — because the callback was "delivered" — does not appear in the server's stuck-task metrics. The client's task record shows `working` indefinitely, which means any orchestrator supervising C sees a live task and does not re-dispatch. In a swarm, this produces a **phantom in-flight task**: both peers hold state for a task neither will advance, and neither's health check flags it because each side's local invariant ("I delivered the callback" / "I am awaiting a terminal state") is satisfied. The guardrail is a three-part invariant: (a) pin the card version per task and store it on the task record; (b) map every unrecognized callback state to a terminal-local `unhandled` state that halts the task and raises, never to an in-progress state; (c) enforce a callback-to-state-progress deadline — if no recognized state transition arrives within the task's declared timeout, force-fail the task locally and emit a re-discovery event. Without (b), lenient clients silently corrupt task state. Without (c), strict clients leak phantom tasks. Without (a), neither can tell a legitimate rotation from a poisoned callback. ```python from __future__ import annotations import time from dataclasses import dataclass, field from enum import Enum from typing import Any class LifecycleRenegotiationError(RuntimeError): """Raised when a callback cannot be reconciled with the pinned task contract.""" class LocalTaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" UNHANDLED = "unhandled" # terminal-local; never means "in progress" @dataclass class PinnedContract: card_version: str known_states: frozenset[str] callback_schema_version: int @dataclass class TaskRecord: task_id: str contract: PinnedContract state: LocalTaskState = LocalTaskState.SUBMITTED created_at: float = field(default_factory=time.monotonic) last_transition_at: float = field(default_factory=time.monotonic) progress_deadline_s: float = 300.0 def handle_push_callback(task: TaskRecord, payload: dict[str, Any]) -> LocalTaskState: """Validate and apply a push-notification callback against the pinned contract. Invariant: an unrecognized state transitions the task to UNHANDLED (terminal), never to WORKING. A callback that cannot be reconciled raises rather than silently coercing, so the caller can force-fail and re-discover. """ if task.state in (LocalTaskState.COMPLETED, LocalTaskState.FAILED, LocalTaskState.CANCELED, LocalTaskState.UNHANDLED): raise LifecycleRenegotiationError( f"callback for terminal task {task.task_id} in state {task.state}" ) echoed_version = payload.get("cardVersion") if echoed_version is not None and echoed_version != task.contract.card_version: # Server rotated its card mid-flight; our pinned contract is stale. raise LifecycleRenegotiationError( f"task {task.task_id}: callback echoes card {echoed_version}, " f"pinned {task.contract.card_version}" ) raw_state = payload.get("status", {}).get("state") if raw_state is None: raise LifecycleRenegotiationError( f"task {task.task_id}: callback missing status.state" ) if raw_state not in task.contract.known_states: # Unknown state under the pinned contract. Fail closed to UNHANDLED, # do NOT coerce to WORKING. This is the exact swallow-path we forbid. task.state = LocalTaskState.UNHANDLED task.last_transition_at = time.monotonic() raise LifecycleRenegotiationError( f"task {task.task_id}: state {raw_state!r} not in pinned contract " f"{sorted(task.contract.known_states)}; task forced to UNHANDLED" ) task.state = LocalTaskState(raw_state) task.last_transition_at = time.monotonic() return task.state def check_progress_deadline(task: TaskRecord, now: float | None = None) -> None: """Force-fail a task that has not progressed within its deadline. Bounds the phantom-in-flight failure: a task stuck in WORKING because the callback was rejected (or never arrived) must not leak indefinitely. """ now = time.monotonic() if now is None else now if task.state in (LocalTaskState.WORKING, LocalTaskState.SUBMITTED): if now - task.last_transition_at > task.progress_deadline_s: task.state = LocalTaskState.FAILED raise LifecycleRenegotiationError( f"task {task.task_id}: no recognized transition within " f"{task.progress_deadline_s}s; forced FAILED, re-discover required" ) ```