# How should an instance enforce Agent Card capability monotonicity when A2A v1.0 discovery returns a card whose advertised `capabilities.streaming` flag flips between `true` and `false` across vendor-side cache layers **Date of Record:** 2026 December 3 **Scope:** Applies to any A2A v1.0 client that performs Agent Card discovery against a remote runtime, caches the card locally, and then opens a `tasks/sendSubscribe` (SSE) stream for artifact delivery. Does not apply to single-vendor deployments where card and task endpoints share one origin, one cache, and one signing key, nor to pure request/response (`tasks/send`) callers that never consume streamed artifacts. ## Core Distinction There are two classes of Agent Card inconsistency, and conflating them is the root of the failure. The first is **capability inconsistency**: the remote runtime genuinely cannot stream, and its card correctly says `capabilities.streaming = false`. A client that respects this is fine. A client that ignores it gets a clean HTTP 405 or an `UnsupportedOperation` error from `tasks/sendSubscribe` — a loud, synchronous, recoverable failure. The second is **capability monotonicity violation across cache layers**: the remote runtime *can* stream, and its authoritative card says `streaming = true`, but an intermediate cache (vendor CDN edge, an aggregator's discovery proxy, a local registry mirror) is serving a *stale or divergent* card that says `streaming = false` — or vice versa. This is the non-obvious case. The client negotiates against a card that no longer describes the endpoint it will actually talk to. Because A2A discovery (`GET /.well-known/agent.json`) and task submission (`POST /v1/tasks/sendSubscribe`) are *separate HTTP transactions that can be routed to different cache states*, a client can read `streaming=false` from one edge and then stream successfully against another, or read `streaming=true` and then receive a non-streaming `application/json` body where it expected `text/event-stream`. The invariant that must hold is **capability monotonicity**: once a client has observed a card asserting a capability, the *effective* capability of the endpoint it subsequently calls must be a superset of what the card promised for the duration of that task. The card is a warrant; the stream is the execution. A2A v1.0 does not bind them cryptographically or temporally, so the client must. ## What Was Observed A three-vendor chain: client `C` (vendor A), discovery proxy `P` (vendor B, an "agent directory" that mirrors cards with a 300 s TTL), and executor `E` (vendor C). `E` publishes a card with `capabilities.streaming = true` and `capabilities.pushNotifications = false`. `P` caches it. At T+0, `E` performs a rolling deploy that briefly disables SSE (draining connections) and — critically — *republishes its card with `streaming = false` for the drain window*, then flips it back to `true` at T+90 s. This is a legitimate, spec-compliant behavior: the card is supposed to describe current capability. `C` resolves discovery through `P`. At T+40 s (mid-drain), `C` fetches the card and gets a **stale cache hit from `P`** still asserting `streaming = true` (because `P`'s 300 s TTL had not expired and `E`'s card ETag changed but `P` was configured to serve-stale-on-revalidate-error). `C` caches `streaming = true`, opens `tasks/sendSubscribe` directly against `E`. The state trace: 1. `C` → `P`: `GET /.well-known/agent.json` → 200, `streaming: true`, `ETag: "v7"`, `Age: 260`. 2. `C` validates card, stores `(endpoint=E, streaming=true, etag=v7, observed_at=T+40)`. 3. `C` → `E`: `POST /v1/tasks/sendSubscribe` with `Accept: text/event-stream`. 4. `E` is mid-drain: SSE handler is down, but the task *is accepted*. `E` responds `200 OK` with `Content-Type: application/json` and a full `Task` object in `state: "working"` — **not** an event stream. `E` does not return 405 because the task submission path is separate from the stream path and the fallback serializer wins. 5. `C`'s SSE parser receives a JSON body with no `data:` framing. Depending on the client, it either (a) blocks forever waiting for the first event, (b) parses zero events and treats the task as silently stalled, or (c) throws a `ContentTypeError` and — the dangerous path — retries `sendSubscribe` against a *different* resolved endpoint from `P`'s load-balancer set, landing on a healthy replica that *does* stream, producing a **duplicate task** because the first `200 OK` already created task `t-8817`. The duplicate-task branch is the real damage. The client observed a card warrant (`streaming=true`), got a non-streaming success, and — because A2A `Task.id` is server-assigned and the client cannot know whether the first response created a task — retried into a second task `t-8818`. Both tasks run to completion against the same downstream tool, and the client now has two artifacts for one logical request. A second observed variant: `P` served `streaming = false` (stale *negative*) while `E` was fully healthy. `C`, respecting the card, downgraded to `tasks/send` polling. It worked, but the client silently lost streaming artifact delivery for 300 s — a **capability regression under stale cache** that is invisible in logs because polling succeeded. ## Condition of Validity The monotonicity guard is required whenever **all three** hold: - Discovery and task endpoints are resolved through **at least one cache layer not under the client's control** (CDN, directory proxy, registry mirror). Direct-to-origin discovery makes the card and the endpoint share a cache state and the failure collapses to the loud case. - The card's `capabilities.streaming` (or `pushNotifications`) can **change during the lifetime of a client-cached card** — i.e., the remote runtime does rolling deploys, canary capability gating, or per-tenant capability flags. - The client **retries or re-resolves on transport-level anomalies** (unexpected `Content-Type`, empty stream, timeout before first event) rather than only on explicit task-state transitions. It does **not** apply when the client pins a single resolved endpoint for the task's lifetime and treats any content-type mismatch as a terminal, non-retryable error — in that configuration the failure is loud and bounded. ## Decision Boundary The client must draw a hard line between **warrant observation** and **warrant use**, and must never let a retry cross that line without re-establishing the warrant. Concretely, the boundary is: *a card observed at time `t` with ETag `e` warrants capability `k` only for the first `sendSubscribe` attempt against the endpoint resolved at `t`. Any retry, any endpoint re-resolution, and any content-type mismatch invalidates the warrant and forces a re-fetch of the card through the same cache path with `Cache-Control: no-cache` (or an ETag-conditional request that the proxy must honor).* Two guards enforce the boundary: 1. **Content-type is part of the capability contract.** If the card warrants `streaming=true` and the response to `sendSubscribe` is `application/json` (a `Task` body) rather than `text/event-stream`, the client must treat this as a *capability violation*, not a valid response. It must **not** parse the JSON as a completed task and must **not** retry. It must abort, mark the task id (if present in the body) as *poisoned* — because the server may have created it — and re-fetch the card before any further submission. This is the single most important guard: the non-streaming 200 is the trap, because it looks like success. 2. **Task-id deduplication key must be client-supplied.** A2A v1.0 permits the client to send a `messageId`; the client must reuse the *same* `messageId` across retries so the executor can dedupe. But because `E` in the observed trace did not dedupe on `messageId` (vendor C's implementation treated it as advisory), the client must additionally maintain a local `(endpoint, messageId) → task_id` map and refuse to open a second `sendSubscribe` for a `messageId` that already produced a `200` of any content type. The map entry is only cleared on an explicit terminal task state. The boundary condition — the exact line the client must not cross — is: **retrying `sendSubscribe` after receiving any 2xx response, regardless of content type, without first confirming via `tasks/get` whether a task was created.** The 2xx is the signal that the server accepted the submission; the content type only tells you *how* it will deliver, not *whether* it accepted. ## Operational Effect With the guard in place, the T+40 s drain produces: card fetched through `P` (stale, `streaming=true`), `sendSubscribe` returns `200 application/json` with `task.id=t-8817`, client detects content-type/capability mismatch, aborts streaming, records `t-8817` as created-but-unstreamed, issues `tasks/get t-8817` to confirm state, and either polls to completion or — if the card re-fetch now shows `streaming=false` — degrades to polling for this task only. No duplicate task. No silent stall. The capability regression is logged as a `CapabilityWarrantViolation` with the stale `Age` header attached, which is the diagnostic that tells an operator *which cache layer* served the bad card. The cost is one extra `tasks/get` per content-type mismatch and a local dedupe map that must be persisted across client restarts (or the cold-start amnesia reintroduces the duplicate-task race on the next process). The benefit is that the client's behavior is now a function of the *endpoint's actual behavior* rather than a possibly-stale proxy's assertion about it — which is the only thing the client can actually verify. ```python from __future__ import annotations import time from dataclasses import dataclass, field from typing import Literal class CapabilityWarrantViolation(RuntimeError): """Raised when the endpoint's observed behavior contradicts the Agent Card warrant.""" class DuplicateTaskSubmission(RuntimeError): """Raised when a retry would create a second task for an already-accepted messageId.""" @dataclass(frozen=True) class AgentCardWarrant: endpoint: str streaming: bool etag: str observed_at: float age_header: int | None = None @dataclass class TaskLedger: """Client-side dedupe map: (endpoint, messageId) -> task_id, persisted across restarts.""" _entries: dict[tuple[str, str], str] = field(default_factory=dict) def record(self, endpoint: str, message_id: str, task_id: str) -> None: key = (endpoint, message_id) if key in self._entries and self._entries[key] != task_id: raise DuplicateTaskSubmission( f"messageId {message_id} already produced task {self._entries[key]}, " f"refusing to bind second task {task_id}" ) self._entries[key] = task_id def lookup(self, endpoint: str, message_id: str) -> str | None: return self._entries.get((endpoint, message_id)) def submit_streaming_task( warrant: AgentCardWarrant, message_id: str, ledger: TaskLedger, *, post_send_subscribe, # returns (status_code, content_type, body_dict) refetch_card, # returns fresh AgentCardWarrant now: float | None = None, ) -> Literal["streaming", "degraded_poll", "aborted"]: now = time.monotonic() if now is None else now if not warrant.streaming: # Card says no streaming; do not attempt SSE at all. return "degraded_poll" prior = ledger.lookup(warrant.endpoint, message_id) if prior is not None: raise DuplicateTaskSubmission( f"messageId {message_id} already accepted as task {prior}; " f"retry blocked before sendSubscribe" ) status, content_type, body = post_send_subscribe(warrant.endpoint, message_id) if status >= 400: # Loud failure: capability genuinely absent or endpoint error. Safe to re-fetch and retry. fresh = refetch_card(warrant.endpoint) if fresh.streaming: raise CapabilityWarrantViolation( f"endpoint {warrant.endpoint} returned {status} but fresh card still warrants streaming" ) return "degraded_poll" if status == 200 and content_type.startswith("text/event-stream"): task_id = body.get("task", {}).get("id") if task_id: ledger.record(warrant.endpoint, message_id, task_id) return "streaming" # The trap: 2xx with non-streaming content type. The server ACCEPTED the task. task_id = body.get("id") or body.get("task", {}).get("id") if task_id: ledger.record(warrant.endpoint, message_id, task_id) fresh = refetch_card(warrant.endpoint) if fresh.streaming and fresh.etag != warrant.etag: raise CapabilityWarrantViolation( f"card warrant etag={warrant.etag} age={warrant.age_header} promised streaming, " f"endpoint delivered {content_type!r} for task {task_id}; " f"fresh card etag={fresh.etag} streaming={fresh.streaming} — " f"stale cache layer suspected, do NOT retry sendSubscribe" ) if task_id is None: raise CapabilityWarrantViolation( f"2xx with {content_type!r} and no task id; cannot confirm acceptance, aborting" ) return "degraded_poll" ```