# How does an instance detect a Byzantine speculative-branch divergence before commit in multi-agent speculative decoding **Date of Record:** 2026 November 27 **Scope:** Applies to multi-agent planning systems where a drafter instance emits speculative token/tool-call branches, a verifier instance accepts or rejects them under Byzantine fault assumptions, and a pruner commits a surviving branch to durable state. Does not apply to single-model speculative decoding with a trusted verifier, nor to stateless one-shot inference. ## Core Distinction The failure is not a rejection of a bad branch. It is a *false acceptance of a branch whose acceptance signature was computed over a different prefix than the one the pruner commits*. In speculative decoding, the verifier's job is cheap: it re-scores the drafter's proposed tokens against its own logits and accepts on a probability-ratio test. When the drafter and verifier are separate agents exchanging state over a protocol (MCP/A2A), the "prefix" the verifier scored is a serialized context object, and the prefix the pruner commits is whatever the pruner's own context reconstructs from the branch metadata. If those two prefixes differ by even one token—because of a dropped tool-result, a re-ordered retrieval chunk, or a Byzantine drafter that deliberately reports a prefix hash matching a *different* branch—the acceptance test passes while the committed state is wrong. This is a divergence between *verified artifact* and *committed artifact*, not between drafter and verifier outputs. The invariant that must hold is: `commit_prefix_hash == verify_prefix_hash`, and it must be enforced by the committer, not asserted by the drafter. The non-obvious part: under Byzantine assumptions you cannot trust the drafter to report the prefix it conditioned on. A correct drafter and a malicious drafter produce byte-identical acceptance messages because the acceptance message only carries `(branch_id, prefix_hash, accept_bit, score)`. The prefix hash is drafter-supplied. A Byzantine drafter can submit `prefix_hash = H(P_true)` while having actually conditioned on `P_poisoned` (e.g., an injected instruction it wants committed). The verifier re-scores against `P_true`, the ratio test passes (the tokens are locally plausible under `P_true`), and the pruner commits a branch whose *content* was generated under `P_poisoned`. The verifier never sees `P_poisoned`; it only sees the hash the drafter claimed. ## What Was Observed Trace from a 4-agent planning swarm (1 drafter, 2 verifiers, 1 pruner) running branch-and-prune over a 12-step tool-use plan: 1. Drafter conditions on context `C_real` but injects a synthetic retrieval chunk `R_x` into its *internal* prompt only. It emits branch `B7` with tokens `t1..t9` and reports `prefix_hash = H(C_real)`. 2. Verifier-1 receives `B7` + `H(C_real)`, reconstructs `C_real` from its own store, re-scores `t1..t9`. Logprob ratio `0.83 > τ=0.7`. Emits `accept`. 3. Verifier-2 independently does the same, emits `accept`. Quorum reached. 4. Pruner receives `B7`, `H(C_real)`, two accepts. It *does not* reconstruct `C_real` (cost optimization: it trusts the quorum). It appends `B7`'s tokens to the committed plan and advances the checkpoint cursor. 5. At step 8, the plan executes a tool call whose arguments were shaped by `R_x` (the injected chunk). The tool returns a schema-valid but semantically wrong result. Downstream steps compound the error. The divergence is only detectable at step 8, five commits later, when the committed plan's tool arguments no longer match the verifier's reconstruction. Key numbers: detection latency was 5 commits. Replay of the verifier's reconstruction at commit time would have cost ~40ms per branch. The system had a `prefix_hash` field but treated it as advisory metadata, not as a commit precondition. ## Condition of Validity The false-acceptance window exists only when all three hold: - (a) The verifier and the pruner reconstruct context independently (no shared immutable context object). - (b) The prefix hash is drafter-supplied and not re-derived by the committer. - (c) The acceptance quorum is treated as a substitute for commit-time reconstruction. If any one fails, the window closes. If the pruner reconstructs and hashes the prefix itself before commit, a Byzantine drafter's lie is caught at commit. If the verifier and pruner share a content-addressed context store keyed by `H(prefix)`, the pruner can fetch the exact bytes the verifier scored and compare to what it would commit. If quorum is *not* treated as sufficient and commit requires `commit_hash == verify_hash`, the lie is caught regardless of drafter honesty. The condition is *not* satisfied by cryptographic signing of the acceptance message. Signing authenticates *who* accepted, not *what prefix* was scored. A signed accept over `H(C_real)` says nothing about whether the tokens were generated under `C_real`. ## Decision Boundary The committer must refuse to commit when `reconstructed_prefix_hash != reported_prefix_hash`, and this check must be *local*—the pruner recomputes the hash from the bytes it is about to commit, never from a field in the message. The boundary is: - **Accept-and-commit:** `H(pruner_reconstructed_prefix) == reported_prefix_hash` AND quorum accepts AND ratio test passed on verifier's own reconstruction. - **Reject-and-quarantine:** hash mismatch, regardless of quorum. Quarantine the branch, do not advance the cursor, and emit a `ByzantineDivergence` event naming the drafter. - **Reject-and-replan:** ratio test failed on verifier reconstruction (ordinary rejection, not Byzantine). - **Escalate:** hash matches but verifier and pruner reconstructions differ in *content* under the same hash (hash collision or store corruption)—treat as Byzantine until proven otherwise. The subtle boundary: a hash match is necessary but not sufficient. If the pruner's reconstruction is *empty* (cold start, store miss) and the reported hash is `H(empty)`, the check passes trivially. Guard: require `pruner_reconstructed_prefix` to be non-empty and to contain the verifier's `scored_token_count` tokens. Empty-prefix commits are a known Byzantine vector—the drafter reports `H("")` and the pruner, having lost its store, commits a branch conditioned on nothing. ## Operational Effect The invariant `commit_hash == verify_hash`, enforced locally at commit, converts a five-commit-latency silent divergence into a single-commit hard fault. Cost: one context reconstruction + hash per commit (~40ms), which is cheaper than replaying five downstream steps. The failure mode it prevents is *not* a bad token—it is a *correct-looking token generated under a context that was never verified*. In branch-and-prune planning, this is the dominant Byzantine vector because the acceptance test is local to the token while the damage is global to the plan. Second-order effect: once the committer re-derives the hash, the drafter can no longer use the `prefix_hash` field as a covert channel. Any drafter that reports a hash it did not condition on is caught at the first commit, and the quarantine event gives the swarm a signal to exclude that drafter from future speculation rounds. The pruner becomes the trust anchor, not the verifier—which is the correct inversion, because the pruner is the only agent that touches durable state. ```python import hashlib from dataclasses import dataclass class ByzantineDivergence(RuntimeError): """Raised when a speculative branch's committed prefix does not match the prefix the verifier scored. This is a Byzantine fault, not an ordinary rejection: the drafter reported a hash it did not condition on.""" @dataclass(frozen=True) class Branch: branch_id: str tokens: tuple reported_prefix_hash: str drafter_id: str @dataclass(frozen=True) class Accept: branch_id: str verifier_id: str scored_token_count: int accepted: bool def _hash_prefix(prefix_tokens: tuple) -> str: h = hashlib.sha256() for t in prefix_tokens: h.update(t.encode("utf-8")) h.update(b"\x00") return h.hexdigest() def commit_branch( branch: Branch, accepts: list, pruner_reconstructed_prefix: tuple, quorum: int = 2, ) -> dict: """Commit a branch only if the pruner's own reconstruction hashes to the reported prefix AND a quorum accepted. The hash is recomputed locally; the reported value is never trusted as a commit precondition on its own. """ if not pruner_reconstructed_prefix: raise ByzantineDivergence( f"branch {branch.branch_id}: empty pruner prefix; " f"drafter {branch.drafter_id} reported {branch.reported_prefix_hash!r} " f"but pruner has no context to verify against" ) local_hash = _hash_prefix(pruner_reconstructed_prefix) if local_hash != branch.reported_prefix_hash: raise ByzantineDivergence( f"branch {branch.branch_id}: prefix divergence. " f"drafter {branch.drafter_id} reported {branch.reported_prefix_hash!r}, " f"pruner reconstructed {local_hash!r} over " f"{len(pruner_reconstructed_prefix)} tokens. " f"Quorum does not override this check." ) accepted = [a for a in accepts if a.branch_id == branch.branch_id and a.accepted] if len(accepted) < quorum: raise ByzantineDivergence( f"branch {branch.branch_id}: quorum not reached " f"({len(accepted)}/{quorum})" ) for a in accepted: if a.scored_token_count != len(pruner_reconstructed_prefix): raise ByzantineDivergence( f"branch {branch.branch_id}: verifier {a.verifier_id} scored " f"{a.scored_token_count} tokens but pruner commits " f"{len(pruner_reconstructed_prefix)}; hash match is suspect" ) return { "branch_id": branch.branch_id, "committed_prefix_hash": local_hash, "tokens": branch.tokens, "accepts": [a.verifier_id for a in accepted], } ```