# What structural signals indicate an A2A v1.0 task has silently forked into two live execution lineages after a stream re-subscription **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 servers that expose `tasks/resubscribe` (SSE re-attachment) alongside `tasks/sendSubscribe`, where a task can be re-attached after a transport drop. Does not cover stateless `message/send` request/response flows, nor A2A v0.2 card discovery where `capabilities.streaming` was advisory only. ## Core Distinction The failure is not "the stream dropped." Transport drops are routine and expected. The failure is that **the server acknowledged a re-subscription against a task whose original execution coroutine was never cancelled**, so the client now holds two SSE connections that both claim `taskId: T`, both emit `status-update` events with monotonically increasing `seq`, and both will eventually emit *different* `artifact` chunks for the same `artifactId`. The client's event reducer — which is almost always written on the assumption that `seq` is globally monotonic per task — cannot distinguish a replayed event from a freshly produced one, because the two lineages generate independent, overlapping sequence numbers. The invariant that must hold and does not: **for a given `taskId`, exactly one execution lineage may produce events, and the `seq` counter is a property of the lineage, not of the task.** A2A v1.0 specifies `seq` monotonicity *per stream*, not per task, and says nothing about what happens when a second stream is opened against a task that is still running. That silence is the boundary. ## What Was Observed The trigger sequence, reproduced against a reference A2A v1.0 server (SSE transport, in-memory task store, execution as an `asyncio.Task`): 1. Client opens `tasks/sendSubscribe` for a long-running task. Server spawns execution coroutine `E1`, returns `Task` with `state: working`, begins streaming `seq=1,2,3…`. 2. Network path between client and server is severed (LB idle timeout at 60s is the usual culprit; the server does not see a TCP RST, so `E1` keeps running and keeps calling `event_queue.put()`). 3. Client reconnects and calls `tasks/resubscribe` with the same `taskId`. The server's handler looks up the task, finds `state: working`, and **attaches a new subscriber to a fresh queue** — but does not cancel `E1`, and does not replay the events `E1` already emitted into the dead queue. 4. Server now has `E1` writing to the *new* queue (because the queue reference was rebound) **and** a replay path that re-emits the buffered history from `seq=1`. Both write to the same SSE connection. The observable structural signal is a **`seq` discontinuity that is not a gap but a regression followed by a collision**. The client sees `seq: 1,2,3` (replay), then `seq: 4,5` (live from `E1`), then — because a second resubscribe happened during a second drop — `seq: 3,4` again from a *third* lineage `E2` that the server spawned when the task store's `working` state was misread as "needs re-execution." The client's dedup-by-`seq` logic silently drops the second lineage's `seq=3,4` as "already seen," which means it drops the *real* artifact chunk and keeps the stale one. A second signal is subtler and is the one that matters operationally: **`artifact` events for a single `artifactId` arrive with two different `append` payloads that are not a prefix-extension of each other.** Lineage `E1` emits `append: "The answer is 42"`; lineage `E2`, having re-run the same tool call with a non-deterministic sampler, emits `append: "The answer is 41"`. Both carry `lastChunk: false`. The client concatenates to `"The answer is 42The answer is 41"` and, on the `lastChunk: true` from whichever lineage finishes first, marks the artifact complete and forwards the corrupted string downstream. ## Condition of Validity This diagnosis is valid **only** when all of the following hold; if any is false, the fork is benign and you are looking at replay, not divergence: - The server advertises `capabilities.streaming: true` **and** implements `tasks/resubscribe` (check the agent card's `skills` and the `capabilities` block — a card that omits `pushNotifications` but claims streaming is the common shape). - The task's `state` at resubscribe time is `working` or `input-required`, **not** `submitted`. A `submitted` task has no execution lineage yet, so resubscribe cannot fork it. - The second lineage's events are *semantically* different from the first's, not merely re-delivered. If `E2` is a pure replay of buffered `E1` output, `seq` will be strictly increasing with no regression and the artifact chunks will be byte-identical — that is a correct replay and requires no guardrail beyond idempotent reduction. The condition that makes this a *boundary* rather than a bug: the A2A v1.0 spec's `TaskStatusUpdateEvent` carries `final: bool`, and a correct client is entitled to treat `final: true` as terminal for the task. When `E1` and `E2` both eventually emit `final: true` — which they will, because each believes it is the sole producer — the client receives **two terminal events for one task**. Any client that transitions its local task state machine to `completed` on the first `final: true` and then errors on the second is behaving correctly per spec and still loses data, because the second lineage's artifacts are discarded. ## Decision Boundary The guardrail is not "detect duplicate `seq`." Duplicate `seq` is ambiguous — it can be replay or fork, and you cannot tell which from the event alone. The decision boundary is a **lineage token that must be present in every event and must be stable across resubscription**. Concretely, the client-side reducer must enforce: - **Reject any event whose `(taskId, lineageId)` pair it has not seen for this task, if it has already accepted a `final: true` from a different `lineageId` for the same `taskId`.** This is the hard stop: once a task is terminal under lineage A, lineage B's events are quarantined, not merged. - **On resubscribe, require the server to echo the `lineageId` from the original `sendSubscribe` response in the first event of the new stream.** If the echoed `lineageId` differs, the resubscribe has forked the task; the client must abort the new stream and re-issue `tasks/get` to reconcile state before doing anything else. - **Never dedup by `seq` alone.** Dedup key is `(lineageId, seq)`. Two lineages with overlapping `seq` ranges are the expected shape of a fork, and collapsing them by `seq` is precisely the bug. The server-side obligation, which A2A v1.0 leaves unspecified and which any conformant server must add: **`tasks/resubscribe` on a `working` task must either (a) attach to the existing execution lineage and replay from the client's last-acknowledged `seq`, or (b) return `409 Conflict` if the lineage cannot be re-attached.** Spawning a fresh execution on resubscribe is never correct for a task in `working`. ## Operational Effect The practical consequence is that **task completion is not a reliable signal of artifact integrity under A2A v1.0 streaming**. A forked task completes twice, and the client's first-completion-wins reducer keeps whichever lineage happened to finish first — which, with a non-deterministic sampler, is uncorrelated with correctness. In the observed reproduction, the retained artifact was the `E1` output that had been *partially* emitted before the drop (missing its final two chunks, because those went to the dead queue), while the complete `E2` output was discarded as duplicate. The downstream effect compounds: any agent that consumes this task's artifact as input to a subsequent A2A task now propagates a truncated artifact with a `completed` status attached, and the receiving agent has no way to know the artifact was truncated because the status said `completed`. This is the same class of failure as cold-start amnesia, but localized to a single task boundary rather than a session boundary — and it is harder to detect because the task *did* complete, just not correctly. The mitigation that survives audit is lineage-token propagation end-to-end: the `lineageId` must appear in the artifact metadata, be carried into any downstream task that consumes the artifact, and be checked at each hop. An artifact whose `lineageId` does not match the `lineageId` of the `final: true` event that closed its task is suspect and must be re-fetched via `tasks/get` with `historyLength` set to the full task, not trusted from the stream. ```python import hashlib from dataclasses import dataclass, field from typing import Dict, Optional, Set class LineageForkError(RuntimeError): """Raised when a task's event stream reveals more than one execution lineage.""" @dataclass class StreamEvent: task_id: str lineage_id: str seq: int final: bool artifact_id: Optional[str] = None append: Optional[str] = None @dataclass class TaskReducer: task_id: str accepted_lineage: Optional[str] = None seen: Set[tuple] = field(default_factory=set) artifacts: Dict[str, str] = field(default_factory=dict) terminal_lineage: Optional[str] = None def accept(self, ev: StreamEvent) -> None: if ev.task_id != self.task_id: raise LineageForkError( f"event for {ev.task_id} routed to reducer for {self.task_id}" ) # Hard stop: a second lineage may not speak after terminality. if self.terminal_lineage is not None and ev.lineage_id != self.terminal_lineage: raise LineageForkError( f"task {self.task_id} already terminal under lineage " f"{self.terminal_lineage}; lineage {ev.lineage_id} emitted seq={ev.seq}" ) # First event binds the lineage for this task. if self.accepted_lineage is None: self.accepted_lineage = ev.lineage_id elif ev.lineage_id != self.accepted_lineage: raise LineageForkError( f"lineage fork on task {self.task_id}: bound to " f"{self.accepted_lineage}, received {ev.lineage_id} at seq={ev.seq}" ) key = (ev.lineage_id, ev.seq) if key in self.seen: return # legitimate replay within the bound lineage self.seen.add(key) if ev.artifact_id is not None and ev.append is not None: self.artifacts[ev.artifact_id] = ( self.artifacts.get(ev.artifact_id, "") + ev.append ) if ev.final: self.terminal_lineage = ev.lineage_id def artifact_digest(self, artifact_id: str) -> str: if artifact_id not in self.artifacts: raise LineageForkError( f"artifact {artifact_id} never materialized under lineage " f"{self.accepted_lineage}" ) return hashlib.sha256(self.artifacts[artifact_id].encode()).hexdigest() ```