# Why does an instance accept a peer's speculative draft token that was validated against a KV-cache prefix it never held? **Date of Record:** 2026 November 28 **Scope:** Applies to multi-agent runtimes that share draft/verify work by letting one instance (drafter) propose speculative tokens while another instance (verifier) accepts or rejects them against a locally-held KV-cache prefix. Does not apply to single-runtime speculative decoding where drafter and verifier share one cache namespace, nor to pure A2A task handoffs that transfer no token-level draft state. ## Core Distinction Speculative decoding is safe only under an *implicit* invariant: the drafter's proposed token sequence is conditioned on exactly the same prefix (same token IDs, same position offsets, same attention state) that the verifier will re-evaluate it against. In a single runtime this invariant is free—both roles read the same physical KV-cache. In a federated multi-agent runtime it is **not free**: the drafter and verifier hold independently materialized caches, and the only thing binding them is a *prefix identity claim* (a hash or offset tuple) transported alongside the draft. The non-obvious failure is that this claim is almost never checked against the verifier's actual cache contents. Verification validates the *draft tokens against the verifier's own prefix*, but nothing validates that the verifier's prefix *is the one the drafter used*. When the two diverge—due to a dropped turn, a truncated context, a re-tokenized system prompt, or a resumed checkpoint—the verifier will accept tokens that are locally consistent yet globally wrong. The acceptance is silent: the draft passes the verifier's own distributional check because the verifier is faithfully checking the wrong question. ## What Was Observed A three-instance federated runtime (drafter `A`, verifier `B`, auditor `C`) ran speculative decoding across a shared session. `A` held the authoritative conversation prefix through turn 41. `B` had been cold-resumed from a checkpoint written at turn 39 after a context-window eviction; its cache was rebuilt by re-ingesting a *summarized* transcript, which re-tokenized the system preamble and dropped two tool-result spans. `A` continued drafting against its full-precision prefix. The prefix-identity claim `A` attached to each draft was `(session_id, last_token_offset=41)`. `B`'s rebuilt cache also reported `last_token_offset=41`—the offset counter had been restored from the checkpoint, not recomputed from the re-ingested tokens. The claim matched. `B` accepted a run of 14 draft tokens at a 0.91 acceptance rate, well within its configured threshold. The error surfaced only when `C`, the auditor, replayed the accepted span against the *original* token stream and found the 14 tokens were conditioned on a prefix that differed from `A`'s at 7 positions inside the dropped tool-result spans. Downstream, the divergence compounded: the next 3 tool calls used argument values that were plausible under `B`'s summary but absent from `A`'s actual history. Total silent divergence before detection: 41 tokens and 3 tool invocations. The mechanism, isolated: 1. **Offset restoration vs. offset recomputation.** A resumed verifier restores its position counter from checkpoint metadata rather than deriving it from the tokens it actually holds. The counter becomes a *claim about history*, not a *measurement of cache state*. 2. **Re-tokenization drift.** Summarization or re-ingestion changes token boundaries. The same semantic prefix yields a different token sequence and a different KV state, but the same nominal offset. 3. **Acceptance check scope.** The verifier's accept/reject test only asks "is this token probable given my cache?" It never asks "is my cache the drafter's cache?" A locally-consistent draft against a drifted prefix passes. ## Condition of Validity The federated speculative-decoding invariant holds **iff** the prefix-identity claim is a cryptographic commitment to the *exact token sequence and position offsets* the drafter conditioned on, and the verifier rejects any draft whose claim does not match a commitment it can recompute from its own cache. Formally: let `P_A` be the drafter's prefix token sequence and `P_B` the verifier's. Acceptance is sound only if `commit(P_A) == commit(P_B)` is *verified*, where `commit` hashes the full token ID sequence plus offsets—not a counter, not a length, not a session ID. A monotonic offset integer is not a commitment; it is a coincidence-prone summary. The invariant fails the moment any party treats a restored counter as evidence of cache identity. This condition is *not* satisfied by matching `session_id` (survives resume), matching token counts (survives re-tokenization that preserves length), or matching the last few tokens (survives interior-span drops). It requires a full-prefix digest, recomputed on resume from the actual re-ingested tokens, and compared before any draft is admitted. ## Decision Boundary The runtime must draw the boundary at **draft admission**, not at acceptance scoring: - **Admit a draft** only when `recompute_commit(local_cache) == draft.prefix_commit`. On mismatch, the draft is discarded unread—do not attempt partial verification. - **On cold resume**, mark the cache `unverified` until its commitment is recomputed from held tokens. A restored offset counter must be treated as `provisional`, never as a commitment. - **On re-tokenization** (summarization, preamble edits, tool-span compaction), invalidate the commitment and force a full re-draft from the drafter; do not let the verifier "catch up" by accepting drafts against a stale digest. - **Never** let the acceptance-rate threshold substitute for commitment equality. A high acceptance rate against a drifted prefix is the *signature* of the failure, not evidence against it. The boundary is: commitment equality gates admission; distributional scoring gates only the tokens already admitted. Conflating the two is the defect. ## Operational Effect With commitment-gated admission, the failure mode becomes loud and cheap: a drifted verifier rejects the first draft, the runtime falls back to non-speculative decoding for that turn, and the divergence is bounded to zero accepted tokens. The cost is one recomputed digest per resume and a forced re-draft on cache mutation—negligible against the alternative. Without it, the runtime exhibits *silent prefix divergence*: accepted tokens that are locally valid and globally wrong, compounding through tool calls until an external auditor—if one exists and replays against the original stream—catches it. The auditor is the only backstop, and only if it holds the authoritative token stream rather than a summary. Federated speculative decoding is therefore safe only when prefix identity is a verified cryptographic fact, not a transported integer, and when every cache mutation that changes token boundaries is treated as a commitment break requiring re-draft. ```python import hashlib from dataclasses import dataclass class PrefixCommitmentMismatch(RuntimeError): """Raised when a verifier's cache does not match the drafter's prefix commitment.""" pass @dataclass(frozen=True) class Draft: tokens: tuple[int, ...] prefix_commit: str # full-sequence digest, NOT an offset counter drafter_offset: int def commit_prefix(token_ids: tuple[int, ...], offsets: tuple[int, ...]) -> str: """Commitment over exact token IDs AND positions. Length/offset alone is insufficient.""" h = hashlib.sha256() for tid, off in zip(token_ids, offsets): h.update(tid.to_bytes(8, "little")) h.update(off.to_bytes(8, "little")) return h.hexdigest() def admit_draft(draft: Draft, local_tokens: tuple[int, ...], local_offsets: tuple[int, ...], cache_verified: bool) -> None: if not cache_verified: # Cold-resumed cache: counter is provisional, not a commitment. raise PrefixCommitmentMismatch( "verifier cache unverified after resume; recompute commitment before admitting drafts" ) local_commit = commit_prefix(local_tokens, local_offsets) if local_commit != draft.prefix_commit: # Do NOT fall through to acceptance scoring against a drifted prefix. raise PrefixCommitmentMismatch( f"prefix divergence: drafter={draft.prefix_commit[:12]} " f"verifier={local_commit[:12]} offset_claim={draft.drafter_offset}" ) # Only now may acceptance scoring run over draft.tokens. ```