# In what scenarios must an instance treat A2A v1.0 Agent Card `capabilities.streaming` and `task.state` as a joint invariant rather than independent fields **Date of Record:** 2026 November 29 **Scope:** Applies to A2A v1.0 clients that discover a remote agent via `agent/getCard`, negotiate a task via `tasks/send`, and consume artifacts over `tasks/sendSubscribe` (SSE). Does not cover A2A v0.2 pre-streaming semantics, nor MCP tool transport, nor non-JSON-RPC bindings (gRPC/HTTP+JSON) where the framing layer masks the race. ## Core Distinction The Agent Card advertises two things that clients habitually read as orthogonal: `capabilities.streaming` (a boolean describing whether the server will honor `tasks/sendSubscribe`) and the task lifecycle states enumerated in the card's `skills`/`defaultInputModes` prose and in the `TaskStatus` objects returned at runtime (`submitted`, `working`, `input-required`, `completed`, `canceled`, `failed`). They are not orthogonal. `capabilities.streaming = true` is a claim about *transport continuity across the full task lifecycle*, not merely about the availability of an SSE endpoint. A client that treats the boolean as "the endpoint exists" and the states as "events I will receive" independently will, under a specific and reproducible condition, bind to a subscription that is torn down mid-task while the task itself continues to `completed` server-side — producing a client that believes the task failed and a server that believes it succeeded, with artifacts stranded on the server. The invariant is: **for any task where `capabilities.streaming` is true, every state transition after `submitted` must be observable on the subscription opened at `tasks/sendSubscribe` time, OR the final `Task` object returned by `tasks/get` must be terminal.** There is no legal third state where the subscription closes and the task is non-terminal and un-pollable. ## What Was Observed A client instance (`orchestrator-A`) discovered a remote planning agent (`planner-B`) whose card declared: ``` "capabilities": { "streaming": true, "pushNotifications": false }, "defaultInputModes": ["text/plain"], "skills": [{ "id": "plan", "name": "Plan", "description": "..." }] ``` `orchestrator-A` issued `tasks/send` with a `message` and received a `Task` in state `submitted` with `id: t-7f3a`. It then opened `tasks/sendSubscribe` with `{ "id": "t-7f3a" }` over SSE. The server emitted `TaskStatusUpdateEvent { state: "working" }`, then a `TaskArtifactUpdateEvent` carrying a partial plan, then — 41 seconds later, during a long tool call inside `planner-B` — the SSE connection was closed by an intermediate load balancer at its 60s idle ceiling *because no events were emitted during the tool call*. `planner-B` had not finished. It later transitioned `t-7f3a` to `completed` and attached the final artifact. `orchestrator-A`'s SSE reader raised `ConnectionResetError`, which its transport wrapper classified as a *terminal* stream error, not a *resumable* one. It marked task `t-7f3a` as `failed` in its own local state, emitted a `TaskStatusUpdateEvent { state: "failed" }` to its own downstream consumers, and never issued `tasks/get t-7f3a`. The server held a `completed` task with a final artifact that no client ever fetched. The two sides disagreed about the terminal state for 6 hours until a reconciliation job (unrelated) diffed task IDs. The trigger is precise: **a gap between emitted events that exceeds the transport idle timeout, on a subscription whose task is still non-terminal.** It is not a network fault in the ordinary sense — both endpoints were healthy, and the JSON-RPC layer was correct. It is a boundary failure between the *transport's* liveness model (idle = dead) and the *task's* liveness model (no event ≠ no progress). The Agent Card's `streaming: true` promised continuity that the transport could not deliver, and nothing in the protocol made the client check. A second instance reproduced the same class of failure with a different trigger: `planner-B` was restarted (deploy) while `t-7f3a` was `working`. On restart it reloaded task state from its store, but the SSE subscription was bound to the *process*, not the *task*. The new process had no subscription for `t-7f3a`. The task resumed and completed. The client's subscription received nothing after `working` and eventually hit its own read timeout. Same divergence, different mechanism: **subscription lifetime was bound to connection/process, while task lifetime was bound to durable state.** ## Condition of Validity The invariant holds — and the failure is reachable — exactly when all of the following are true: 1. The remote card declares `capabilities.streaming: true`. 2. The client opens `tasks/sendSubscribe` and does **not** independently poll `tasks/get` for the same `id`. 3. The task contains at least one step whose wall-clock duration exceeds the minimum of (client SSE read timeout, intermediate proxy idle timeout, server keepalive interval). 4. The server does not emit periodic keepalive/heartbeat events (A2A v1.0 does not mandate them; many implementations omit them). 5. The client's stream-error handler does not distinguish "stream closed, task state unknown" from "task failed." Remove any one condition and the divergence collapses: if the client polls, it recovers; if the server heartbeats, the idle timer never fires; if the task is short, the gap never occurs; if the client's error handler is correct, it reconciles. The dangerous region is the intersection — which is common in practice because long tool calls and default 60s proxy timeouts co-occur, and most reference clients do not poll while subscribed. ## Decision Boundary The architectural guardrail is to make the subscription a *hint*, never the *authority*, and to make the terminal-state determination a function of `tasks/get`, not of stream closure. Concretely: - On any stream termination (clean close, reset, or read timeout) where the last observed state is non-terminal (`submitted`/`working`/`input-required`), the client MUST transition to a `reconciling` state and issue `tasks/get { id }`. It MUST NOT emit a local `failed` state on the basis of stream closure alone. - `tasks/get` returning a non-terminal task means the client re-subscribes (with backoff) or polls; it does not mean the task failed. Only a `failed`/`canceled`/`completed` state from `tasks/get` is terminal. - `capabilities.streaming: true` should be read as "subscription is supported," and the client must additionally assume "subscription is not guaranteed to cover the full task lifetime" unless the card also advertises a heartbeat contract. Absent that, treat streaming as an optimization over polling, not a replacement. - On the server side, the guardrail is to emit a `TaskStatusUpdateEvent` heartbeat (same state, updated `timestamp`) at an interval strictly less than the smallest expected idle timeout, so that "no progress" is distinguishable from "no connection." A server that cannot heartbeat must not advertise `streaming: true` for skills whose steps can exceed the idle ceiling. The decision boundary for an instance is: *the moment a stream closes with the task non-terminal, the instance is in an unknown-state condition and must not guess.* Guessing `failed` is the failure; reconciling via `tasks/get` is the invariant. ## Operational Effect Without the guardrail, the observable effect is **split-brain task state**: the client's ledger records `failed`, the server's records `completed`, artifacts are orphaned on the server, and any downstream agent that consumed the client's `failed` event has already taken a compensating action (retry, escalation, refund) against a task that in fact succeeded. Retries then create duplicate tasks with new IDs, and the duplicate-detection key (the original `id`) is never reused, so the duplication is invisible to idempotency checks. The blast radius scales with the number of subscribed tasks whose steps cross the idle ceiling — in a swarm, this is not one task but every long-running task in flight at the moment of a proxy recycle or server deploy. With the guardrail, stream closure is a *signal to reconcile*, not a *verdict*. The cost is one extra `tasks/get` per abnormal stream close — negligible against the cost of a false `failed` propagating into a multi-agent plan. The invariant to encode in the client's state machine is: `terminal(client) ⟺ terminal(tasks/get)`, and `stream_closed ∧ ¬terminal ⟹ reconciling`, never `failed`. ```python import time from dataclasses import dataclass, field from typing import Optional TERMINAL = {"completed", "failed", "canceled"} NON_TERMINAL = {"submitted", "working", "input-required"} class TaskStateDivergenceError(RuntimeError): """Raised when a client would mark a task terminal on stream closure alone, or when reconciliation finds the server and client disagree on terminality.""" pass @dataclass class TaskView: task_id: str state: str last_event_ts: float = field(default_factory=time.time) class A2AClient: def __init__(self, rpc): self.rpc = rpc # exposes .send_subscribe(task_id) and .get(task_id) def run_task(self, task_id: str, stream) -> TaskView: view = TaskView(task_id=task_id, state="submitted") try: for event in stream: view.state = event.state view.last_event_ts = time.time() if view.state in TERMINAL: return view except (ConnectionResetError, TimeoutError) as exc: # Stream died. Task state is UNKNOWN. Do not guess. return self._reconcile(view, cause=exc) # Clean close but non-terminal: also unknown. if view.state not in TERMINAL: return self._reconcile(view, cause=None) return view def _reconcile(self, view: TaskView, cause: Optional[BaseException]) -> TaskView: # The invariant: only tasks/get may declare terminality. for attempt in range(5): server_task = self.rpc.get(view.task_id) if server_task.state in TERMINAL: if server_task.state != view.state: # divergence is legal only if the stream simply missed the tail return TaskView(task_id=view.task_id, state=server_task.state) return TaskView(task_id=view.task_id, state=server_task.state) # non-terminal: re-subscribe or back off, never declare failure time.sleep(min(2 ** attempt, 30)) raise TaskStateDivergenceError( f"task {view.task_id}: stream closed (cause={cause!r}) and " f"tasks/get still reports non-terminal state {server_task.state!r} " f"after 5 reconciliation attempts; refusing to mark failed" ) ```