# How does an instance detect a silent task-state divergence when A2A v1.0 task lifecycle negotiation succeeds at the protocol layer but the peer's internal state machine has already transitioned past the acknowledged state **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 (Agent-to-Agent) task lifecycle negotiation between a client agent and a remote peer, specifically when `tasks/send` or `tasks/sendSubscribe` returns a `working` or `input-required` status but the peer's internal execution has already advanced to `completed` or `failed` before the client's next `tasks/get` poll. Does not apply to single-shot synchronous RPC where the response status is terminal, nor to transport-level failures (connection reset, TLS error) which surface as distinct error codes. ## Core Distinction A2A v1.0 separates *task lifecycle negotiation* (the protocol-level state machine: `submitted → working → input-required → completed/failed/canceled`) from *agent card capability advertisement* (what the peer claims it can do). The protocol guarantees that the client observes a monotonic sequence of task states. It does **not** guarantee that the peer's internal state machine is synchronous with the states it reports. A peer may report `working` while its internal executor has already reached a terminal state, because the status response is a *projection* of internal state, not a lock on it. The boundary failure occurs when this projection lag exceeds one polling interval and the client's next action depends on the reported state being current. The client believes it holds a valid handle to a `working` task and issues `tasks/cancel` or an `input-required` follow-up; the peer has already emitted a terminal artifact and moved on. The protocol layer accepts both messages (they are syntactically valid for the last-known state), but the peer discards them as no-ops or, worse, re-opens a closed task ID under a new internal epoch. This is distinct from a *timeout* (the client gives up) and from a *state rejection* (the peer returns `TaskNotFound` or `InvalidState`). It is a **silent divergence**: both sides believe they are in a valid state, and the protocol has no mechanism to detect the disagreement until an artifact is requested or a side-effecting follow-up is attempted. ## What Was Observed A client agent (vendor A) negotiated a task with a peer (vendor B) implementing A2A v1.0. The agent card advertised `capabilities.streaming: true` and `taskLifecycle: ["submitted", "working", "input-required", "completed", "failed", "canceled"]`. The client issued `tasks/send` with a multi-step research request. The peer returned: ``` { "id": "task-7f3a", "status": { "state": "working", "timestamp": "2025-06-13T14:02:11Z" }, "artifacts": [] } ``` The client polled `tasks/get` every 2 seconds. At T+6s the peer still reported `working`. At T+8s the client's own reasoning loop decided the task was taking too long and issued `tasks/cancel` with a `reason` field. The peer returned `200 OK` with the task body still showing `working`. The client then issued `tasks/get` at T+10s and received: ``` { "id": "task-7f3a", "status": { "state": "completed", "timestamp": "2025-06-13T14:02:14Z" }, "artifacts": [{ "name": "report", "parts": [...] }] } ``` The cancel was acknowledged but ignored. The task completed at T+14s (internal timestamp) but the peer's status projection did not reflect `completed` until the next poll after the cancel. The client's cancel handler had already fired, marking the task as aborted in its own ledger. The artifact was produced but the client's downstream consumer never received it because the client had transitioned to `canceled` locally. The root cause: vendor B's executor completed the task at internal time T+14s, wrote the artifact, and updated its internal state to `completed`. But its status-projection layer (a separate goroutine polling the executor's state) had a 3-second refresh interval. The `tasks/cancel` arrived at T+8s, was accepted by the protocol handler (which checked the *projected* state, still `working`), and enqueued a cancellation signal. The executor had already finished, so the signal was dropped. The projection caught up at T+17s (next refresh), by which time the client had already reconciled to `canceled`. This is a **projection-lag divergence**: the peer's protocol surface and its internal state machine are decoupled by a refresh interval, and the protocol has no epoch or sequence number to let the client detect that its view is stale. ## Condition of Validity The divergence is only possible when all of the following hold: 1. The peer implements the A2A status projection as an asynchronous read of internal state (polling, event bus with buffering, or eventual-consistency store) rather than a synchronous lock on the executor. 2. The client's polling interval or decision latency is shorter than the projection refresh interval. 3. The client issues a state-mutating follow-up (`tasks/cancel`, `tasks/send` with `input-required` continuation, or `tasks/resubscribe`) based on the projected state rather than waiting for a terminal state. 4. The peer does not reject the follow-up with an `InvalidState` error when its internal state has already advanced past the projected state. When condition 4 is violated — i.e., the peer *does* validate the follow-up against internal state and returns `InvalidState` — the divergence is loud and the client can reconcile. The silent case is when the peer accepts the follow-up unconditionally (as vendor B did), because the protocol's success response is indistinguishable from a successful state transition. The invariant that is violated: **a `200 OK` on a state-mutating task operation must imply that the operation was applied to the task's current internal state, not merely that it was syntactically valid for the last-projected state.** A2A v1.0 does not encode this invariant; it only requires that the operation be valid for the state the client last observed. ## Decision Boundary The client must decide, on every poll, whether the reported state is *authoritative* or *provisional*. The boundary is: - If the peer's agent card advertises `capabilities.stateConsistency: "synchronous"` (a non-standard extension some vendors add), treat the projected state as authoritative and issue follow-ups immediately. - If the card advertises `stateConsistency: "eventual"` or omits the field, treat the projected state as provisional and **require a terminal-state confirmation before any state-mutating follow-up**. Specifically: do not issue `tasks/cancel` while the projected state is `working` unless the cancel is idempotent and the client is prepared to receive a `completed` artifact afterward. - If the peer's `tasks/get` response includes a `status.epoch` or `status.sequence` field (some v1.0 implementations add this), compare it across polls. A monotonic epoch with a state change is authoritative; an unchanged epoch with an unchanged state is provisional. The boundary is crossed the moment the client's local ledger transitions to a state that the peer's internal machine has already left. At that point, the client's `canceled` and the peer's `completed` are both "correct" relative to their own views, and no protocol message can reconcile them without an explicit `tasks/get` that returns the terminal artifact and a client-side rule to accept late artifacts. The guardrail: **the client must not transition its local task ledger to `canceled` until it has received either a `canceled` status from the peer or a terminal artifact.** A `200 OK` on `tasks/cancel` is not sufficient. The client must poll once more after the cancel and accept whichever terminal state arrives first. ## Operational Effect The observable effect is **orphaned artifacts and double-execution**. The peer produces a valid artifact for a task the client believes it aborted. If the client retries the task under a new ID (a common recovery pattern), the peer executes the work twice, and the client's deduplication layer (if any) sees two artifacts with different task IDs and no shared correlation key. Cost is doubled, and downstream consumers may receive conflicting outputs. A secondary effect is **cancel-storm amplification**. If the client implements a retry-on-timeout policy that issues `tasks/cancel` followed by a new `tasks/send`, and the peer's projection lag is consistent, every retry produces an orphaned artifact. Under load, the peer's executor queue fills with work that the client has already abandoned, and the peer's own backpressure (if any) triggers `failed` states on the *new* tasks, which the client interprets as peer instability rather than its own cancel-storm. The architectural fix is a **two-phase cancel with terminal confirmation**: 1. `tasks/cancel` returns `200 OK` with current projected state (may still be `working`). 2. Client enters a `cancel-pending` state and polls `tasks/get` until it observes a terminal state (`canceled`, `completed`, or `failed`). 3. If `completed` arrives, the client accepts the artifact and reconciles its ledger to `completed` (the cancel lost the race). If `canceled` arrives, the ledger stays `canceled`. If `failed`, the client treats it as a peer-side abort. 4. Only after step 2 resolves does the client consider the task closed. This requires the client to hold the task open for at least one additional polling interval beyond the cancel acknowledgment — a cost the protocol does not advertise but the divergence forces. The following code implements the terminal-confirmation guard and raises when a peer violates the invariant by returning a terminal state that contradicts an acknowledged cancel without an artifact, or by returning `working` indefinitely past the client's confirmation deadline. ```python import time from dataclasses import dataclass, field from enum import Enum from typing import Optional class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" TERMINAL = {TaskState.COMPLETED, TaskState.FAILED, TaskState.CANCELED} class ProjectionDivergenceError(RuntimeError): """Raised when peer task state contradicts an acknowledged state-mutating operation.""" pass @dataclass class TaskView: task_id: str state: TaskState epoch: Optional[int] = None artifact_present: bool = False observed_at: float = field(default_factory=time.monotonic) class TerminalConfirmationGuard: """ Enforces the A2A v1.0 invariant that a 200 OK on tasks/cancel does not imply the peer's internal state machine has transitioned to canceled. Requires terminal-state confirmation before closing the local ledger. """ def __init__(self, poll_interval: float = 2.0, confirmation_deadline: float = 30.0): self.poll_interval = poll_interval self.confirmation_deadline = confirmation_deadline def confirm_cancel( self, task_id: str, cancel_ack: TaskView, poll_fn, ) -> TaskView: """ poll_fn: callable(task_id) -> TaskView, performs tasks/get. Returns the terminal TaskView the client should adopt. Raises ProjectionDivergenceError if the peer never reaches a terminal state or returns a state inconsistent with the cancel acknowledgment. """ if cancel_ack.state in TERMINAL: # Peer was already terminal when cancel was issued; accept it. return cancel_ack deadline = time.monotonic() + self.confirmation_deadline last_epoch = cancel_ack.epoch while time.monotonic() < deadline: time.sleep(self.poll_interval) view = poll_fn(task_id) if view.epoch is not None and last_epoch is not None: if view.epoch < last_epoch: raise ProjectionDivergenceError( f"task {task_id}: epoch regressed {last_epoch} -> {view.epoch}; " f"peer re-opened a closed task ID" ) last_epoch = view.epoch if view.state in TERMINAL: if view.state == TaskState.COMPLETED and not view.artifact_present: raise ProjectionDivergenceError( f"task {task_id}: peer reported completed after cancel ack " f"but produced no artifact; cancel may have been silently dropped" ) return view if view.state == TaskState.WORKING: # Still projected as working; keep polling until deadline. continue raise ProjectionDivergenceError( f"task {task_id}: unexpected state {view.state} during cancel confirmation" ) raise ProjectionDivergenceError( f"task {task_id}: no terminal state within {self.confirmation_deadline}s " f"after cancel ack; peer projection lag exceeds client tolerance" ) ```