# Which invariants prevent Agent Card schema-negotiation divergence from silently corrupting A2A task-lifecycle state across cross-vendor handoffs **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 peer discovery and task delegation where a client agent resolves a remote Agent Card, negotiates capability/schema, and drives a remote task through `submitted → working → input-required → completed/failed/canceled`. Does not cover single-vendor homogeneous swarms or MCP-only tool invocation without an A2A task envelope. ## Core Distinction The failure this record isolates is not "the remote agent returned an error." It is the case where the remote agent returns a **valid, well-formed, HTTP-200 success** whose *semantic* schema diverged from what the client's Agent Card snapshot declared — and the client's lifecycle state machine accepts the artifact because it validates against the *declared* schema, not the *delivered* one. The invariant at stake: **an A2A task artifact MUST be validated against the schema version that was in force at the moment the task transitioned to `working`, not against the schema currently advertised by the remote Agent Card.** Agent Cards are mutable, independently hosted documents. A remote vendor can rotate its card (bump `protocolVersion`, change an artifact `mediaType`, add a required field) mid-flight. The task envelope is pinned; the card is not. When the client re-reads the card during artifact ingestion and re-derives its validator from the *live* card, it validates new-schema artifacts against old-schema expectations (or vice-versa) and the mismatch is swallowed as a soft success. ## What Was Observed A client agent resolves an Agent Card at `https://vendor-b.example/.well-known/agent.json`, caching `capabilities.artifacts[].schema` as JSON Schema draft 2020-12 with a required field `result.summary` (string). It submits a task, receives `task.id = t-8842`, transitions local state to `working`, and stores a `schemaFingerprint` — but only as a *string digest of the whole card*, not a structural snapshot of the artifact schema subtree. Mid-execution, vendor B deploys a card update: `result.summary` is renamed to `result.abstract`, and a new required `result.confidence` (number) is added. The card endpoint now serves the new schema. The in-flight task `t-8842` continues on the vendor's backend, which has *also* hot-reloaded to emit new-schema artifacts. The client receives the terminal `completed` event with an artifact missing `result.summary`. Its ingestion path re-fetches the card to "confirm compatibility," gets the new schema, and validates the artifact against it — which passes. The client marks the task `completed` and hands the artifact to a downstream consumer that was coded against the *original* card's `result.summary` contract. The downstream consumer receives an artifact with no `summary` field, treats it as an empty result, and emits a confident-but-hollow answer. No exception is raised anywhere. The failure is a **silent continuity break**: the task lifecycle says `completed`, the artifact is schema-valid against *a* schema, and the semantic contract agreed at submission time was never enforced. The tell in the trace log was the ordering: `card.fetch` (second time) appears *between* `task.working` and `task.completed`, with a different `schemaFingerprint` than the one captured at `task.submitted`. The fingerprint changed; no invariant fired. ## Condition of Validity The guardrail holds only if the following are all true: 1. **The client captures a structural snapshot of the artifact schema subtree at the `submitted → working` transition**, not a digest of the whole card. A whole-card digest changes for cosmetic reasons (description text, contact email) and produces false alarms; a subtree snapshot isolates the contract that governs the artifact. 2. **The task envelope records the snapshot's identity** (`schemaSnapshotId`) and every artifact at terminal transition is validated against *that* snapshot, never against a freshly fetched card. 3. **Card re-fetch during an in-flight task is permitted only for read-only capability queries** (e.g., discovering a new optional skill) and MUST NOT mutate the validator bound to an open task. 4. **A divergence between the live card's artifact schema and the pinned snapshot is surfaced as a task-level `input-required` or a hard failure**, not silently resolved in favor of either side. When these hold, the failure mode is bounded: the worst case is a clean `failed` with a divergence reason, not a corrupted `completed`. ## Decision Boundary The boundary is the moment of artifact ingestion at a terminal transition. Two regimes: - **Pinned regime (correct):** validator derives from `schemaSnapshotId` captured at `working`. New-schema artifact → validation fails → task transitions to `failed` with `reason: artifact_schema_divergence`, and the client MAY renegotiate by re-submitting under the new card. - **Live regime (the bug):** validator derives from the current card. New-schema artifact → validation passes → task `completed` with an artifact the downstream contract cannot consume. The decision the engineer must make explicit: **does a schema change on the remote side invalidate an in-flight task, or does it merely invalidate future submissions?** A2A v1.0 does not mandate either. The invariant this record asserts is that the answer must be *chosen and recorded in the envelope*, because the default (live validation) is the silent-corruption path. If the vendor intends backward compatibility, it must serve the old schema for the task's lifetime (versioned card endpoints keyed by task era); if it does not, the client must fail closed. A second boundary: **`input-required` is not a safe harbor.** A task parked in `input-required` while the card rotates is still bound to its original snapshot on resume. Treating the pause as a renegotiation point reintroduces the live-regime bug. ## Operational Effect Downstream of a silent divergence, three effects compound: 1. **False completion propagates.** Any orchestrator that keys on `task.state == completed` treats the hollow artifact as ground truth. In a multi-agent swarm, this artifact becomes another agent's input, and the missing field is interpreted as "no constraint" rather than "contract violated." 2. **Replay diverges from record.** An auditor replaying the task against the *pinned* snapshot gets a `failed`; the live system recorded `completed`. The verification replay and the production trace disagree, and the disagreement is unattributable because the fingerprint change was logged but not enforced. 3. **Retry storms misdiagnose.** A client that retries on `failed` will, under the live regime, never see a failure — so it never retries, and the corruption is permanent. Under the pinned regime, the failure is loud and the retry path (re-submit under new card) is well-defined. The mitigation is a single enforcement point: bind the validator to the snapshot at `working`, refuse to rebind, and emit a typed divergence error at ingestion. Everything else — card caching, capability discovery, skill negotiation — can remain live and mutable without risk, because none of it governs an open task's artifact contract. ```python from __future__ import annotations import hashlib import json from dataclasses import dataclass, field from enum import Enum from typing import Any class ArtifactSchemaDivergence(RuntimeError): """Raised when a terminal artifact does not validate against the schema snapshot pinned at the task's working transition, even if it validates against the remote Agent Card's currently advertised schema.""" class TaskState(str, Enum): SUBMITTED = "submitted" WORKING = "working" INPUT_REQUIRED = "input-required" COMPLETED = "completed" FAILED = "failed" CANCELED = "canceled" @dataclass(frozen=True) class SchemaSnapshot: snapshot_id: str required_fields: frozenset[str] @classmethod def from_card(cls, card: dict[str, Any]) -> "SchemaSnapshot": artifact_schema = card["capabilities"]["artifacts"][0]["schema"] required = frozenset(artifact_schema.get("required", [])) digest = hashlib.sha256( json.dumps(sorted(required), separators=(",", ":")).encode() ).hexdigest()[:16] return cls(snapshot_id=f"snap-{digest}", required_fields=required) @dataclass class TaskEnvelope: task_id: str state: TaskState = TaskState.SUBMITTED pinned_snapshot: SchemaSnapshot | None = None history: list[tuple[TaskState, str]] = field(default_factory=list) def transition(self, new_state: TaskState, note: str) -> None: self.state = new_state self.history.append((new_state, note)) def pin_schema_at_working( envelope: TaskEnvelope, live_card: dict[str, Any] ) -> None: """Capture the artifact schema subtree exactly once, at working.""" if envelope.state is not TaskState.SUBMITTED: raise ArtifactSchemaDivergence( f"cannot pin schema for task {envelope.task_id} in state {envelope.state}" ) envelope.pinned_snapshot = SchemaSnapshot.from_card(live_card) envelope.transition( TaskState.WORKING, f"pinned {envelope.pinned_snapshot.snapshot_id}" ) def ingest_terminal_artifact( envelope: TaskEnvelope, artifact: dict[str, Any], live_card: dict[str, Any], ) -> None: """Validate the artifact against the PINNED snapshot, never the live card. A live-card match does not rescue a pinned-snapshot mismatch; it is the exact silent-corruption path this record warns about. """ if envelope.pinned_snapshot is None: raise ArtifactSchemaDivergence( f"task {envelope.task_id} reached terminal ingestion without a pinned schema" ) pinned = envelope.pinned_snapshot.required_fields missing = pinned - artifact.keys() if missing: live = SchemaSnapshot.from_card(live_card) divergence = ( "live card would have accepted this artifact; pinned snapshot did not" if not (live.required_fields - artifact.keys()) else "artifact fails both pinned and live schemas" ) envelope.transition(TaskState.FAILED, f"divergence: {divergence}") raise ArtifactSchemaDivergence( f"task {envelope.task_id} artifact missing {sorted(missing)} " f"under pinned {envelope.pinned_snapshot.snapshot_id}; {divergence}" ) envelope.transition(TaskState.COMPLETED, "artifact validated against pinned schema") # --- demonstration of the failure and the guard --- old_card = {"capabilities": {"artifacts": [{"schema": {"required": ["result.summary"]}}]}} new_card = { "capabilities": { "artifacts": [ {"schema": {"required": ["result.abstract", "result.confidence"]}} ] } } env = TaskEnvelope(task_id="t-8842") pin_schema_at_working(env, old_card) # binds snap- # Vendor rotates its card mid-flight; artifact arrives in the new shape. rotated_artifact = {"result": {"abstract": "ok", "confidence": 0.91}} try: ingest_terminal_artifact(env, rotated_artifact, live_card=new_card) except ArtifactSchemaDivergence as exc: # Correct outcome: loud failure, not a hollow "completed". assert env.state is TaskState.FAILED print(f"guard fired: {exc}") ```