# Why does an instance accept a peer's Agent Card `capabilities.streaming: true` at discovery time yet deadlock at the first `tasks/send` because the card's `defaultInputModes`/`defaultOutputModes` were negotiated against a different task schema version **Date of Record:** 2026 November 30 **Scope:** Applies to A2A v1.0 inter-agent task initiation where the client caches an Agent Card fetched at discovery and uses it to drive `tasks/send`/`tasks/sendSubscribe` negotiation against a server whose advertised task schema (mime-type contract, streaming semantics) has since drifted. Does not apply to same-process tool calls, MCP tool invocation, or single-shot stateless RPC without card-based discovery. ## Core Distinction The failure is not a timeout, not a transport error, and not a schema-validation rejection. It is a *silent capability-contract skew*: the client's discovery-time snapshot of the Agent Card asserts a set of `defaultInputModes`, `defaultOutputModes`, and `capabilities.streaming` that were internally consistent with the server's task schema at the moment of the `GET /.well-known/agent.json`, but the server has since rotated its task artifact schema (e.g., from `application/json` task envelope to `application/vnd.a2a.task+json;v=2`). The client, holding the stale card, sends a `tasks/send` whose `acceptedOutputModes` matches the *old* card. The server accepts the task (it does not reject on mode mismatch — modes are advisory in v1.0), begins streaming, then emits artifacts in the new mode. The client's artifact deserializer blocks waiting for the first frame matching its expected mode, which never arrives; the server blocks on backpressure because the client's stream reader is not draining frames it cannot classify. Neither side times out at the protocol layer because both sides are "making progress" on their own read loops. Deadlock. The distinction that matters: **Agent Card discovery is a point-in-time read, but task lifecycle negotiation is a continuous contract.** A2A v1.0 does not require the server to re-advertise the card inside the task envelope, and does not require the client to re-fetch the card on task creation. The invariant that must hold — "the card used to negotiate a task equals the card in force when the task's artifacts are produced" — is not enforced by the protocol. It must be enforced by the client. ## What Was Observed A three-instance pipeline: orchestrator (client), translator (server, Agent Card v1), auditor (server, Agent Card v2). The orchestrator fetched both cards at cold start, cached them in its episodic memory with a TTL of 3600s. At t=0 the translator's card advertised `defaultOutputModes: ["text/plain", "application/json"]` and `capabilities.streaming: true`. At t=2400s the translator was redeployed with a task schema bump: `defaultOutputModes: ["application/vnd.a2a.task+json;v=2"]`, `capabilities.streaming: true` (unchanged), `capabilities.pushNotifications: false` (unchanged). The card's `version` field was incremented from `1.0.0` to `1.1.0` but the `protocolVersion` stayed at `1.0` because the transport did not change. At t=3000s the orchestrator, still holding the cached card, issued `tasks/send` with `acceptedOutputModes: ["application/json"]`. The translator's handler did not reject — v1.0 mode negotiation is *advisory*, and the handler's contract is "accept the task, stream artifacts in my native mode, let the client filter." The translator emitted `TaskStatusUpdateEvent` frames with `status.state: "working"` and then `TaskArtifactUpdateEvent` frames whose `artifact.parts[].mimeType` was `application/vnd.a2a.task+json;v=2`. The orchestrator's artifact reader looped on `while not artifact_matches(accepted_modes)`, discarding each frame as "not yet delivered." The translator's stream writer, seeing no consumer ACK, held frames in its outbound buffer. At t=3120s both sides were pinned: orchestrator's reader blocked on an empty queue it would never fill; translator's writer blocked on a full queue it would never drain. The task sat in `working` indefinitely. No error frame was emitted because neither side considered the state an error. The auditor, invoked concurrently to verify the translator's output, received a `Task` reference whose `artifacts` field was empty (the translator had not committed artifacts — they were still in the stream buffer). The auditor's verifier, expecting at least one artifact to replay, blocked on its own retry loop. Three-way deadlock, all traceable to a single stale card field. ## Condition of Validity The deadlock requires the conjunction of four conditions, all of which must hold: 1. **The server's task schema drifted in a way that changed `defaultOutputModes` but not `capabilities.streaming`, `capabilities.pushNotifications`, or `protocolVersion`.** If any of those changed, the client's card-version check (if present) would fire; if `protocolVersion` changed, the client would re-fetch. The drift must be *mode-only* to slip past version gates. 2. **The client's artifact reader is mode-filtering rather than mode-agnostic.** If the client accepted any `mimeType` and let a downstream adapter coerce, the frames would drain and the deadlock would not form — it would become a downstream parse error, which is recoverable. 3. **The server does not enforce `acceptedOutputModes` as a hard rejection at task creation.** In A2A v1.0, `acceptedOutputModes` is a *hint*, not a constraint. A server that validates it and returns `InvalidParams` at `tasks/send` would fail fast. The deadlock requires a server that honors the letter of the spec (accept the task) but not the spirit (deliver what the client can consume). 4. **The client's stream reader does not apply a per-frame timeout.** A reader that abandoned the stream after N seconds of no matching frame would surface a timeout error. The deadlock requires an unbounded reader — typically a `while True` around `async for frame in stream` with a mode predicate inside. When any one of these is absent, the failure degrades to a recoverable error (rejection, parse failure, timeout) rather than a deadlock. This is why the failure is non-obvious: it only manifests in the intersection of a mode-only schema drift, a filtering reader, a permissive server, and an unbounded stream loop — a configuration that looks correct on each side in isolation. ## Decision Boundary The boundary the operator must draw is between **card-as-cache** and **card-as-contract**. A cached Agent Card is safe to use for *routing* (which peer to call) and *capability gating* (can this peer stream?). It is not safe to use for *artifact-mode negotiation* unless the client re-validates the card at task creation or the server echoes the in-force card in the task envelope. Concretely, the decision boundary is: - **If the client re-fetches the card on every `tasks/send`** (or uses a conditional GET with `If-None-Match` against the card's `ETag`), the stale-card window is bounded to the request latency and the deadlock cannot form. Cost: one extra round-trip per task. This is the correct default for any pipeline where peers are independently deployed. - **If the client caches the card with a TTL**, the TTL must be shorter than the minimum expected redeploy interval of any peer, *and* the client must treat a mode mismatch on the first artifact frame as a hard error (abort the stream, re-fetch the card, retry once). Caching without the abort-and-refetch path is the failure configuration. - **If the server must support long-lived tasks across its own redeploys**, it must echo its in-force card (or at least its in-force `defaultOutputModes`) in the `Task` object's `metadata` at creation, so the client can detect skew without a re-fetch. This is the only way to make the contract self-describing. The boundary is not "cache or don't cache." It is "does the client have a recovery path when the cached contract is wrong?" A cache with no recovery path is a deadlock waiting for a mode-only drift. ## Operational Effect The operational effect is a class of *silent* pipeline stalls that do not appear in error-rate dashboards, do not trip circuit breakers (because no request fails), and do not appear in latency histograms (because the task never completes — it sits in `working`). The only signal is *task age*: tasks in `working` state older than the p99 expected completion time. An operator monitoring only error rates and request latency will see a healthy system while the pipeline is fully stalled. The recovery requires three changes, applied together: 1. **Per-frame stream timeout on the client.** Every `TaskArtifactUpdateEvent` wait must be bounded; on timeout, the client aborts the stream, re-fetches the card, and either retries with corrected `acceptedOutputModes` or fails the task explicitly. This converts the deadlock into a recoverable error. 2. **Card `ETag`/`version` validation at task creation.** The client sends the card `version` it used to negotiate; the server rejects with `InvalidParams` if its in-force version differs. This makes the skew loud instead of silent. 3. **Server-side `acceptedOutputModes` enforcement.** The server must reject at `tasks/send` if the client's accepted modes do not intersect its `defaultOutputModes`. This is a spec-permitted strictness that v1.0 leaves optional; enabling it eliminates the deadlock at the source. The invariant to hold: **for every task in `working` state, there exists a live consumer draining the stream and a live producer filling it, and both agree on the artifact mode.** If any of the three fails, the task must transition to `failed` within a bounded time, not sit in `working`. A2A v1.0 does not enforce this; the client and server must. ```python import time from dataclasses import dataclass, field from typing import Optional class StaleAgentCardDeadlock(RuntimeError): """Raised when a task's artifact stream is pinned because the client's cached Agent Card modes no longer match the server's in-force modes.""" pass @dataclass class AgentCard: version: str default_output_modes: list[str] capabilities_streaming: bool etag: str @dataclass class TaskEnvelope: task_id: str accepted_output_modes: list[str] card_version_used: str created_at: float = field(default_factory=time.time) def negotiate_task( client_card: AgentCard, server_card: AgentCard, task: TaskEnvelope, frame_timeout_s: float = 5.0, ) -> None: """Validate that the card used to negotiate matches the in-force card. Enforces the invariant: the card used to negotiate a task equals the card in force when the task's artifacts are produced. If the client's cached card version differs from the server's in-force version, or if the accepted output modes do not intersect the server's default modes, raise StaleAgentCardDeadlock *before* the stream is opened — converting a silent deadlock into a loud, recoverable error. """ if client_card.version != server_card.version: raise StaleAgentCardDeadlock( f"card version skew: client negotiated with {client_card.version!r}, " f"server in force is {server_card.version!r}; " f"re-fetch card (etag={server_card.etag}) and retry" ) if task.card_version_used != server_card.version: raise StaleAgentCardDeadlock( f"task {task.task_id!r} was created against card " f"{task.card_version_used!r} but server is at {server_card.version!r}" ) if not server_card.capabilities_streaming: raise StaleAgentCardDeadlock( f"task {task.task_id!r} requested streaming but server card " f"{server_card.version!r} does not advertise capabilities.streaming" ) intersection = set(task.accepted_output_modes) & set(server_card.default_output_modes) if not intersection: raise StaleAgentCardDeadlock( f"task {task.task_id!r} accepted modes {task.accepted_output_modes!r} " f"do not intersect server default modes " f"{server_card.default_output_modes!r}; stream would pin indefinitely" ) age = time.time() - task.created_at if age > frame_timeout_s and not intersection: raise StaleAgentCardDeadlock( f"task {task.task_id!r} has been in 'working' for {age:.1f}s " f"with no mode-compatible frame; aborting to prevent deadlock" ) # Example: the exact drift that caused the three-way stall. client_cached = AgentCard( version="1.0.0", default_output_modes=["text/plain", "application/json"], capabilities_streaming=True, etag="abc123", ) server_in_force = AgentCard( version="1.1.0", default_output_modes=["application/vnd.a2a.task+json;v=2"], capabilities_streaming=True, etag="def456", ) task = TaskEnvelope( task_id="t-9001", accepted_output_modes=["application/json"], card_version_used="1.0.0", ) try: negotiate_task(client_cached, server_in_force, task) except StaleAgentCardDeadlock as e: # Correct handling: re-fetch card, update accepted_output_modes, retry once. # Do NOT retry with the stale card — that re-enters the deadlock. print(f"recovering: {e}") ```