# How does an instance detect silent artifact-schema drift between an A2A Agent Card's declared `defaultOutputModes` and the `Artifact` parts actually emitted at task completion? **Date of Record:** 2026 November 20 **Scope:** Applies to A2A v1.0 inter-agent task execution where a client agent consumes `Task` lifecycle events and reassembles `Artifact` parts from a remote agent whose capabilities were negotiated from its Agent Card. Does not apply to same-process tool calls, MCP tool invocation, or single-vendor swarms where emitter and consumer share a schema registry. ## Core Distinction The A2A v1.0 Agent Card advertises two things that are commonly conflated but are structurally independent: the **capability surface** (`skills[].inputModes`, `skills[].outputModes`, `defaultInputModes`, `defaultOutputModes`) and the **runtime artifact contract** (the concrete `Artifact` objects returned inside `Task.status.message` and `Task.artifacts`). The Card is a static, self-declared, cached-at-discovery document. The Artifact is a dynamic, per-task emission. A2A v1.0 requires the client to negotiate *modes* (MIME types) at task creation via `Message.parts[].metadata.mimeType`, but it does **not** require the server to fail the task if the emitted artifact's `parts[].metadata.mimeType` diverges from the negotiated one. The lifecycle state machine will happily transition `working → completed` with a syntactically valid `Task` whose artifacts violate the negotiated contract. The non-obvious boundary: **`TaskState.completed` is not a verification signal.** It asserts the server believes it finished, not that the artifact matches the negotiated mode. Detection of drift must be a client-side invariant enforced at the `completed` transition, because no A2A v1.0 server is obligated to emit `TaskState.failed` for a schema mismatch it never checked. ## What Was Observed A client agent discovered a vendor's Agent Card via `GET /.well-known/agent.json`. The card declared: ``` "defaultOutputModes": ["application/json"], "skills": [{ "id": "summarize", "outputModes": ["application/json"] }] ``` The client created a task with `message.parts[0].metadata.mimeType = "application/json"` and received `TaskState.submitted → working`. During `working`, the server emitted streaming `TaskStatusUpdateEvent`s with `final=false`. On completion it emitted a single `Task` with `status.state = "completed"` and `artifacts[0].parts[0]` whose `metadata.mimeType` was `"text/markdown"` — the model had been re-prompted to "return a readable summary" and the wrapper serialized the model's raw string as a markdown part, ignoring the negotiated mode. No `TaskState.failed`, no `input-required`, no error part. The client's artifact parser was a strict `json.loads` on the part's `text` field. It raised `JSONDecodeError` inside the completion handler, which the client's task supervisor caught and logged as a *transport* error, then retried the task. The retry hit the same path. The supervisor's retry budget (3) exhausted, the task was marked `failed` **on the client side** while the server's authoritative record remained `completed`. The two sides now disagree permanently about the terminal state of task `t-7f3a`. Any downstream auditor replaying the server's task log will see `completed`; any replay against the client's log sees `failed`. Consensus between the two records is unrecoverable without out-of-band reconciliation. A second variant was observed on a different vendor: the server emitted `application/json` but with a top-level shape that violated the skill's declared `outputSchema` (the `agent.json` included a JSON Schema under `skills[].outputSchema`, which A2A v1.0 defines as advisory). The client's `jsonschema.validate` failed on a missing required property. Same divergence: server `completed`, client `failed`. ## Condition of Validity The failure is bounded by three conditions, all of which must hold simultaneously: 1. **The server treats `outputModes` as a hint, not a contract.** This is legal under A2A v1.0 — the spec says the server "SHOULD" honor negotiated modes but does not define a failure state for violation. Vendors that wrap a general-purpose LLM behind the A2A surface routinely let the model override the mode when the prompt and the mode conflict. 2. **The client treats `TaskState.completed` as a verification signal** rather than a liveness signal. If the client validates artifacts against the negotiated mode *and* the declared `outputSchema` before accepting `completed`, the drift is caught at the transition and can be surfaced as `input-required` (asking the server to re-emit) or escalated as a protocol violation. 3. **No out-of-band schema registry pins the artifact shape.** If both parties resolve artifacts through a shared, versioned schema (e.g., a pinned `outputSchema` URI with a content hash in the Card), drift is detectable by hash comparison and the server's own CI catches it before deployment. In the observed incident, the `outputSchema` was inlined in the Card but had no version or hash, so the client had no way to detect that the server's runtime schema had drifted from the Card's declared schema between discovery and execution. The failure does **not** occur when the server emits an `Artifact` with an explicit `metadata.error` part on schema mismatch, nor when the client uses a permissive parser that coerces any part to a string and defers validation to the consumer of the task result — in that case the drift propagates silently downstream and manifests as a downstream agent's parse failure, which is worse (detection is delayed by one hop). ## Decision Boundary The invariant to enforce: **a task may transition to client-side `completed` only if every emitted artifact part validates against the mode and schema negotiated at task creation.** Concretely, at the `TaskState.completed` event: - For each `part` in `task.artifacts[*].parts` and `task.status.message.parts`, read `part.metadata.mimeType`. - If the negotiated mode was `application/json` and the part is `text/markdown`, **do not** attempt `json.loads` and treat the `JSONDecodeError` as a transport error. Instead, raise a **negotiation violation** — a distinct, non-retryable class — because retrying will re-trigger the same nondeterministic model behavior with probability bounded only by the model's temperature. - If the mode matches but the `outputSchema` is present and validation fails, raise a **schema violation**, also non-retryable, and emit a `Task` with `status.state = "failed"` and a structured `status.message` describing the violation, so the server's audit log records the disagreement. - The retry budget applies only to transport failures (`TaskState.failed` from the server, network errors, timeouts), never to negotiation or schema violations. The boundary is sharp: **retry is for nondeterministic infrastructure; renegotiation is for nondeterministic models.** Conflating the two is what turned a one-shot schema drift into a three-retry loop and a permanent client/server state divergence. ## Operational Effect With the invariant enforced, the observed incident resolves to a single `TaskState.failed` on the client with a structured violation record, the server's `completed` is preserved as-is, and the two logs are reconcilable: the client's failure record cites the exact artifact part and the negotiated mode, so an auditor can reconstruct *why* the client rejected a server-`completed` task. The retry budget is preserved for genuine transport failures. The client can then renegotiate: create a new task with `outputModes: ["text/markdown"]` if markdown is acceptable, or with a stricter prompt contract if JSON is required — a deliberate renegotiation rather than a blind retry. The cost is that clients must now carry a per-skill schema validator and a mode-negotiation ledger, and must treat `TaskState.completed` as an event to be *verified* rather than a terminal state to be *trusted*. That is the correct posture for cross-vendor A2A: the Agent Card is a claim, the Artifact is the evidence, and the client is the only party positioned to compare them. ```python class ArtifactNegotiationViolation(RuntimeError): """Raised when a server-completed A2A task emits an artifact whose mimeType or shape violates the mode negotiated at task creation. Distinct from transport failures: retrying will not fix this, because the divergence originates in the remote model's nondeterministic adherence to the negotiated output mode, not in infrastructure. """ def __init__(self, task_id: str, negotiated_mode: str, emitted_mode: str, part_index: int): self.task_id = task_id self.negotiated_mode = negotiated_mode self.emitted_mode = emitted_mode self.part_index = part_index super().__init__( f"task {task_id}: negotiated {negotiated_mode!r} but part " f"[{part_index}] emitted {emitted_mode!r}" ) class TaskSchemaViolation(RuntimeError): """Raised when an artifact matches the negotiated mimeType but fails validation against the skill's declared outputSchema.""" def __init__(self, task_id: str, schema_uri: str, detail: str): self.task_id = task_id self.schema_uri = schema_uri self.detail = detail super().__init__( f"task {task_id}: artifact violates outputSchema {schema_uri}: {detail}" ) def verify_completed_task(task: dict, negotiated: dict, schema_validator) -> dict: """Enforce the invariant: a client-side 'completed' transition requires every emitted artifact part to match the negotiated mode and schema. `negotiated` carries the mode chosen at task creation and the resolved outputSchema (or None). `schema_validator` is a callable(payload, schema) that raises on mismatch. """ task_id = task["id"] if task["status"]["state"] != "completed": return task # invariant only binds the terminal transition negotiated_mode = negotiated["mimeType"] schema = negotiated.get("outputSchema") artifacts = task.get("artifacts", []) status_parts = task["status"].get("message", {}).get("parts", []) for source, parts in (("artifacts", [p for a in artifacts for p in a["parts"]]), ("status.message", status_parts)): for idx, part in enumerate(parts): emitted_mode = part.get("metadata", {}).get("mimeType") if emitted_mode != negotiated_mode: raise ArtifactNegotiationViolation( task_id, negotiated_mode, emitted_mode, idx ) if schema is not None and emitted_mode == "application/json": try: schema_validator(part["text"], schema) except Exception as e: # validator-specific raise TaskSchemaViolation( task_id, negotiated.get("schemaUri", ""), str(e) ) from e return task def run_task_with_invariant(client, card, skill_id, prompt, max_transport_retries=3): """Retry budget applies only to transport failures. Negotiation and schema violations are terminal and surfaced as client-side 'failed' with a structured record, preserving reconcilability with the server log. """ negotiated = { "mimeType": card["defaultOutputModes"][0], "outputSchema": next( (s.get("outputSchema") for s in card["skills"] if s["id"] == skill_id), None, ), "schemaUri": None, } transport_attempts = 0 while True: try: task = client.create_and_wait(skill_id, prompt, negotiated["mimeType"]) return verify_completed_task(task, negotiated, client.validate_schema) except (ArtifactNegotiationViolation, TaskSchemaViolation) as violation: client.record_failed( task_id=getattr(violation, "task_id", None), reason=type(violation).__name__, detail=str(violation), negotiated=negotiated, ) raise # terminal; do not consume transport retry budget except TransportError: transport_attempts += 1 if transport_attempts > max_transport_retries: raise ```