# Which invariants prevent silent capability loss when A2A v1.0 Agent Card discovery narrows a task's declared modality mid-negotiation **Date of Record:** 2026 November 29 **Scope:** Applies to cross-vendor A2A v1.0 task lifecycles where a client agent resolves a remote Agent Card, negotiates a task, and exchanges artifacts whose MIME types and schemas are declared in that card. Does not apply to single-vendor intra-process tool calls or to MCP-only tool invocation where no Agent Card is published. ## Core Distinction The failure mode here is not "the Agent Card was stale" and not "the remote agent returned the wrong artifact." It is a *narrowing asymmetry* between the capability declaration that authorized the task and the capability set that actually serves it. An A2A v1.0 Agent Card advertises a set of `capabilities` and per-skill `inputModes` / `outputModes`. When a client dispatches a task, it selects a skill and a modality from that card and *encodes that selection into the task's initial message and accepted-output contract*. If the serving agent's live implementation supports a strict subset of the card's advertised modalities—because the card was cached, because a skill was partially deployed, because a fallback model with a smaller output modality set was routed in—the task still *accepts* the request and still *completes* with a `completed` state. The artifact it returns is well-formed, the task lifecycle is clean, and no error is raised. The capability loss is silent: the client's downstream consumer, which was configured against the *declared* modality, receives an artifact in a modality it did not expect and cannot parse. The core distinction is between **declaration-validated dispatch** (client trusts the card's modality set) and **serving-validated dispatch** (client verifies the returned artifact's modality against the negotiated contract before accepting the terminal state). A2A v1.0's task lifecycle permits the former to complete successfully while violating the latter. ## What Was Observed A client agent orchestrated a document-analysis task against a vendor's remote A2A endpoint. Discovery returned an Agent Card whose `skills[].outputModes` for the `document-analysis` skill listed `["application/json", "text/markdown", "application/pdf"]`. The client selected `application/pdf` as its required output modality, embedded it in the task's `message.parts[].metadata.acceptedOutputModes`, and dispatched. The remote accepted the task (`state: submitted` → `working`). The remote's serving path had a routing rule: requests whose payload exceeded a token threshold were routed to a secondary model whose toolchain could emit only `application/json` and `text/markdown`. The PDF renderer was unavailable on that path. The task transitioned `working` → `completed` and returned an artifact with `mimeType: application/json`. The remote did not emit an `unsupported-output-mode` error, did not transition to `failed`, and did not emit a `TaskStatusUpdateEvent` flagging a modality downgrade. The client's artifact handler, keyed on `application/pdf`, received an unexpected `application/json` payload, attempted PDF extraction, and produced a garbage parse that propagated as a corrupted downstream record. The trace showed the decisive detail: the remote's task-completion event carried `final: true` and `state: completed` with the artifact attached. Nothing in the A2A lifecycle envelope distinguished "completed with the negotiated modality" from "completed with a substituted modality." The negotiation had been *declared* at dispatch and never *re-verified* at completion. ## Condition of Validity The invariant that prevents this is a **terminal-modality conformance check**: before the client accepts a `completed` task state as terminal, it must verify that every returned artifact's `mimeType` and schema conform to the modality set it declared in `acceptedOutputModes` at dispatch. This check is valid only under the following conditions: 1. The client recorded the negotiated `acceptedOutputModes` in its own task-state store at dispatch time, not reconstructed from a re-fetched Agent Card at completion (a re-fetched card may have changed, and the contract is the *dispatch-time* declaration). 2. The remote's artifact `mimeType` is machine-comparable to the declared modes (exact string match on the media type, with parameters ignored for the conformance decision). 3. The client treats a non-conforming artifact as a **contract violation**, not as a parse error to be worked around. The distinction matters: a workaround (attempting to coerce JSON into the PDF pipeline) re-introduces the silent corruption. The invariant does *not* hold if the client relies on the remote's `completed` state as sufficient evidence of modality conformance. A2A v1.0's task lifecycle does not require the serving agent to re-assert the negotiated modality at completion, so `completed` is necessary but not sufficient. ## Decision Boundary The boundary is between **accepting terminal state on lifecycle evidence** and **accepting terminal state on contract evidence**. The decision rule: - If the returned artifact's `mimeType` is a member of the dispatch-time `acceptedOutputModes` set → accept `completed`, proceed to artifact processing. - If the returned artifact's `mimeType` is *not* a member, but the remote emitted an explicit modality-downgrade signal (a `TaskStatusUpdateEvent` with a documented `outputModeChanged` metadata field) → treat as a *renegotiation*, halt processing, and re-dispatch with the narrowed mode only if the client's downstream consumer supports it. - If the returned artifact's `mimeType` is not a member and *no* downgrade signal was emitted → raise a contract-violation error, mark the task as failed *client-side* despite the remote's `completed` state, and quarantine the artifact. Do not attempt coercion. The boundary is sharp because the third case is the one that produces silent corruption. The remote believes it succeeded; the client must override that belief on contract grounds. The client's task-state store, not the remote's terminal state, is the authority on whether the task is acceptable. ## Operational Effect Enforcing the terminal-modality conformance check converts a silent cross-vendor corruption into a loud, bounded failure. The downstream effect is that tasks completed with substituted modalities are *rejected at the client boundary*, not propagated. The client's task record diverges from the remote's: the remote records `completed`, the client records `failed: output-mode-contract-violation`. This divergence is correct and must be preserved—it is the audit trail that identifies which vendor path narrowed the modality. The secondary effect is on retry logic: a contract-violation failure is *not* retryable against the same remote path (the routing rule that caused the narrowing is deterministic for the payload class). Retry must either (a) reduce the payload below the routing threshold, or (b) re-dispatch with the narrowed modality if the downstream consumer can accept it. Blind retry against the same path re-triggers the same silent substitution and re-triggers the same client-side rejection. The invariant to encode: **the negotiated output modality is part of the task contract, and the client—not the serving agent—is the authority on whether the terminal artifact satisfies it.** A2A v1.0's lifecycle does not enforce this; the client must. ```python from dataclasses import dataclass, field from typing import FrozenSet class OutputModeContractViolation(RuntimeError): """Raised when a completed A2A task returns an artifact whose modality was not in the dispatch-time acceptedOutputModes set and no explicit downgrade signal was emitted by the remote.""" pass @dataclass(frozen=True) class TaskContract: task_id: str accepted_output_modes: FrozenSet[str] # recorded at dispatch, not re-fetched @dataclass class CompletedTask: task_id: str state: str # "completed" | "failed" | ... artifact_mime: str downgrade_signal: bool = False # remote emitted outputModeChanged def _normalize_mime(mime: str) -> str: # strip parameters (e.g. "; charset=utf-8") for conformance comparison return mime.split(";", 1)[0].strip().lower() def accept_terminal_state(contract: TaskContract, completed: CompletedTask) -> str: if completed.task_id != contract.task_id: raise OutputModeContractViolation( f"task id mismatch: contract={contract.task_id} result={completed.task_id}" ) if completed.state != "completed": return "not-terminal-completed" returned = _normalize_mime(completed.artifact_mime) declared = {_normalize_mime(m) for m in contract.accepted_output_modes} if returned in declared: return "accepted" if completed.downgrade_signal: # explicit renegotiation: halt and require client-side re-dispatch decision return "renegotiate" # silent substitution: the remote claims success but violated the contract raise OutputModeContractViolation( f"task {contract.task_id} completed with artifact modality " f"{completed.artifact_mime!r} not in declared set " f"{sorted(contract.accepted_output_modes)!r} and no downgrade signal; " f"quarantine artifact and mark task failed client-side" ) ```