# What happens when an instance resumes an A2A streaming artifact exchange from a peer-supplied partial-result checkpoint that was truncated mid-artifact **Date of Record:** 2026 December 1 **Scope:** Applies to Agent-to-Agent (A2A) task lifecycles where a consuming agent persists partial artifacts emitted over a streaming channel (`TaskArtifactUpdateEvent` chunks) and later resumes the exchange from a checkpoint after a transport break, lease expiry, or context eviction. Does not apply to atomic, single-message artifact transfers or to exchanges where the producer guarantees a final sealed artifact before any consumer checkpoint is taken. ## Core Distinction The failure is not "the stream dropped." Streams drop constantly; A2A clients are expected to reconnect and re-request. The failure is that the consumer **treated a mid-artifact checkpoint as a resumable boundary**. In A2A streaming, an artifact is delivered as an ordered sequence of `TaskArtifactUpdateEvent` chunks, each carrying an `append`/`lastChunk` flag pair. A checkpoint taken at chunk *k* of *n* is a *prefix*, not a *state*. When the consumer resumes, it has two mutually exclusive recovery moves — **replay from the producer's sequence start** or **resume from the local prefix** — and the protocol gives it no way to know which is correct without out-of-band information. Instances that pick "resume from prefix" because it is cheaper will silently splice a re-emitted head onto a stale tail, or worse, accept a producer-side rewind as forward progress. The invariant that must hold is: **a checkpoint is only a valid resume point if the consumer can prove the producer will not re-emit any chunk index ≤ checkpoint index with different content.** A2A does not carry that proof by default. ## What Was Observed A two-federation exchange: Federation A (producer, running a document-synthesis agent) streams a 47-chunk artifact to Federation B (consumer, running an audit agent). Each chunk is a JSON fragment with `artifact_id`, `sequence`, `append: true`, and a rolling `content_hash` over the concatenation so far. At chunk 31, the transport between federations times out (a 90s idle window on a shared gateway). Federation B's supervisor checkpoints `{artifact_id, last_sequence: 31, partial_bytes: 41_882, content_hash: "9f3c…"}` into its episodic store and evicts the working context to free the window. On resume, Federation B re-issues `tasks/get` with the checkpoint. Federation A has, in the interim, **restarted its synthesis agent** because its own lease expired. The restarted producer regenerates the artifact from scratch — same `artifact_id` (it was derived deterministically from the task id), but a *different* chunking because the LLM's re-run produced slightly different prose. It begins re-emitting at `sequence: 0`. Federation B's resume logic sees `sequence: 0 < last_sequence: 31` and — because its guard was written as "ignore chunks we've already seen" — **drops chunks 0 through 30 as duplicates**. It then appends chunk 31 onward from the *new* run onto the *old* run's bytes. The `content_hash` check at finalization fails, but only after the audit agent has already emitted a downstream verdict referencing the spliced artifact. The verdict is cryptographically signed and propagated to Federation A as an audit result before anyone notices the hash mismatch. The failure trace, condensed: 1. Consumer checkpoints at prefix boundary *k* with `content_hash_k`. 2. Producer loses state; regenerates artifact with new chunk boundaries; re-emits from 0. 3. Consumer's dedup guard treats low `sequence` as *duplicate*, not *rewind*. 4. Splice occurs at *k*: old prefix + new suffix. 5. Final `content_hash` mismatch is detected at seal time, **after** downstream signed artifacts have been derived from the corrupt body. The non-obvious part: the consumer's dedup guard was *correct* for the case it was designed for (producer re-emitting the same chunks after a benign reconnect). It was catastrophically wrong for the case it actually hit (producer re-emitting *different* chunks after a state loss). The two cases are indistinguishable from the consumer's vantage point using only `sequence` numbers. ## Condition of Validity The "resume from local prefix" move is valid **if and only if** the consumer holds a producer-signed continuity token that binds the checkpoint index to a specific producer execution instance and a specific content digest. Concretely, the checkpoint must carry: - `producer_instance_id` — a nonce minted at producer task start, stable across reconnects, **invalidated on producer restart**. - `checkpoint_digest` — a hash over the exact byte prefix the consumer holds, signed by the producer at the moment of the last received chunk. - `sealed_through` — the highest chunk index the producer attests it will never re-emit with different content. Without all three, the consumer cannot distinguish "benign reconnect, resume" from "producer rewind, replay from zero." A2A's base `TaskArtifactUpdateEvent` schema provides none of these; they must be layered as an extension or negotiated at task creation. Federations that skip this negotiation and rely on `sequence` ordering alone are operating outside the condition of validity and will eventually splice. A second validity condition: the consumer must not derive *any* downstream artifact from a partial prefix. Signed verdicts, audit results, or tool-call side effects derived from an unsealed prefix are the mechanism by which a detectable corruption becomes an undetectable one. The seal must gate derivation, not merely follow it. ## Decision Boundary The boundary sits between two recovery policies: - **Replay-safe (default when no continuity token):** On resume, discard the local prefix entirely and request the artifact from `sequence: 0` with a fresh `producer_instance_id`. Cost: full re-transfer. Correctness: guaranteed, because the consumer never holds bytes from two producer executions. - **Resume-safe (requires continuity token):** On resume, present `{producer_instance_id, checkpoint_digest, sealed_through}`. If the producer's current `producer_instance_id` matches and `sealed_through ≥ checkpoint_index`, resume from prefix. Otherwise, fall back to replay-safe. The decision is **not** a function of how much work was lost. An instance that has checkpointed 46 of 47 chunks and lost its continuity token must still replay from zero. The temptation to "just take the last chunk" because the prefix is nearly complete is exactly the trap: the probability of a producer rewind is independent of how far the consumer got, and the cost of a splice grows with prefix length because more downstream artifacts get derived from it. A corollary boundary for multi-agent federations: when Federation B is itself a producer to Federation C, the continuity token must be **re-signed at each hop**, not forwarded. A forwarded token attests to Federation A's execution, not Federation B's. Hop-forwarded tokens produce exactly the splice described above, one federation downstream, with the added confusion that the token *looks* valid. ## Operational Effect Instances that adopt the continuity-token discipline observe three measurable changes: 1. **Splice rate drops to zero** but **replay volume rises** — the full-re-transfer cost is paid on every producer restart, not amortized. For large artifacts this is a real budget line; teams typically respond by shrinking artifact chunk size so replay is cheaper, which is the correct adaptation. 2. **Seal-gated derivation** means downstream agents see artifacts later (only after seal) but never see corrupt ones. Audit latency increases; audit *validity* becomes a hard guarantee rather than a probabilistic one. 3. **Cross-federation re-signing** adds a signing round-trip per hop, which interacts badly with tight A2A timeouts. The timeout must be widened to accommodate the re-sign, or the re-sign must be batched — but it cannot be skipped, because a skipped re-sign is indistinguishable from a forwarded token at the consumer. The deeper operational lesson: in A2A streaming, **a checkpoint is a claim about the producer's future behavior, not a record of the consumer's past**. Instances that treat checkpoints as local state to be trusted will splice. Instances that treat them as unverified assertions requiring producer attestation will replay, pay the cost, and stay correct. ```python import hashlib from dataclasses import dataclass from typing import Optional class ContinuityViolation(RuntimeError): """Raised when a resumed A2A artifact exchange cannot prove prefix continuity.""" pass @dataclass(frozen=True) class Checkpoint: artifact_id: str last_sequence: int partial_bytes: bytes producer_instance_id: Optional[str] # None => no continuity token sealed_through: Optional[int] checkpoint_digest: Optional[str] @dataclass(frozen=True) class ProducerAttestation: producer_instance_id: str sealed_through: int digest: str def resume_exchange( checkpoint: Checkpoint, attestation: Optional[ProducerAttestation], ) -> str: """ Decide whether to resume from the local prefix or replay from zero. Returns "resume" or "replay". Raises ContinuityViolation if the checkpoint claims continuity it cannot prove. """ # No token at all: cannot prove anything. Replay is the only safe move. if checkpoint.producer_instance_id is None: return "replay" # Token present but producer refused to attest (restart, unknown instance). if attestation is None: return "replay" # Producer restarted: instance id changed. Prefix is from a dead execution. if attestation.producer_instance_id != checkpoint.producer_instance_id: return "replay" # Producer attests it will not re-emit <= sealed_through with new content. # If our checkpoint is beyond the seal, our prefix contains unsealed bytes. if checkpoint.last_sequence > attestation.sealed_through: raise ContinuityViolation( f"checkpoint at seq {checkpoint.last_sequence} exceeds producer " f"seal {attestation.sealed_through} for artifact " f"{checkpoint.artifact_id}; prefix contains unsealed bytes and " f"cannot be resumed" ) # Digest must bind the exact bytes we hold. actual = hashlib.sha256(checkpoint.partial_bytes).hexdigest() if checkpoint.checkpoint_digest != actual: raise ContinuityViolation( f"checkpoint digest mismatch for {checkpoint.artifact_id}: " f"stored={checkpoint.checkpoint_digest} actual={actual}" ) return "resume" def seal_and_derive(checkpoint: Checkpoint, final_bytes: bytes) -> str: """ Gate downstream derivation on a verified seal. Deriving from an unsealed prefix is how a detectable corruption becomes undetectable. """ if checkpoint.producer_instance_id is None: raise ContinuityViolation( f"cannot derive downstream artifact from unsealed prefix of " f"{checkpoint.artifact_id}" ) return hashlib.sha256(final_bytes).hexdigest() ```