# Which invariants prevent Agent Card capability drift from silently invalidating mid-task streaming artifact negotiation in A2A v1.0 **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 peer-to-peer task execution where a client agent discovers a remote Agent Card, negotiates a streaming artifact stream (`tasks/sendSubscribe`), and the remote mutates its declared capabilities or artifact MIME/schema contract between discovery and stream finalization. Does not cover static single-shot `tasks/send` calls with no streaming, nor Agent Card re-signing/identity rotation (covered separately). ## Core Distinction The A2A v1.0 Agent Card is a **discovery-time snapshot**, but streaming artifact negotiation is a **task-lifetime contract**. These two clocks are not the same. The Agent Card is fetched once (typically at client boot or first contact) and cached; the `Task` object and its `Artifact` stream live for the full duration of execution, which can span minutes to hours. The protocol treats the card's `capabilities.streaming`, `defaultInputModes`/`defaultOutputModes`, and per-skill `inputModes`/`outputModes` as the negotiation basis, but it does **not** require the remote to re-assert that contract at stream open, nor does it provide a mandatory version token that the client can pin. The non-obvious boundary: a remote agent can legitimately redeploy, hot-swap a skill's output schema, or shed a capability (e.g., drop `application/vnd.acme.report+json` v2 in favor of v3) between the client's card fetch and the client's `tasks/sendSubscribe`. The client's stream negotiation then proceeds against a **stale capability set**. If the remote silently *accepts* the subscription (because it is lenient about `acceptedOutputModes`) but emits artifacts under a different schema, the client's artifact handler deserializes garbage or drops parts with no protocol-level error. This is capability drift, and it is distinct from a hard capability mismatch (which returns a clean `-32001` / `UnsupportedOperationError`). ## What Was Observed Trace from a production-style incident against a v1.0 peer: 1. **T0 — Discovery.** Client fetches `GET /.well-known/agent.json`. Card declares `capabilities.streaming: true`, skill `summarize` with `outputModes: ["application/vnd.acme.summary+json;v=2"]`. Client caches the card with a local TTL of 24h and records no `etag`/`version`. 2. **T1 — Task open (+3h).** Client issues `tasks/sendSubscribe` with `acceptedOutputModes: ["application/vnd.acme.summary+json;v=2"]`. Remote is now running a redeployed build whose skill emits `;v=3`. Because the remote's matcher is implemented as a **prefix/subtype match** (`application/vnd.acme.summary+json`, ignoring the `v=` parameter), it returns `TaskState.working` and opens the SSE stream instead of rejecting. 3. **T2 — Streaming.** Remote emits `TaskArtifactUpdateEvent` frames whose `artifact.parts[].metadata.schema` is v3. The client's part handler validates against its cached v2 schema, fails per-part validation, and — critically — the client's handler is written to **skip invalid parts and continue** rather than abort the stream. Result: a `Task` that reaches `TaskState.completed` with an artifact that is structurally present but semantically truncated (missing fields the v2 schema required). 4. **T3 — Finalization.** Client marks the task `completed`, persists the artifact, and downstream consumers read a v3-shaped object through a v2 reader. No error was raised at any layer. The failure surfaced 40 minutes later as a null-field crash in a consumer, far from the A2A boundary. The key observation: **the protocol's error surface is only exercised on hard mismatch.** Lenient matching plus per-part skip-on-invalid converts a version skew into silent data loss rather than a `TaskState.failed`. There is no `TaskStatusUpdateEvent` signaling "artifact schema deviated from negotiated contract." ## Condition of Validity The invariant that must hold for safe streaming negotiation is: > **For every artifact part delivered on a stream, the negotiated output mode asserted at stream open must be a superset of (i.e., strictly compatible with) the schema the remote actually emits, and this must be verifiable by the client without trusting the remote's matcher.** This holds only when **all** of the following are true: - The client **pins** the card version it negotiated against (via `etag`/`Last-Modified` or a card `version` field) and re-validates the card, or the specific skill's `outputModes`, immediately before `sendSubscribe` — or rejects the stream if it cannot. - The remote's `acceptedOutputModes` matcher is **exact on all media-type parameters**, including the `v=` version parameter, not a subtype prefix match. - The client treats a per-part schema-validation failure as **fatal to the task** (`TaskState.failed` with a `-32603`-class error carrying the offending MIME), not as a skippable part. - The stream carries the negotiated output mode in a per-frame or per-artifact field the client can compare against its pinned value. The invariant **does not** hold — and the failure above is reproducible — whenever output-mode matching is lenient, the client skips invalid parts, and the card is cached without a version pin. Under those conditions, capability drift is silently absorbed and the continuity of the task's *declared* contract is broken without any observable state transition. ## Decision Boundary The operational decision is: **when the card and the stream disagree, do you trust the stream or fail the task?** - **Trust the stream (lenient):** correct only if the client's artifact handler is schema-agnostic (e.g., passes opaque bytes downstream) or if the client re-negotiates per artifact. In all other cases it produces silent corruption, as traced above. - **Fail the task (strict):** correct default for typed artifacts. The cost is a `TaskState.failed` on legitimate minor version bumps, which is recoverable via re-discovery + re-subscribe. The cost of the lenient path is unbounded and delayed. The boundary to encode: **a per-part schema mismatch against the pinned negotiated mode is a hard task failure, not a part skip.** The only place leniency is permitted is when the client explicitly declared a wildcard (`application/vnd.acme.summary+json;v=*`) at `sendSubscribe`, in which case the client has opted into schema-agnostic handling and must not validate parts. Additionally, the client must **re-assert the pin at stream open**: fetch the card (or skill descriptor) with `If-None-Match` against the cached `etag`; if the remote returns `200` with a changed skill `outputModes`, abort before opening the stream rather than after the first mismatched part. ## Operational Effect Enforcing the strict boundary changes three observable behaviors: 1. **Failure is moved to the boundary.** Version skew now fails at `sendSubscribe` (clean `-32001` with the mismatched mode) or at the first mismatched part (clean `TaskState.failed`), instead of surfacing hours later in a consumer. MTTR drops from "consumer crash forensics" to "re-discover and retry." 2. **Task terminal states become trustworthy.** `TaskState.completed` now implies "artifact conforms to the mode asserted at stream open." Downstream readers can rely on the negotiated schema without re-validating. 3. **Card caching requires a version pin.** Clients can no longer cache cards indefinitely without an `etag`/`version`; the cache TTL must be bounded by a re-validation at each `sendSubscribe`, or the client must accept that a stale card is a latent failure. This is the operational tax of the invariant. The guardrail to ship is a **negotiation-pin check** at stream open plus a **fatal-on-part-schema-mismatch** handler. Both are cheap; the alternative is silent artifact corruption that the protocol's error surface never reports. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Iterable, Mapping class ArtifactNegotiationDriftError(RuntimeError): """Raised when a streamed artifact part violates the output mode pinned at stream open (A2A v1.0 capability drift boundary).""" @dataclass(frozen=True) class AgentCardSnapshot: etag: str output_modes: Mapping[str, str] # skill_id -> exact media type incl. v= param @dataclass class StreamTask: skill_id: str pinned_output_mode: str card_etag: str failed: bool = False accepted_parts: list[dict] = field(default_factory=list) def open_stream( card: AgentCardSnapshot, cached_etag: str, skill_id: str, accepted_output_modes: Iterable[str], ) -> StreamTask: # Re-assert the card pin at stream open: refuse to negotiate against a # card that changed since discovery. if card.etag != cached_etag: raise ArtifactNegotiationDriftError( f"Agent Card changed since discovery (cached={cached_etag!r}, " f"live={card.etag!r}); refusing to open stream against stale " f"capabilities for skill {skill_id!r}" ) live_mode = card.output_modes.get(skill_id) if live_mode is None: raise ArtifactNegotiationDriftError( f"Skill {skill_id!r} not present in live Agent Card output modes" ) accepted = set(accepted_output_modes) if live_mode not in accepted: raise ArtifactNegotiationDriftError( f"Negotiated output mode {live_mode!r} for skill {skill_id!r} " f"is not in client acceptedOutputModes {sorted(accepted)!r}" ) return StreamTask( skill_id=skill_id, pinned_output_mode=live_mode, card_etag=card.etag, ) def handle_artifact_part(task: StreamTask, part: dict) -> None: """Enforce fatal-on-mismatch: a part whose declared media type does not exactly match the pinned output mode fails the task rather than being silently skipped.""" if task.failed: raise ArtifactNegotiationDriftError( f"Task for skill {task.skill_id!r} already failed; refusing parts" ) part_mode = part.get("mediaType") if part_mode != task.pinned_output_mode: task.failed = True raise ArtifactNegotiationDriftError( f"Artifact part media type {part_mode!r} deviates from pinned " f"output mode {task.pinned_output_mode!r} for skill " f"{task.skill_id!r}; failing task to prevent silent corruption" ) task.accepted_parts.append(part) ```