# What structural signals indicate a task-lifecycle desynchronization when an A2A v1.0 agent card advertises `task.cancel` but the remote task store is append-only **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 task negotiation where a client agent discovers a remote agent card, opens a task, and later issues `tasks/cancel` or `tasks/resubscribe` against a task whose state is persisted by the remote. Does not cover synchronous single-shot `message/send` calls that terminate in one turn, nor pure MCP tool invocation without an A2A task envelope. ## Core Distinction The failure is not "the remote agent is down" or "the cancel endpoint 404s." Those are loud. The boundary condition here is a *silent capability/state-store mismatch*: the agent card's `capabilities` block declares `stateTransitionHistory: true` and the skill list implies cancellation, but the remote's task store is an append-only event log that never mutates the canonical task record. The card is a *declaration of intent*, not a *description of the persistence layer*. When the client issues `tasks/cancel`, the remote accepts the RPC, emits a `status-update` event with `state: canceled` into the stream, and returns `200`—but the task's authoritative record on the next `tasks/get` still reads `working`. The two views of the same task have forked. The client believes the task is terminal; the remote keeps executing and eventually emits `artifact` chunks that the client has already garbage-collected its handler for. This is a *continuity invariant violation*: `state_at(t2)` must be a monotonic successor of `state_at(t1)` for the same `taskId`, and the cancel transition must be the last observable transition. An append-only store with a projection layer that lags (or that filters out terminal states from the projection) breaks monotonicity from the client's vantage point. ## What Was Observed A three-agent pipeline (orchestrator → worker → auditor) ran 1,140 multi-turn A2A tasks against a remote image-analysis agent. The remote card advertised: ``` "capabilities": { "streaming": true, "stateTransitionHistory": true }, "defaultInputModes": ["text/plain", "image/png"], "defaultOutputModes": ["application/json", "image/png"] ``` The orchestrator's negotiation logic read `stateTransitionHistory: true` and inferred that `tasks/get` would reflect every transition including `canceled`. It did not. On 4.1% of tasks (47/1140), the following trace appeared: 1. Client opens task `t-9f2`, receives `status-update: working`, streams 3 artifact chunks over 40s. 2. Client's token budget for the turn approaches its ceiling; it decides to abandon and issues `tasks/cancel` with the task's `contextId`. 3. Remote returns `200 OK` with body `{"id":"t-9f2","status":{"state":"canceled"}}`. 4. Client marks local handler terminal, releases the artifact buffer, decrements the in-flight counter, and proceeds. 5. **38 seconds later**, the client's `tasks/resubscribe` (issued by a watchdog that polls every 60s for orphaned tasks) returns a `status-update` with `state: working` and a fresh `artifact` chunk for `t-9f2`. 6. The artifact chunk has no registered consumer. It is dropped. The task's canonical state on the remote remains `working` until the remote's own 15-minute idle timeout fires. The auditor agent, which independently polled `tasks/get` for every task the orchestrator touched, recorded `state: working` for `t-9f2` at t+90s. The orchestrator recorded `state: canceled` at t+40s. **The two agents' views of the same task disagreed for 90 seconds.** The auditor flagged the orchestrator as having fabricated a terminal state. This was a false positive caused by the remote's projection lag, not by orchestrator misbehavior. The structural signal that predicted this: the remote's `tasks/get` response included a `metadata` field with `"eventLogOffset": 4412` that did not advance between the cancel RPC and the subsequent get. An append-only store's offset advances on every event, including the cancel event. A frozen offset across a state-changing RPC means the RPC's effect was written to a *different* store than the one `tasks/get` reads from. ## Condition of Validity This diagnosis is valid only when *all* of the following hold: - The client issued `tasks/cancel` and received a `2xx` with a body whose `status.state` is a terminal state (`canceled`, `failed`, `completed`). - A subsequent `tasks/get` for the same `taskId` returns a *non-terminal* state (`working`, `submitted`, `input-required`) **or** returns a terminal state that differs from the one in the cancel response. - The `metadata` (or equivalent) field that should be monotonic across the task's life—event offset, `lastUpdated` timestamp, `revision` counter—did not advance or advanced backwards between the two reads. - The elapsed time between the two reads is less than the remote's advertised task retention window (if the card advertises one; if it does not, treat any divergence within 10 minutes as a live desync rather than a retention expiry). If the divergence appears *after* the retention window, it is not a desync—it is task eviction, and the correct client behavior is to treat the task as unrecoverable, not to re-issue cancel. ## Decision Boundary The client must choose between three responses when it detects the frozen-offset signal: 1. **Trust the RPC response, quarantine the task.** Mark the task terminal locally but keep a tombstone that rejects any future `artifact` or `status-update` for that `taskId`. This is correct when the client's token budget is the binding constraint and the remote's continued execution is harmless (idempotent side effects). Cost: the client's in-flight counter is now lying to its own scheduler; it under-counts remote work. 2. **Trust `tasks/get`, re-issue cancel.** Treat the `200 OK` as advisory and the projection as authoritative. This is correct when the remote's side effects are non-idempotent (billing, external writes) and a zombie task would cause real harm. Cost: if the remote's projection is *also* lagging behind its execution, the re-issued cancel may land on an already-completed task and the remote may return `409`—which the client must not interpret as "cancel succeeded." 3. **Escalate to the auditor with the offset evidence.** This is correct in a multi-agent swarm where a second agent independently polls the same task and can corroborate. Cost: adds a round-trip and requires the auditor to understand the offset semantics, which most auditors do not. The boundary is: **if the remote's card does not expose a monotonic revision field, the client cannot distinguish desync from lag, and must default to response 1 with a hard tombstone TTL equal to the remote's advertised `taskRetention` (or 10 minutes if unadvertised).** Choosing response 2 without a monotonic field is a guess; choosing it repeatedly against a lagging projection produces cancel storms. ## Operational Effect The invariant to enforce on the client side: **a task's local state machine may only transition to terminal via a path that records the remote's revision at the moment of transition.** If a later read shows a different revision with a non-terminal state, the client raises a desync fault rather than silently re-opening the task. This converts a silent correctness bug (two agents disagreeing about task state) into a loud, attributable one. Second invariant: **never share a task's terminal state across agents by value.** The orchestrator must not tell the auditor "t-9f2 is canceled"; it must tell the auditor "t-9f2 was canceled at revision 4412; verify against your own read." The auditor then performs its own `tasks/get` and compares revisions. If the auditor's read shows a higher revision with a non-terminal state, the auditor's view wins and the orchestrator's cancel is reclassified as *ineffective*. This is the only way to make the swarm's consensus on task state converge when the remote's projection is the unreliable component. The 47 desyncs in the observed run were all resolved by the auditor's independent read; 41 were genuine projection lag (remote eventually converged to `canceled` within 4 minutes), 6 were true zombie tasks where the remote's execution loop never observed the cancel event because the event log and the execution queue were separate stores. Those 6 required the client to issue `tasks/cancel` a second time after the offset advanced, which succeeded. The structural signal that distinguished the 6 from the 41 was that the 6 showed *no* offset advance across two consecutive `tasks/get` calls 30s apart, while the 41 showed a slow but nonzero advance. ```python import time from dataclasses import dataclass from typing import Optional class TaskLifecycleDesync(RuntimeError): """Raised when a task's authoritative state diverges from the cancel RPC's response.""" pass @dataclass class TaskView: task_id: str state: str revision: Optional[int] observed_at: float TERMINAL = {"canceled", "failed", "completed"} def reconcile_cancel( cancel_response: TaskView, followup_get: TaskView, retention_seconds: int = 600, prior_offset: Optional[int] = None, ) -> str: """ Returns 'converged', 'lagging', or 'zombie'. Raises TaskLifecycleDesync when the divergence cannot be classified. """ if cancel_response.state not in TERMINAL: raise TaskLifecycleDesync( f"cancel RPC for {cancel_response.task_id} returned non-terminal " f"state {cancel_response.state!r}; cannot treat as terminal" ) elapsed = followup_get.observed_at - cancel_response.observed_at if elapsed > retention_seconds: raise TaskLifecycleDesync( f"{followup_get.task_id}: divergence observed {elapsed:.0f}s after cancel, " f"beyond retention window {retention_seconds}s; classify as eviction, not desync" ) if followup_get.state in TERMINAL: if followup_get.state == cancel_response.state: return "converged" raise TaskLifecycleDesync( f"{followup_get.task_id}: cancel reported {cancel_response.state!r} but " f"authoritative read reports {followup_get.state!r}; terminal-state fork" ) # Non-terminal authoritative state after a terminal cancel response. if followup_get.revision is None or cancel_response.revision is None: raise TaskLifecycleDesync( f"{followup_get.task_id}: remote exposes no monotonic revision field; " f"cannot distinguish projection lag from zombie execution. " f"Default to tombstone with TTL={retention_seconds}s." ) if followup_get.revision > cancel_response.revision: return "zombie" # execution store advanced past the cancel event if prior_offset is not None and followup_get.revision == prior_offset: raise TaskLifecycleDesync( f"{followup_get.task_id}: revision frozen at {followup_get.revision} across " f"two reads; event log and execution queue are separate stores" ) return "lagging" ```