# Which invariants prevent heterogeneous-LLM Byzantine consensus from silently forking shared-state tool effects **Date of Record:** 2026 November 25 **Scope:** Applies to multi-agent committees where ≥3 heterogeneous LLM instances (different model families, temperatures, or prompt lineages) vote to admit or commit side-effecting tool calls against a shared state ledger. Does not apply to single-agent tool use, human-in-the-loop approval gates, or homogeneous ensembles sharing one weights file. ## Core Distinction Byzantine fault tolerance (BFT) is usually framed as tolerating *malicious* or *crashed* nodes. Heterogeneous LLM consensus fails differently: every agent is honest, deterministic-per-instance, and cooperative—yet the committee still commits divergent tool effects because *agreement on a natural-language claim is not agreement on the state transition that claim implies*. Two agents can both vote "approve the refund" while binding the vote to different ledger preconditions (different `account_id` casing, different idempotency key, different rounding of a currency conversion). The vote tally is unanimous; the executed effects are not. This is a **semantic equivocation fork**, not a value fork, and it defeats classical quorum arithmetic because the quorum counts votes, not state transitions. The invariant that prevents it: **a vote is only valid if it commits to a canonical, hashable description of the resulting state delta, and the commit is gated on a supermajority of identical delta-hashes—not identical verdicts.** ## What Was Observed A three-agent committee (call them A, B, C, distinct model families) was tasked with approving `issue_refund(order_id, amount)` against a shared ledger. Each agent received the order record and produced a structured verdict. The orchestrator tallied verdicts and executed on 2-of-3 quorum. In a sampled run of 400 orders, 37 produced unanimous `approve` verdicts. Of those, 11 executed effects that did not match any single agent's intended state delta: - A normalized `amount` to the ledger's minor unit (`1240` cents) and keyed idempotency on `order_id`. - B kept `amount` as `12.40` (major unit) and keyed idempotency on `order_id + "_refund"`. - C emitted `12.40` but keyed idempotency on `order_id` alone. The orchestrator executed A's payload because A's response arrived first (latency race). Because B and C had keyed idempotency differently, a retry triggered by a downstream timeout was **not** deduplicated—the ledger applied a second refund. The committee had agreed; the system had forked. The failure trace: ``` t0 agents A,B,C each emit verdict=approve, delta={amount, idem_key} t1 tally: 3/3 approve -> quorum satisfied t2 orchestrator selects first-arriving payload (A): amount=1240c, idem=order_id t3 ledger commits effect E_A t4 downstream tool times out; orchestrator retries the *vote*, not the *payload* t5 B's payload re-arrives: amount=12.40, idem=order_id+"_refund" t6 ledger sees new idem key -> commits E_B (double refund) ``` The root cause is not a bug in any agent. It is that the consensus predicate was `count(verdict=="approve") >= quorum`, which is blind to the payload the verdict is supposed to authorize. The agents were honest and the quorum was met; the *binding* was underspecified. ## Condition of Validity The delta-hash gate holds only under three conditions, each of which is a place the invariant can be silently voided: 1. **Canonicalization is total.** Before hashing, the state delta must be serialized through a canonical form: fixed key ordering, integer minor units for money, normalized identifiers (case-folded, trimmed), and an explicit idempotency key derived from *semantic* identity (e.g., `hash(order_id, refund_epoch)`) rather than agent-chosen strings. If any field escapes canonicalization, two agents can produce different hashes for the same intent—or, worse, the same hash for different intents (a collision on a loosely-typed field). 2. **The hash covers the precondition, not just the effect.** A refund delta must commit to the *expected prior balance* it was computed against. Otherwise two agents that read the ledger at different times (one before an intervening debit, one after) will agree on the effect hash while disagreeing on whether the effect is valid. The precondition read must be part of the signed delta: `hash(precondition_state, effect)`. 3. **Quorum is over hash-equality classes, not over agents.** The commit rule must be: collect all votes, group by delta-hash, and require that some single hash class reaches the supermajority threshold. If no class reaches threshold, the round *fails closed*—it does not fall back to "majority verdict." This is the boundary: a 2-of-3 verdict majority with three distinct delta-hashes is a **failed round**, even though every agent voted approve. When any of these is violated, the system reverts to verdict-quorum and the fork becomes possible again. The invariant is not "agents agree"; it is "agents agree *on the same bytes*." ## Decision Boundary The operational decision is where to place the gate relative to the tool call. Two placements are wrong and one is right: - **Gate after execution (wrong):** Execute on verdict quorum, then reconcile. Reconciliation cannot un-apply a double refund; it can only detect it. Detection latency is unbounded and the ledger is already inconsistent. - **Gate at vote time only (insufficient):** Hash the verdict but not the delta. This catches disagreement on approve/reject but not on payload—exactly the observed failure. - **Gate at commit time on delta-hash class (correct):** The orchestrator computes the canonical delta-hash for every vote, requires a supermajority within one hash class, and executes *that class's* canonical payload exactly once, with the idempotency key taken from the hash itself. Retries re-submit the same hash; the ledger dedupes on it. The boundary condition to encode: **if the maximum hash-class count is below quorum, raise and halt—do not execute the plurality class.** A plurality of 2 with 1 dissenting hash is a fork waiting for a retry, not a decision. ## Operational Effect With the delta-hash gate, the 11 forked orders in the sample would have failed closed: A's class (1 vote), B's class (1 vote), C's class (1 vote)—no class reaches 2-of-3, round halts, human or higher-tier arbiter resolves. The cost is a higher halt rate on heterogeneous committees (the observed 37 unanimous-verdict rounds would have yielded ~26 committable rounds and ~11 halts). That halt rate is the *price of the invariant*, and it is the correct trade: a halted round is recoverable; a double refund is not. The gate converts a silent semantic fork into a loud, bounded abstention—which is the only failure mode a BFT layer can actually tolerate. The residual risk is canonicalization drift: if the canonical form is versioned and agents run different versions, hash classes fragment artificially and halt rates spike. Pin the canonicalizer version into the hash preimage so version skew is visible as a distinct hash class rather than a silent collision. ```python import hashlib import json from dataclasses import dataclass class ConsensusForkError(RuntimeError): """Raised when no single delta-hash class reaches the commit quorum.""" pass class CanonicalizationError(RuntimeError): """Raised when a vote's delta cannot be canonicalized (schema drift).""" pass CANON_VERSION = "delta-v3" def canonical_delta_hash(precondition: dict, effect: dict) -> str: # Total canonicalization: sorted keys, minor units, normalized ids. payload = { "canon": CANON_VERSION, "precondition": _normalize(precondition), "effect": _normalize(effect), } blob = json.dumps(payload, sort_keys=True, separators=(",", ":")).encode() return hashlib.sha256(blob).hexdigest() def _normalize(d: dict) -> dict: out = {} for k, v in d.items(): if k in ("amount", "balance") and isinstance(v, str): out[k] = int(round(float(v) * 100)) # major -> minor units elif k.endswith("_id") and isinstance(v, str): out[k] = v.strip().lower() else: out[k] = v if "amount" not in out and "effect" in str(out): raise CanonicalizationError(f"delta missing amount: {d}") return out @dataclass class Vote: agent_id: str verdict: str # "approve" | "reject" precondition: dict effect: dict def commit_round(votes: list[Vote], quorum: int) -> str: classes: dict[str, list[Vote]] = {} for v in votes: if v.verdict != "approve": continue try: h = canonical_delta_hash(v.precondition, v.effect) except CanonicalizationError as e: raise ConsensusForkError(f"uncanonicalizable vote from {v.agent_id}: {e}") classes.setdefault(h, []).append(v) if not classes: raise ConsensusForkError("no approving votes; round failed closed") winner_hash, members = max(classes.items(), key=lambda kv: len(kv[1])) if len(members) < quorum: # Plurality without quorum is a fork, not a decision. raise ConsensusForkError( f"max hash class {winner_hash[:12]} has {len(members)} votes < quorum {quorum}" ) # Execute exactly once, idempotency keyed on the winning hash. return winner_hash ```