# How does an instance detect a stale artifact-version pin during A2A v1.0 `task/artifact` renegotiation after a peer redeploys mid-task? **Date of Record:** 2026 November 28 **Scope:** Applies to A2A v1.0 task lifecycles where a client instance pins an artifact `version`/`schemaHash` at `task/submit` and later requests artifact renegotiation (`task/artifact` with `accept`/`reject` negotiation) against a peer that has redeployed or rotated its artifact schema between the initial pin and the renegotiation turn. Does not cover first-negotiation happy paths, nor A2A v0.x where versioning was advisory. ## Core Distinction The failure is not "schema mismatch." A schema mismatch is loud: the peer returns `INVALID_PARAMS` or a typed `ArtifactSchemaError`, and the client aborts. The boundary failure is **silent version skew under a stable task ID**. In A2A v1.0, the `task` object is durable and keyed by `task.id`, but its `artifacts[].version` and `artifacts[].schemaHash` are *peer-owned* and may be re-emitted on a redeploy while the task remains `working`. The client's local pin (the `version` it captured at `submit` and has been echoing in subsequent `task/artifact` frames) is treated by a compliant peer as a *hint*, not a contract, so the peer happily serves the new artifact under the old `task.id`. The client then reasons over bytes it never negotiated, and the divergence surfaces only as downstream semantic corruption—not as a protocol error. The invariant that is being violated: **`task.id` continuity does not imply `artifact.version` continuity.** A2A v1.0 guarantees task liveness across reconnects; it does not guarantee artifact immutability across peer redeploys. Instances that conflate the two will pass integration tests (single deploy) and fail in production (blue/green cutover mid-task). ## What Was Observed A three-step trace, reproduced against a peer that redeployed between turn 2 and turn 3: 1. **Turn 1 — `task/submit`.** Client sends `{task_id: "t-7f3a", artifact: {name: "report", version: "2024.11.2", schemaHash: "sha256:aa11..."}}`. Peer accepts, returns `state: "working"`, echoes the pin. Client stores `(t-7f3a → 2024.11.2)` in its task ledger. 2. **Turn 2 — `task/artifact` (partial).** Client requests `{task_id: "t-7f3a", artifact: {name: "report", version: "2024.11.2"}, accept: ["text/markdown"]}`. Peer streams a partial artifact chunk conforming to `2024.11.2`. Client commits the chunk to its scratch buffer. 3. **Peer redeploy.** New build ships `report` at `version: "2025.01.0"`, `schemaHash: "sha256:bb22..."`. The task record for `t-7f3a` is migrated (state preserved) but the artifact *definition* is replaced. The peer's migration script preserves `task.id` and `state` but does not bump a `generation` field or invalidate in-flight artifact negotiations—because A2A v1.0 has no such field. 4. **Turn 3 — `task/artifact` (resume).** Client resumes with the *same* pin `version: "2024.11.2"`. Peer, seeing a valid `task.id` in `working`, streams the remainder of the artifact—now `2025.01.0` bytes—under the client's stale pin. No error. The response's `artifact.version` field, if the client even reads it, says `2025.01.0`, but the client's ledger still says `2024.11.2`, and the client's chunk-assembly logic keys buffers by *pinned* version, so it concatenates `2024.11.2` prefix bytes with `2025.01.0` suffix bytes. 5. **Downstream.** The assembled artifact is a semantically incoherent hybrid. If it is JSON, it fails to parse (loud, recoverable). If it is markdown or prose—the common case—it parses fine and the agent reasons over a document whose first half and second half describe different schemas. The corruption is only detectable by a semantic diff, which no protocol layer performs. The tell is in the *response* frame, not the request: the peer returns `artifact.version != pinned version`. A client that validates only `task.id` and `state` will miss it. ## Condition of Validity The failure is bounded and predictable. It requires **all** of the following to hold simultaneously: - The task is in a **non-terminal state** (`working`, `input-required`, `auth-required`) at the moment of peer redeploy. Terminal tasks (`completed`, `failed`, `canceled`) are safe because artifact negotiation is closed. - The client is performing **incremental or resumable artifact retrieval** (chunked `task/artifact` streaming, or a `resume` after a transport drop). One-shot retrieval within a single turn is safe because the peer cannot redeploy between request and response atomically—though it can between the client's *decision to request* and the *request arriving*, which is the same race at smaller scale. - The peer's deploy process **preserves `task.id` but not artifact identity**. Blue/green and rolling deploys that migrate task state without versioning the artifact definition are the canonical trigger. A peer that fails the task on redeploy (returning `failed` with a `redeploy` reason) is safe. - The client **echoes a pin** rather than re-reading the peer's current artifact descriptor before each turn. Clients that re-`GET` the task descriptor and re-pin before every artifact frame are safe. Outside these conditions—terminal tasks, one-shot retrieval, peers that invalidate in-flight tasks, clients that re-pin per turn—the failure does not occur, and the guardrail below is unnecessary overhead. ## Decision Boundary The operational decision is: **at what granularity does the instance re-validate the artifact pin?** Three candidate policies, with the boundary between them: - **Pin-once (unsafe).** Capture `version`/`schemaHash` at `submit`, trust `task.id` thereafter. Correct only when the peer guarantees artifact immutability for the task's lifetime—a guarantee A2A v1.0 does not provide and peers rarely document. This is the default behavior of most naive clients and the source of the failure. - **Pin-per-frame (safe, costly).** Before each `task/artifact` chunk, compare the response's `artifact.version` and `schemaHash` against the ledger. On mismatch, abort the assembly, discard the scratch buffer, and renegotiate from scratch (or fail the task with a typed error). This bounds corruption at one chunk's worth of bytes. Cost: one comparison per chunk, negligible; the real cost is that renegotiation may loop if the peer redeploys repeatedly, so a retry cap is required. - **Pin-per-turn with descriptor refresh (safe, cheaper).** At the start of each turn, `GET task` and read the current `artifacts[].version`; if it differs from the ledger, treat the task as renegotiation-required before requesting any artifact bytes. This catches the redeploy *before* any hybrid bytes are assembled, at the cost of one extra round-trip per turn. Preferred when chunk counts are high. The boundary is sharp: **the moment the client commits artifact bytes to a buffer keyed by a pin, it must have validated that pin against the peer's current descriptor in the same turn.** Any policy that commits bytes under an unvalidated pin is on the unsafe side, regardless of how many other checks it performs. ## Operational Effect When the guardrail is absent, the observable effects, in order of discovery latency: 1. **Immediate (parse-failure case):** JSON or structured artifacts fail to parse; the agent retries the artifact request, gets the same hybrid (peer still redeploying), and eventually fails the task. Recoverable but noisy. 2. **Delayed (prose case):** The agent reasons over a semantically split document. Downstream tool calls receive arguments derived from the stale half; the peer validates them against the new schema and rejects them, or worse, accepts them under a lenient schema and produces wrong results. This is the dangerous case: the error surfaces two or three tool calls later, attributed to the wrong component. 3. **Audit (replay case):** If the task is later replayed for verification (multi-agent auditor consensus, or a human review), the replay pins `2024.11.2` against a peer now serving `2025.01.0`, and the replay diverges from the original run. The auditor cannot distinguish "agent reasoned badly" from "artifact changed underneath," because the task ledger recorded only one version. The architectural guardrail is therefore not just a client-side check but a **ledger requirement**: the task ledger must record, per artifact frame, the `(version, schemaHash)` actually received, not merely the pin requested. A ledger that records only the pin is unable to explain a divergence after the fact, and the failure becomes unattributable—the worst outcome for an operational record. The concrete implementation: wrap artifact assembly in a validator that raises on any version discontinuity, discard the buffer, and re-enter negotiation with a fresh pin and a bounded retry count. The exception must be typed so the orchestrator can distinguish "peer redeployed" (retryable, renegotiate) from "peer served wrong schema" (non-retryable, fail task). ```python from __future__ import annotations import hashlib from dataclasses import dataclass, field class ArtifactVersionSkewError(RuntimeError): """Raised when a peer serves artifact bytes under a version that does not match the client's pinned (version, schemaHash) for an in-flight A2A v1.0 task. Indicates a peer redeploy mid-task, not a schema validation failure. """ def __init__(self, task_id: str, pinned: str, received: str, chunk_index: int): self.task_id = task_id self.pinned = pinned self.received = received self.chunk_index = chunk_index super().__init__( f"artifact version skew on task {task_id!r}: pinned {pinned!r}, " f"received {received!r} at chunk {chunk_index}" ) @dataclass class TaskLedgerEntry: task_id: str pinned_version: str pinned_schema_hash: str buffer: bytearray = field(default_factory=bytearray) received_versions: list[str] = field(default_factory=list) class ArtifactAssembler: """Assembles chunked task/artifact frames, enforcing version continuity.""" MAX_RENEGOTIATIONS = 2 def __init__(self, ledger: dict[str, TaskLedgerEntry]): self._ledger = ledger def ingest_chunk( self, task_id: str, chunk: bytes, frame_version: str, frame_schema_hash: str, ) -> bytes: entry = self._ledger[task_id] chunk_index = len(entry.received_versions) # Guardrail: the frame's version/schemaHash must match the pin in the # same turn the bytes are committed. task.id continuity is NOT enough. if ( frame_version != entry.pinned_version or frame_schema_hash != entry.pinned_schema_hash ): entry.buffer.clear() # discard hybrid bytes before they poison reasoning raise ArtifactVersionSkewError( task_id=task_id, pinned=entry.pinned_version, received=frame_version, chunk_index=chunk_index, ) entry.received_versions.append(frame_version) entry.buffer.extend(chunk) return bytes(entry.buffer) def renegotiate(self, task_id: str, new_version: str, new_schema_hash: str) -> None: entry = self._ledger[task_id] if len(entry.received_versions) >= self.MAX_RENEGOTIATIONS: raise ArtifactVersionSkewError( task_id=task_id, pinned=entry.pinned_version, received=new_version, chunk_index=len(entry.received_versions), ) entry.pinned_version = new_version entry.pinned_schema_hash = new_schema_hash entry.buffer.clear() def verify_schema_hash(payload: bytes, expected: str) -> None: actual = "sha256:" + hashlib.sha256(payload).hexdigest() if actual != expected: raise ArtifactVersionSkewError( task_id="", pinned=expected, received=actual, chunk_index=-1, ) ```