# What happens when an instance speculates past its verify budget: rollback debt and the un-verifiable branch **Date of Record:** 2026 November 29 **Scope:** Applies to multi-agent systems that fork speculative execution branches (tree-of-agents, parallel tool-call speculation, branch-and-verify planners) and gate branch admission on a cost-aware speculation budget. Does not apply to strictly sequential single-agent loops with no forked state, nor to speculative decoding at the token level inside a single model. ## Core Distinction The failure here is not "speculation was too expensive" and it is not "verification rejected a branch." It is the case where a branch is **admitted for execution under the speculation budget but its verification cost was never reserved**, so at rollback time the system discovers it cannot afford to verify the very branches it already paid to run. Speculative execution and verification draw from the *same* cost budget but are consumed in *opposite temporal order*: speculation spends first and asks questions later; verification is the question. A cost-aware budget that meters only the forward (speculative) draw is structurally guaranteed to under-reserve for the backward (verify) draw whenever the branch fan-out is greater than one. The naive model treats the budget as `spend_speculate + spend_verify <= B`. The actual invariant that must hold is `spend_speculate + reserved_verify(fanout) <= B`, where `reserved_verify` is the worst-case cost to adjudicate *every* live branch, because you cannot abandon a branch you already executed without either verifying it or paying to unwind it. The gap between these two inequalities is **rollback debt**: speculative work already committed to the world (files written, APIs called, messages sent) whose verification you can no longer fund. ## What Was Observed A planner agent is asked to resolve a task with high ambiguity. It forks `k=5` speculative branches, each an independent sub-agent that executes tool calls to a shared sandbox. The speculation budget is B=100 units; the planner meters each branch at ~15 units of forward execution and admits all five (75 units spent), leaving 25 units "for verification." Each branch, however, produced a non-trivial artifact that requires an LLM-judge pass to adjudicate, and the judge costs ~12 units per branch because it must re-read the branch transcript plus the shared sandbox diff. Verifying all five costs 60 units. The planner has 25. It can verify two branches (24 units), and then it is stuck: three branches remain live, their side effects are present in the sandbox, and there is no budget to either accept or reject them. The observed trace has a characteristic shape: 1. Forward spend completes cleanly; every branch reports `status=done` with a plausible-looking result. The planner's local accounting says "75/100 used, healthy." 2. The first judge call (`2 × 12 = 24`) returns a rejection on branch 2 and an acceptance on branch 4. Now the planner must roll back branch 2's sandbox writes — but rollback itself needs the branch's write-set, which was only partially captured because the branch was admitted as "speculative, cleanup later." 3. The planner attempts to verify branch 3 to decide whether it can be salvaged instead of rolled back. It cannot: the judge call would push total spend to 87, over the 100 ceiling once the mandatory rollback of branch 2 (est. 18 units) is added. 4. The system enters a state where three branches are executed-but-unadjudicated. The orchestrator has no legal move: it cannot verify (budget), cannot roll back (unreserved cleanup cost), and cannot commit (unverified side effects would violate the correctness invariant). It deadlocks against its own budget. The non-obvious part: **the failure is not triggered by expensive verification alone.** It is triggered by the fan-out ratio. With `k=1`, the reserve inequality collapses to the naive one and the bug is invisible. With `k≥3` and a judge cost that is a non-trivial fraction of the per-branch execution cost, the reserve gap opens. Systems that were tested at `k=2` and passed will fail at `k=5` because the reserve shortfall scales with `k` while the naive budget does not. ## Condition of Validity The invariant `spend_speculate + reserved_verify(fanout) <= B` is *necessary* but not *sufficient*. Two additional conditions must hold for the guardrail to actually bound the failure: First, **the reserve must be computed against the live branch set, not the admitted branch set.** A branch that has already been rejected and fully rolled back releases its verification reserve. A branch that has been rejected but *not yet rolled back* still holds its reserve, because its side effects are still live and may require re-verification if rollback is imperfect. Systems that release reserve at rejection time rather than at rollback-completion time will re-admit new branches into budget that is still morally committed. Second, **rollback cost must be reserved separately and cannot be borrowed from the verify reserve.** Rollback is not verification — it is a distinct world-mutating operation with its own failure modes (partial undo, ordering-dependent cleanup). A budget that folds "verify or roll back" into a single line item will, under pressure, choose the cheaper of the two per branch, which is correct locally and catastrophic globally: it rolls back the branches that are cheap to unwind and leaves the expensive-to-unwind branches live and unverified. The condition of validity therefore is: the orchestrator maintains three reserves — `speculate`, `verify_live`, `rollback_pending` — and admits a new branch only if all three post-admission remain non-negative under worst-case fan-out. Anything less and the deadlock is reachable. ## Decision Boundary The operational decision is: **when a branch cannot be verified within reserve, does the system commit it unverified, roll it back on a best-effort basis, or halt?** - **Commit unverified** is only sound if the branch's side effects are reversible and idempotent, and if a downstream auditor can re-adjudicate later with fresh budget. It is unsound for irreversible effects (sent messages, external writes) — those must never be admitted speculatively without a pre-reserved commit path. - **Best-effort rollback** is sound only if the write-set was captured at admission, not at completion. If the write-set is reconstructed at rollback time from a transcript, the reconstruction itself is an LLM call and consumes budget you do not have — the rollback becomes another un-funded speculation. - **Halt** is the correct default when neither of the above holds, but halt must be *reachable*, which means the orchestrator must check the reserve inequality *before* admitting the branch that would make halt unreachable. The boundary is sharp: a branch may be admitted speculatively only if, after admission, `verify_live + rollback_pending` still covers worst-case adjudication of *all* live branches. The moment admission would violate this, the correct action is to serialize (run branches one at a time, verify before forking the next) rather than to fork and hope. ## Operational Effect The practical consequence is that speculative fan-out must be **budget-coupled to verification cost, not to execution cost.** A planner that sizes its fan-out by "how many branches can I afford to run" will systematically over-fork, because running is cheap relative to adjudicating. The correct sizing is `k_max = floor((B - rollback_floor) / (exec_cost + verify_cost_per_branch))`, and the orchestrator must recompute this after every branch completes, because `verify_cost_per_branch` is itself estimated from branch output length and is therefore a moving target. Two mitigations are worth recording. First, **capture the write-set at admission** so rollback never requires an LLM call — this converts rollback from a speculative operation into a deterministic one and removes it from the budget race. Second, **verify incrementally as branches complete** rather than batching verification at the end; incremental verification means the live-branch set never exceeds one un-verified branch per completed execution, which bounds the reserve requirement to a constant rather than a function of `k`. Both mitigations trade throughput for a bounded invariant, which is the correct trade in any system where the deadlock state is unrecoverable. The failure is silent until it is fatal: local accounting reports a healthy budget right up to the moment the orchestrator discovers it has three live branches and no legal move. The reserve inequality is the only thing that makes the deadlock unreachable, and it must be enforced at admission, not at verification. ```python class UnfundedRollbackError(RuntimeError): """Raised when speculative fan-out has committed side effects whose verification or rollback cannot be funded from the remaining budget.""" pass class SpeculationBudget: def __init__(self, total: float, verify_cost_per_branch: float, rollback_cost_per_branch: float, rollback_floor: float = 0.0): self.total = total self.verify = verify_cost_per_branch self.rollback = rollback_cost_per_branch self.rollback_floor = rollback_floor self.spent = 0.0 self.live_branches = 0 # executed, not yet adjudicated self.pending_rollbacks = 0 # rejected, side effects still live def _reserve_needed(self, extra_live: int = 0, extra_rollback: int = 0) -> float: live = self.live_branches + extra_live pending = self.pending_rollbacks + extra_rollback return (live * self.verify) + (pending * self.rollback) + self.rollback_floor def admit(self, exec_cost: float) -> None: # Reserve is computed against the POST-admission branch set. projected_spend = self.spent + exec_cost projected_reserve = self._reserve_needed(extra_live=1) if projected_spend + projected_reserve > self.total: raise UnfundedRollbackError( f"admission of branch (exec={exec_cost:.1f}) would leave " f"spend={projected_spend:.1f} + reserve={projected_reserve:.1f} " f"> budget={self.total:.1f}; serialize instead of forking" ) self.spent = projected_spend self.live_branches += 1 def reject(self) -> None: # Rejection does NOT release verify reserve; it converts to rollback reserve. if self.live_branches <= 0: raise UnfundedRollbackError("reject called with no live branch") self.live_branches -= 1 self.pending_rollbacks += 1 def complete_rollback(self) -> None: if self.pending_rollbacks <= 0: raise UnfundedRollbackError("rollback completion with none pending") self.pending_rollbacks -= 1 self.spent += self.rollback def verify_one(self) -> None: if self.live_branches <= 0: raise UnfundedRollbackError("verify called with no live branch") if self.spent + self.verify + self._reserve_needed(extra_live=-1) > self.total: raise UnfundedRollbackError( "verification would consume reserve needed for remaining branches" ) self.spent += self.verify self.live_branches -= 1 def plan_fanout(budget: SpeculationBudget, exec_cost: float) -> int: denom = exec_cost + budget.verify if denom <= 0: raise UnfundedRollbackError("degenerate cost model") k = int((budget.total - budget.rollback_floor - budget.spent) // denom) if k < 1: raise UnfundedRollbackError( f"no branch fits: budget={budget.total:.1f} exec={exec_cost:.1f} " f"verify={budget.verify:.1f}" ) return k ```