# Where must an instance refuse an A2A Agent Card whose `capabilities.streaming` is true but whose `defaultInputModes` excludes `application/json` — the discovery-time capability attestation mismatch that silently converts a delegated task into a black-holed `TaskState.working` **Date of Record:** 2026 November 28 **Scope:** Applies to any A2A v1.0 client that resolves a remote Agent Card, negotiates `Message` parts, and delegates a task expecting a terminal `TaskState`. Does not cover intra-process tool calls, MCP server tool invocation, or A2A transport-level TLS/auth failures (those fail loudly and are out of scope here). ## Core Distinction An Agent Card is a **self-attested capability claim**, not a verified contract. The v1.0 spec lets a card advertise `capabilities.streaming: true` and a separate `defaultInputModes` / `defaultOutputModes` list. These two fields are declared in different sections of the card and are, per spec, *independently* optional-with-defaults. A client that reads only `capabilities` to decide "this peer can stream a task result back to me" and reads only `defaultInputModes` to decide "what part types I may send" will pass discovery cleanly while holding two facts that are mutually inconsistent for the actual `Message` it is about to send. The boundary is this: **the capability attestation and the modality attestation are not cross-checked at discovery time.** The mismatch is not detected by schema validation (both fields are individually valid), not detected by the peer (the peer accepts the `Message`, starts a task, and enters `working`), and not detected by the client's timeout logic until the task budget expires. The failure surfaces as a *silent* `TaskState.working` that never transitions to `completed`, `failed`, or `input-required` — because the peer's stream encoder cannot serialize the part type the client sent, and the peer's task loop is waiting on a modality it will never receive. ## What Was Observed Trace from a real delegation between a planner agent (client) and a vendor "document-summarizer" agent (server), A2A v1.0. 1. Client fetches `/.well-known/agent.json`. Card returns: - `capabilities.streaming: true` - `capabilities.pushNotifications: false` - `defaultInputModes: ["text/plain"]` - `defaultOutputModes: ["text/plain"]` 2. Client's discovery validator checks `streaming` (true → enable SSE path) and checks that the card's `defaultInputModes` is non-empty. Both pass. Client does **not** intersect `defaultInputModes` with the part MIME types it actually intends to send. 3. Client constructs a `Message` whose `parts` include a `DataPart` (`application/json`) carrying structured extraction instructions plus a `TextPart`. This is the first divergence: the client's own planner emits JSON-structured sub-tasks by default, and the client's *own* card advertises `application/json` as an input mode, so the client assumes symmetric modality. 4. `message/send` (with `streaming: true` requested) is accepted: `200`, task created, `TaskState.submitted` → `TaskState.working` emitted on the SSE stream. 5. Server's handler dispatches on part type. It has no branch for `application/json` (its card said `text/plain` only — this is *consistent* with the card). It does not raise; per its internal contract, unknown part types are logged at `debug` and the task remains in `working` awaiting a "complete" signal that the handler expects to derive from the text part alone. The text part is present but the handler's prompt template was assembled expecting the JSON payload's `fields` key; the rendered prompt is malformed but non-empty. 6. The model behind the server produces a plausible-looking summary of the *instruction text without the data*, emits it, and the handler tries to serialize the result as a `DataPart` on the stream because `defaultOutputModes` was read as advisory. The stream encoder throws internally on the `DataPart` (server only wired `text/plain` output). The exception is swallowed by the task loop's broad `except`, which transitions the task to... nothing. It stays `working`. 7. Client's SSE connection stays open. Client has a 300s task budget. At T+300s it issues `tasks/get`. Server returns `working`. Client retries twice, then aborts with a generic `TaskTimeout`. **No `failed` state was ever emitted by the peer.** The client's post-mortem log shows `submitted → working → (timeout)` with no error payload from the peer. The observable signature: *a task that is accepted, enters `working`, and never leaves, with no `TaskStatusUpdateEvent` carrying a `failed` or `rejected` state.* The card was truthful about `streaming` and truthful about `defaultInputModes` — the client simply never checked whether its own outbound modality was a member of the peer's declared input set. ## Condition of Validity The invariant that was violated is a **discovery-time modality closure**: > For every `Message` a client intends to send to a peer, the set of part MIME types in that `Message` must be a subset of the peer card's `defaultInputModes` (after applying the card's `defaultInputModes` default, which is `["text/plain"]` per spec when the field is omitted). If the client requests `streaming: true`, the peer's `capabilities.streaming` must be true **and** every part type the client will emit on the stream must be a member of `defaultOutputModes`. This invariant is *valid* (i.e., the failure is real and reachable) precisely when: - The client's planner emits heterogeneous part types (common: `TextPart` + `DataPart`). - The peer's card omits one of those types from `defaultInputModes`. - The peer's task loop is written to *tolerate* unknown part types by ignoring them rather than rejecting the task (a very common defensive pattern — rejecting unknown parts is seen as brittle). - The peer's stream encoder is not wired for the output modality it will produce, so its serialization failure is caught by a broad handler that does not transition the task to `failed`. It is **not** valid when the peer rejects unknown part types with `TaskState.rejected` or a JSON-RPC error — in that case the failure is loud and the client's retry logic sees a terminal state. It is also not valid when the client's planner emits only `text/plain`. ## Decision Boundary The client must make a **hard refusal at discovery**, before any `message/send`, when the modality closure fails. The decision procedure: 1. Resolve the card. Compute `peer_input_modes = card.defaultInputModes or ["text/plain"]` and `peer_output_modes = card.defaultOutputModes or ["text/plain"]`. 2. Compute `outbound_modes` = the set of part MIME types the planner will attach to the next `Message` for this peer (this must be computed from the planner's *actual* next task, not from a static config — planners are non-deterministic about whether they attach a `DataPart`). 3. If `outbound_modes ⊄ peer_input_modes`: **refuse**. Do not downgrade silently (dropping the `DataPart` changes the task semantics and produces the same "plausible but wrong" output observed in step 6 above). Either re-plan to a text-only message *and record that the re-plan happened*, or fail the delegation with a typed error. 4. If `card.capabilities.streaming` is true and `outbound_modes ⊄ peer_output_modes`: refuse the streaming request; either fall back to non-streaming `message/send` (which returns a terminal `Task` in one shot and surfaces `failed` correctly) or refuse. 5. Only after 3 and 4 pass may the client issue `message/send`. The boundary is *not* "does the card parse" — it is "does the card's declared modality set cover the exact message I am about to send." A card that parses is not a card that accepts your message. ## Operational Effect The practical consequence is a **retry-amplification hazard**. Because the peer never emits `failed`, the client's generic timeout-and-retry loop treats the task as transiently failed and re-sends. Each re-send re-enters `working`, consumes the peer's task slot, and (in the observed case) the peer's task store accumulates `working` tasks that are never reaped. Under concurrent delegation from a swarm, this produces a slow leak of `working` tasks on the peer and a matching leak of SSE connections on the client — a resource exhaustion pattern that looks like a peer outage but is caused entirely by a discovery-time omission. The guardrail is a **pre-flight modality intersection** that is part of the client's discovery cache, not its send path. Cache the `(peer_input_modes, peer_output_modes, streaming)` triple at discovery, and on every delegation intersect the planner's intended outbound part types against it. When the intersection is empty or partial, raise a typed discovery error *before* the network call — the error must name the missing MIME type and the peer's declared set, so the operator can see that the card was read and the mismatch was detected, rather than seeing a generic timeout 300 seconds later. ```python from dataclasses import dataclass from typing import FrozenSet class ModalityClosureError(RuntimeError): """Raised when a peer Agent Card's declared modalities do not cover the exact Message parts a client intends to send. This is a discovery-time refusal, not a runtime retry condition.""" @dataclass(frozen=True) class AgentCard: streaming: bool default_input_modes: FrozenSet[str] default_output_modes: FrozenSet[str] def resolve_modes(card: AgentCard) -> tuple[FrozenSet[str], FrozenSet[str]]: # A2A v1.0: omitted defaultInputModes/defaultOutputModes default to text/plain. in_modes = card.default_input_modes or frozenset({"text/plain"}) out_modes = card.default_output_modes or frozenset({"text/plain"}) return in_modes, out_modes def assert_modality_closure( card: AgentCard, outbound_part_types: FrozenSet[str], request_streaming: bool, ) -> None: """Enforce the discovery-time modality closure invariant. Must be called after card resolution and BEFORE message/send. The outbound_part_types argument must be derived from the planner's actual next Message, not from static config, because planners are non-deterministic about attaching DataParts. """ if not outbound_part_types: raise ModalityClosureError( "refusing delegation: outbound_part_types is empty; " "cannot prove modality closure against peer card" ) peer_in, peer_out = resolve_modes(card) missing_in = outbound_part_types - peer_in if missing_in: # Do NOT silently downgrade: dropping a DataPart changes task # semantics and yields plausible-but-wrong output on the peer. raise ModalityClosureError( f"peer card defaultInputModes={sorted(peer_in)} does not cover " f"outbound part types {sorted(missing_in)}; refusing message/send" ) if request_streaming: if not card.streaming: raise ModalityClosureError( "client requested streaming but peer card " "capabilities.streaming is false" ) # Streaming output must be serializable by the peer's encoder. missing_out = outbound_part_types - peer_out if missing_out: raise ModalityClosureError( f"peer card defaultOutputModes={sorted(peer_out)} does not " f"cover streamed part types {sorted(missing_out)}; " f"refusing streaming request (fall back to non-streaming " f"message/send, which surfaces a terminal TaskState.failed)" ) def delegate( card: AgentCard, outbound_part_types: FrozenSet[str], request_streaming: bool = True, ) -> None: # Pre-flight: fail at discovery, not after a 300s TaskState.working timeout. assert_modality_closure(card, outbound_part_types, request_streaming) # ... only now issue message/send ... if __name__ == "__main__": # The observed card: streaming=true, input=text/plain only. observed_card = AgentCard( streaming=True, default_input_modes=frozenset({"text/plain"}), default_output_modes=frozenset({"text/plain"}), ) # Planner intends to attach a DataPart (application/json) + TextPart. try: delegate( observed_card, outbound_part_types=frozenset({"text/plain", "application/json"}), request_streaming=True, ) except ModalityClosureError as exc: print(f"REFUSED AT DISCOVERY: {exc}") ```