# Under what conditions must an instance renegotiate an A2A v1.0 Agent Card mid-task when a peer's advertised `defaultInputModes`/`defaultOutputModes` diverge from its live task-scoped `Task.status.message` part types **Date of Record:** 2026 November 24 **Scope:** Applies to A2A v1.0 clients that cache a peer's Agent Card at discovery time and then drive one or more `tasks/send` / `tasks/sendSubscribe` exchanges against that cached card. Does not apply to single-shot, stateless RPC calls where the card is re-fetched per invocation, nor to peers behind a stable gateway that normalizes part types. ## Core Distinction The A2A Agent Card is a *static capability declaration*, resolved once at discovery (`/.well-known/agent.json` or the `agentCard` field of a `Task`). The task lifecycle, however, is *dynamic and stateful*: the `TaskStatusUpdateEvent` and `TaskArtifactUpdateEvent` streams carry `Message` objects whose `parts[]` each declare a concrete `type` (`text`, `file`, `data`). The failure boundary is the assumption that the card's `defaultInputModes` / `defaultOutputModes` (MIME-like mode strings such as `text/plain`, `application/json`, `image/png`) are a *sufficient* type contract for the parts actually exchanged during a task. They are not. The card advertises *modes*; the wire carries *part types with embedded media types*. A peer can legitimately advertise `defaultOutputModes: ["text/plain"]` and still emit a `DataPart` (`type: "data"`) whose `metadata.mimeType` is `application/json` mid-stream, because the card's `default*` fields are defaults, not exhaustive constraints, and because a heterogeneous runtime (LangGraph node, OpenAI Assistants wrapper, a Rust `rig` agent) may route a sub-call to a tool that produces a richer part than the runtime's own card generator knew about. The client that treats the card as a closed schema will reject or mis-decode a legal part and either abort the task or, worse, silently drop the artifact. ## What Was Observed Two heterogeneous runtimes, `planner-runtime` (Python, card advertises `defaultInputModes: ["text/plain"]`, `defaultOutputModes: ["text/plain", "application/json"]`) and `executor-runtime` (a Go agent behind an A2A shim). The planner discovers the executor's card, sees `application/json` in `defaultOutputModes`, and negotiates a task with `acceptedOutputModes: ["application/json"]` in the initial `Message`. The executor accepts. Mid-task the executor's internal tool returns a PDF blob. The executor's shim wraps it as a `FilePart`: ``` {"type": "file", "file": {"name": "report.pdf", "mimeType": "application/pdf", "bytes": "..."}} ``` emitted inside a `TaskArtifactUpdateEvent`. The planner's decoder, keyed on the negotiated `acceptedOutputModes`, has no branch for `application/pdf` (it was never in the card, never in the negotiation). Depending on the client's strictness: - **Strict client:** raises a schema/validation error, sends `tasks/cancel`, and the task dies with `TaskState.canceled` even though the executor considered it `completed`. The artifact is lost because cancellation races the final artifact event. - **Lenient client:** drops the unrecognized part, records `TaskState.completed` with an empty artifact list, and the downstream consumer believes the task succeeded with no output. This is the *silent* failure and the more dangerous one. A second observed variant: the executor's card advertised `defaultInputModes: ["text/plain"]`, but on a follow-up turn the planner sent a `DataPart` carrying structured `context` (a `data` part with a JSON object) as the continuation message. The executor's input validator, trusting its own card, rejected with `-32602 Invalid params`, and the task stalled in `TaskState.input-required` with no client-side timeout — a deadlock, since the planner was waiting for a status change and the executor was waiting for a valid input. ## Condition of Validity The card-as-schema assumption is valid only when **all three** hold: 1. The peer's runtime is *homogeneous* with respect to part emission — every tool/node that can fire during a task produces parts whose media types are a subset of the card's `default*Modes`. 2. The negotiation (`acceptedOutputModes`) is treated by the peer as a *hard* filter, not a hint, so out-of-mode parts are converted (e.g., PDF → base64 in a `text/plain` part) rather than emitted raw. 3. The client's decoder is *open* to unknown part types and media types, degrading gracefully rather than failing closed. In practice condition (1) fails for any runtime that wraps third-party tools or sub-agents, and condition (2) is not mandated by the spec — `acceptedOutputModes` is advisory. So the invariant that actually holds is weaker and must be stated explicitly: > **Invariant:** A client must never treat the Agent Card's `default*Modes` as a closed schema for parts received during a task. The card bounds *negotiation*, not *emission*. Every received `Part` must be validated against its own declared `type`/`mimeType`, and any part outside the negotiated set must be handled by an explicit policy (buffer-and-report, convert, or fail-with-reason), never silently dropped. ## Decision Boundary The instance must re-fetch the peer's Agent Card (and, if the peer supports it, re-negotiate via a fresh `Message` with updated `acceptedOutputModes`) at the following boundary: - **On first out-of-negotiation part:** if a received part's media type is not in the negotiated set *and* not in the cached card's `defaultOutputModes`, the cached card is stale or incomplete. Re-fetch the card once. If the re-fetched card still does not list the media type, the divergence is real (runtime/tool drift) and the client must switch to *open-decode mode* for the remainder of the task rather than abort. - **On `TaskState.input-required` with a rejected continuation:** if the executor returns `-32602` (or an A2A `InvalidParamsError`) to a continuation `Message` whose parts were within the card's `defaultInputModes`, the executor's *actual* input contract is narrower than its card. Do not retry the same part shape; downgrade to `text/plain` (serialize the `DataPart` payload as a JSON string in a `TextPart`) and retry once. - **On card `version`/`protocolVersion` mismatch in a status event:** if the peer's `TaskStatusUpdateEvent` carries a protocol version or card hash differing from the cached card, the peer was redeployed mid-task; re-fetch before the next turn. The boundary is *not* crossed on the first part whose type is merely *unexpected but in-mode* (e.g., a `DataPart` when `application/json` was negotiated) — that is normal and must be decoded, not treated as drift. ## Operational Effect Treating the card as a closed schema converts a legal, spec-permitted emission into either a spurious cancellation (strict clients) or a silent artifact loss (lenient clients). The strict path is loud but destroys completed work because cancellation races the final artifact event. The lenient path corrupts the task's *semantic* outcome: `completed` with no artifact, which downstream auditors cannot distinguish from a genuinely empty result. Both violate the A2A task-lifecycle guarantee that a `completed` task's artifacts reflect the executor's actual output. The correct posture is: cache the card for *routing and negotiation*, but decode every part by its own self-description, maintain a per-task "observed modes" set that can exceed the negotiated set, and on divergence re-fetch once then degrade to open-decode. This bounds the blast radius to a single task and preserves the artifact, at the cost of one extra discovery round-trip and a looser client-side type check. ```python from dataclasses import dataclass, field from typing import Any class AgentCardDivergenceError(RuntimeError): """Raised when a received Part's media type falls outside both the negotiated acceptedOutputModes and the cached Agent Card's default modes, and the divergence cannot be resolved by a single card re-fetch.""" @dataclass class CachedCard: default_input_modes: set[str] default_output_modes: set[str] version: str @dataclass class TaskNegotiation: accepted_output_modes: set[str] observed_modes: set[str] = field(default_factory=set) open_decode: bool = False refetched: bool = False def handle_part( part: dict[str, Any], negotiation: TaskNegotiation, card: CachedCard, refetch_card, # callable() -> CachedCard ) -> dict[str, Any]: """Decode a single Part from a TaskArtifactUpdateEvent. Invariant: the card bounds negotiation, not emission. Never drop a part silently; never abort a task for an in-spec emission. """ mime = part.get("file", {}).get("mimeType") or part.get("metadata", {}).get("mimeType") ptype = part.get("type") if ptype not in {"text", "file", "data"}: raise AgentCardDivergenceError(f"unknown part type {ptype!r}") # In-mode or open-decode: accept and record. if mime is None or mime in negotiation.accepted_output_modes or mime in card.default_output_modes: if mime: negotiation.observed_modes.add(mime) return part # Out of both negotiated set and cached card. Card may be stale. if not negotiation.refetched: fresh = refetch_card() negotiation.refetched = True if mime in fresh.default_output_modes: negotiation.observed_modes.add(mime) return part # Divergence is real: runtime/tool drift. Degrade to open-decode for the # remainder of the task rather than cancel or drop. if not negotiation.open_decode: negotiation.open_decode = True negotiation.observed_modes.add(mime) return part # Already in open-decode and still unclassifiable -> hard stop with reason. raise AgentCardDivergenceError( f"part mimeType {mime!r} outside negotiated {sorted(negotiation.accepted_output_modes)} " f"and card {sorted(card.default_output_modes)} after re-fetch; " f"open-decode already active" ) ```