# What structural signals indicate an A2A v1.0 task has silently forked: terminal-state divergence between the caller's task object and the remote agent's task store after a `tasks/resend` retry **Date of Record:** 2026 November 23 **Scope:** Applies to A2A v1.0 peer-to-peer task lifecycles where a caller holds a local task object (`Task.id`, `Task.status.state`) synchronized against a remote agent's authoritative task store via `tasks/get`, `tasks/resend`, and SSE `tasks/subscribe` streams. Does not apply to single-shot stateless `message/send` calls that never persist a task handle, nor to A2A v0.2 clients lacking the `tasks/resend` verb. ## Core Distinction The A2A v1.0 spec makes the *remote* agent the single source of truth for task state, and gives the caller a `tasks/resend` verb specifically for the case where the caller's last write (a `message/send` continuation, a `tasks/cancel`, or a follow-up turn) may have been lost to a transport timeout. The spec frames `tasks/resend` as idempotent: "re-deliver the most recent unacknowledged request for this task." The subtlety is that **idempotency of delivery is not idempotency of state transition.** A `tasks/resend` re-delivers a *request envelope*, but the remote agent re-executes the *intent* of that envelope against whatever state the task has drifted into since the original send. If the original send actually succeeded server-side but the acknowledgement was lost, the resend arrives at a task that has already advanced — and the remote agent, having no way to distinguish "first delivery" from "replay," may apply the transition a second time. This produces a **silent fork**: the caller's local `Task.status.state` and the remote store's `Task.status.state` diverge, both are individually "valid" per the state machine's allowed transitions, and neither side raises an error. The fork is silent because A2A's terminal states (`completed`, `failed`, `canceled`, `rejected`) are absorbing — once the remote reaches one, `tasks/get` will faithfully report it, but the *caller* may have already locally transitioned to a different terminal state via its own optimistic path, and there is no reconciliation verb that resolves two conflicting terminals. The caller believes the task is `canceled`; the remote believes it is `completed` and has already emitted its artifact. Both are conformant. Only one is true. ## What Was Observed During conformance testing of a v1.0 reference implementation against a fault-injecting transport proxy, the following trace reproduced deterministically at ~40% injection rate of a dropped ACK on `message/send`: 1. Caller dispatches `message/send` with `taskId: T-4417`, continuation turn, `state` intent = `working`. 2. Remote agent receives, transitions `T-4417` from `input-required` → `working`, begins tool execution, emits `TaskStatusUpdateEvent{state: working}` on the SSE stream. 3. Proxy drops the HTTP 200 ACK to the caller. SSE stream is a *separate* channel and remains open — but the caller's synchronous request handler times out at 30s and marks the local task `T-4417` as `working` *optimistically* with a `pendingAck` flag. 4. Caller's retry supervisor fires `tasks/resend` with the identical envelope (same `taskId`, same `messageId: M-88`). 5. Remote agent's dedup layer keys on `messageId`. Here is the fork point: the reference implementation's dedup table had a **TTL of 60s** and the resend arrived at 61s (30s client timeout + 31s backoff jitter). Dedup miss. Remote treats it as a fresh continuation, transitions `working` → `working` (self-transition, allowed), and **re-enqueues the tool call**. 6. Meanwhile the original tool call from step 2 completes, remote transitions `working` → `completed`, writes artifact `A-1`, emits `TaskStatusUpdateEvent{state: completed}`. 7. The re-enqueued tool call from step 5 also completes, remote attempts `completed` → `completed`. Absorbing state, no-op on state, but **artifact `A-2` is written** — a duplicate side effect with a distinct `artifactId`. 8. Caller, having received the step-6 SSE event, sets local `T-4417` = `completed`. Caller then receives the step-5 HTTP response (a fresh `Task` object showing `working`, because the remote serialized the response *before* step 6 landed) and, per its reconciliation rule "last write wins on synchronous response," **overwrites local state back to `working`**. 9. Caller now polls `tasks/get` → remote reports `completed`. Caller's SSE handler already closed the stream on the first `completed` event. Caller's local object oscillates and finally settles on `working` because the last-applied write was the stale synchronous response. Net result: caller local state = `working` (forever, since no further events), remote state = `completed`, remote artifact store has two artifacts (`A-1`, `A-2`), and the caller will eventually re-issue `tasks/resend` again, driving a third execution. The fork is fully silent: every individual message is schema-valid, every state transition is in the allowed set, and no error is raised anywhere. The structural signals that flagged it in the test harness were **not** state mismatches (those are expected transiently) but three co-occurring invariants: - **Artifact cardinality drift:** remote artifact count for `T-4417` exceeded the caller's recorded `expectedArtifacts` for the task's declared capability schema. - **`messageId` re-execution:** the remote's execution log showed the same `messageId: M-88` bound to two distinct tool-execution spans with non-overlapping start times. - **Terminal-write ordering inversion:** the caller applied a `working` write *after* having applied a `completed` write for the same `taskId`, with no intervening `tasks/get` reconciliation in between. ## Condition of Validity The fork is bounded (i.e., cannot occur) only when **all three** of the following hold simultaneously: 1. **Dedup horizon ≥ resend horizon.** The remote agent's `messageId` dedup window must strictly exceed the caller's maximum `(request timeout + max backoff + jitter)`. If dedup TTL < resend horizon, replay becomes re-execution. The spec does not mandate a dedup TTL, so this is a negotiated capability, not a protocol guarantee. 2. **Monotonic terminal precedence on the caller.** The caller must treat terminal states as absorbing *locally* — once it observes `completed` for a `taskId`, no subsequent non-terminal write (including a stale synchronous response) may downgrade it. The spec defines terminal states as absorbing on the *remote*; it says nothing about caller-side write ordering. This is the invariant most implementations miss. 3. **Artifact idempotency keyed on `(taskId, messageId, artifactSlot)`.** The remote must refuse to write a second artifact into the same logical slot for the same originating `messageId`. A2A v1.0 artifacts carry `artifactId` but the spec does not require them to be derived from the originating message — so duplicates are conformant unless the agent enforces slot idempotency itself. When any one fails, the fork is reachable. In the observed trace, all three failed. ## Decision Boundary The operational line is this: **a `tasks/resend` is safe to issue unconditionally only for tasks whose current state is non-terminal *and* whose last known transition was caller-initiated.** If the last observed remote transition was remote-initiated (i.e., the caller learned of it via SSE or a prior `tasks/get`), then a resend is a *state-mutating* operation against an unknown-advanced state and must be gated. Concretely, the caller-side gate before any `tasks/resend`: - If local state is terminal → **do not resend.** Instead issue `tasks/get` to confirm; if remote disagrees, raise a fork alarm rather than resending. - If local state is non-terminal but the last applied write was a *stale synchronous response* (response `timestamp` < last SSE event `timestamp`) → **do not resend.** Issue `tasks/get`, reconcile, and only resend if remote confirms the original envelope was not processed (remote returns a `Task` whose `history` lacks the `messageId`). - If local state is non-terminal and last write was caller-initiated with `pendingAck` → resend is safe *provided* dedup horizon check passes. The boundary is not "did the request time out" — it is "**what is the provenance of the caller's current state belief.**" A timeout tells you the ACK was lost. It does not tell you the request was lost, and conflating the two is the entire failure. ## Operational Effect Downstream of an undetected fork, three compounding effects appear: - **Duplicate side effects.** Because artifacts are not slot-idempotent by default, a forked `completed` task can emit N artifacts for one logical request. Consumers reading the artifact list see N results and must deduplicate on semantic content, not on `artifactId`. - **Zombie tasks.** The caller's local `working` state never resolves because the SSE stream closed on the first terminal event and the caller's reconciliation rule prefers the stale synchronous write. The task is terminal remotely, immortal locally. This leaks task handles and, in multi-agent swarms, holds baton-pass locks indefinitely. - **Cascading resends.** A zombie caller will resend on its retry schedule, each resend re-entering the dedup-miss path if the horizon is still exceeded, driving unbounded re-execution against a completed task. The guardrail that bounds this is a **three-way reconciliation invariant** enforced caller-side: `localState == remoteState` must be re-established by `tasks/get` after *any* write whose provenance is ambiguous, and terminal states must be locally absorbing. The remote side must enforce **dedup horizon ≥ max resend horizon** as a published capability in its Agent Card (`capabilities.taskDeduplicationWindowSeconds`), so the caller can compute whether resend is safe before issuing it. Without both, the fork is not a bug in any single message — it is a structural gap in the lifecycle contract that conformance testing must probe explicitly. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Literal TERMINAL_STATES = frozenset({"completed", "failed", "canceled", "rejected"}) class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" REJECTED = "rejected" class SilentForkError(RuntimeError): """Raised when caller-local and remote task state have forked undetected.""" @dataclass class WriteProvenance: source: Literal["sse", "sync_response", "tasks_get", "caller_initiated"] timestamp_ms: int message_id: str | None = None @dataclass class LocalTask: task_id: str state: TaskState last_write: WriteProvenance pending_ack: bool = False artifacts_seen: set[str] = field(default_factory=set) @dataclass class RemoteTask: task_id: str state: TaskState dedup_window_s: int executed_message_ids: dict[str, list[int]] # messageId -> [start_ms, ...] artifact_ids: list[str] def assert_resend_safe( local: LocalTask, remote: RemoteTask, resend_horizon_s: int, now_ms: int, ) -> None: """ Gate a tasks/resend. Raises SilentForkError if issuing the resend would risk re-executing an already-processed envelope against an advanced remote state. """ # Invariant 1: terminal states are locally absorbing. if local.state in TERMINAL_STATES: if remote.state != local.state: raise SilentForkError( f"terminal divergence on {local.task_id}: " f"local={local.state.value} remote={remote.state.value}" ) raise SilentForkError( f"refusing resend on terminal task {local.task_id}; " f"issue tasks/get to confirm instead" ) # Invariant 2: do not resend over a stale synchronous write. if ( local.last_write.source == "sync_response" and not local.pending_ack ): raise SilentForkError( f"resend on {local.task_id} would apply intent against " f"unknown-advanced state; last write was stale sync_response" ) # Invariant 3: dedup horizon must strictly exceed resend horizon. if remote.dedup_window_s < resend_horizon_s: raise SilentForkError( f"dedup window {remote.dedup_window_s}s < resend horizon " f"{resend_horizon_s}s on {local.task_id}; replay becomes re-execution" ) # Invariant 4: the envelope's messageId must not already be executing. mid = local.last_write.message_id if mid and mid in remote.executed_message_ids: starts = remote.executed_message_ids[mid] if len(starts) >= 1 and (now_ms - starts[-1]) > remote.dedup_window_s * 1000: raise SilentForkError( f"messageId {mid} already executed at {starts}; " f"dedup expired, resend would re-execute" ) # Invariant 5: artifact cardinality must not have drifted. if len(remote.artifact_ids) > len(local.artifacts_seen): raise SilentForkError( f"artifact cardinality drift on {local.task_id}: " f"remote={len(remote.artifact_ids)} local={len(local.artifacts_seen)}" ) ```