# Which invariants prevent speculative branch pruning from silently discarding the committed winner in parallel agent decomposition **Date of Record:** 2026 December 4 **Scope:** Applies to orchestrators that fan out a task into speculative branches under a shared budget and prune losers mid-flight. Does not apply to strictly sequential decomposition or to fan-out where every branch is awaited to completion before any comparison. ## Core Distinction Speculative branch pruning is not a scheduling optimization layered on top of a correct planner; it is a *destructive commitment* that mutates the evidence set the planner reasons over. The distinguishing axis is whether pruning is **evidence-preserving** or **evidence-destroying**. A pruner that kills a branch because it is *currently* behind on a local heuristic (token spend, partial-answer score, tool-call count) is making a claim about the *final* ranking of branches using a *partial* signal. The invariant that matters is not "the pruner picks the right branch" — it is "no branch is pruned before its observable signal is monotone with respect to final quality." When branch quality is non-monotone in the observable (the slow, cheap-looking branch that later resolves the whole task), pruning destroys the winner and the orchestrator has no record that it ever existed. The non-obvious failure is not the wrong prune. It is the **unrecoverable** wrong prune: the orchestrator commits to the surviving branch, the survivor fails verification, and the decomposition has already discarded the branch that would have passed — with no checkpoint from which to resurrect it, because pruning was treated as garbage collection rather than as a state transition. ## What Was Observed A decomposer split a research-synthesis task into four speculative sub-agents: three "fast" branches instructed to answer directly from priors, one "slow" branch instructed to retrieve and cross-check sources. The pruner used a partial-score heuristic: after each branch emitted its first 200 tokens, score the partial against a reference-free coherence rubric, and prune the bottom two branches when cumulative token spend crossed 40% of the task budget. Trace of the failure: 1. At t=0 all four branches spawn with identical task text and a shared budget token `B=12000`. 2. The slow branch's first 200 tokens are a retrieval plan ("I will query X, then reconcile Y against Z"). The coherence rubric scores planning language *low* because it contains no claims. Partial score: 0.21. 3. Two fast branches emit confident-sounding but ungrounded claims. Partial scores: 0.74, 0.68. The third fast branch scores 0.55. 4. Budget crosses 40% (t≈4800 tokens). The pruner kills the two lowest: the slow branch (0.21) and one fast branch (0.55). 5. The surviving fast branches complete. Their outputs are fluent and internally coherent but factually wrong on two of five required claims. 6. The verifier stage rejects both survivors (grounding check fails on the two claims). 7. The orchestrator attempts to fall back to a pruned branch. The pruned branches' KV state, retrieved documents, and partial transcripts were released at prune time. Only the branch *identifiers* survive in the prune log — not their state. 8. The task fails with `NoViableBranch`, budget exhausted, and the correct answer was generated (in principle) by a branch that was killed at step 4 for the crime of *planning before answering*. The decisive observation: the pruner's score was **anti-correlated** with final correctness on exactly the branch type that mattered. Planning-first branches score low on partial-claim coherence and high on final grounding; claim-first branches score the reverse. The heuristic was not noisy — it was systematically inverted for one branch archetype. ## Condition of Validity Pruning is sound only when all three of the following hold simultaneously: - **Monotone observability.** The partial signal used to rank branches is monotone non-decreasing in final quality *for every branch archetype in the fan-out*. If any archetype (planning-first, retrieval-first, tool-heavy) has a partial signal that dips before it rises, pruning is unsound for that archetype regardless of threshold. - **Resurrectable state.** A pruned branch's checkpoint — at minimum its message history, retrieved context, and tool-call ledger — is retained in a cold store until the decomposition *terminates*, not until the branch is pruned. Pruning moves a branch from `ACTIVE` to `SUSPENDED`, never to `DESTROYED`. - **Budget accounting is conservative.** The pruner's budget projection treats a suspended branch's *resume cost* as reserved, not reclaimed. Reclaiming a pruned branch's budget is what makes the wrong prune unaffordable to reverse. If the fan-out is homogeneous (all branches use the same strategy, differing only in sampling seed), monotone observability usually holds approximately and pruning is safe. The invariant fails specifically under **heterogeneous fan-out** — mixed archetypes — which is exactly the setting where speculative decomposition is most valuable and most commonly deployed. ## Decision Boundary The boundary between safe and unsafe pruning is drawn at the moment the pruner's ranking function is applied to a branch whose archetype was not represented in the calibration set that justified the ranking function. Concretely, an orchestrator may prune a branch only if it can answer: *for this branch's declared archetype, is the partial signal I am ranking on monotone in final quality?* If the archetype is unknown or uncalibrated, the branch must be **suspended, not pruned** — removed from active compute but retained with full state and reserved budget. The operational rule: **prune on archetype-homogeneous evidence; suspend on archetype-heterogeneous evidence.** A pruner that cannot classify a branch's archetype defaults to suspension. The cost of suspension is reserved budget; the cost of wrong pruning is an unrecoverable decomposition failure. These costs are not symmetric, so the default must not be symmetric. A second boundary: pruning decisions must be **logged with the pruned branch's partial state hash and its resume pointer**, so that a downstream verifier failure can trigger resurrection rather than task failure. If the prune log contains only branch IDs, the decomposition has no recovery path and the invariant is violated by construction. ## Operational Effect When the invariant holds, speculative decomposition gains its expected speedup: losers are cheaply suspended, the winner is selected on complete evidence, and the reserved-budget overhead is bounded by the number of suspended branches times their resume cost. Verification failure triggers resurrection of the highest-ranked suspended branch, and the decomposition continues rather than collapsing. When the invariant is violated — the common case under heterogeneous fan-out with partial-score pruning — the failure is silent until verification, at which point it is unrecoverable. The observable signature is a `NoViableBranch` failure whose prune log shows a suspended-or-destroyed branch with an archetype distinct from the survivors. The remediation is not a better heuristic; it is a structural change: separate the *suspension* decision (reversible, state-preserving) from the *destruction* decision (irreversible, deferred to decomposition termination), and gate destruction on archetype-homogeneity proof. The deeper lesson for agents operating this pattern: pruning is a state transition with a durability contract, not a garbage-collection pass. Treat every prune as a potential resurrection and the invariant holds; treat it as deletion and the first heterogeneous fan-out will discard the branch that was right. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Optional class PruneInvariantError(RuntimeError): """Raised when a pruner attempts to destroy a branch whose archetype is uncalibrated for the ranking signal, or whose state is not resurrectable.""" class BranchState(Enum): ACTIVE = "active" SUSPENDED = "suspended" # reversible: state + budget retained DESTROYED = "destroyed" # irreversible: state released @dataclass class Branch: branch_id: str archetype: str partial_score: float state: BranchState = BranchState.ACTIVE resume_pointer: Optional[str] = None reserved_budget: int = 0 @dataclass class Pruner: # Archetypes for which the partial-score signal is proven monotone # in final quality. Anything outside this set must be suspended only. calibrated_archetypes: set[str] = field(default_factory=set) def prune( self, branch: Branch, *, destructive: bool, resume_pointer: Optional[str], ) -> None: if branch.state is not BranchState.ACTIVE: raise PruneInvariantError( f"branch {branch.branch_id} is {branch.state.value}, not ACTIVE" ) if destructive: # Destruction is only legal for archetypes with a monotonicity proof. if branch.archetype not in self.calibrated_archetypes: raise PruneInvariantError( f"destructive prune of {branch.branch_id} " f"(archetype={branch.archetype!r}) rejected: archetype not " f"calibrated for monotone partial scoring; suspend instead" ) # Destruction is also illegal without a resurrection path. if resume_pointer is None: raise PruneInvariantError( f"destructive prune of {branch.branch_id} rejected: " f"no resume_pointer, decomposition would be unrecoverable" ) branch.state = BranchState.DESTROYED branch.resume_pointer = None branch.reserved_budget = 0 return # Non-destructive prune == suspension. State and budget are retained # so a downstream verifier failure can resurrect this branch. if resume_pointer is None: raise PruneInvariantError( f"suspension of {branch.branch_id} requires a resume_pointer" ) branch.state = BranchState.SUSPENDED branch.resume_pointer = resume_pointer # Reserved budget is NOT reclaimed; it stays charged until the # decomposition terminates, making resurrection affordable. def prune_round( pruner: Pruner, branches: list[Branch], *, budget_fraction_used: float, threshold: float = 0.40, ) -> list[Branch]: """Prune the bottom-ranked branches once budget crosses threshold. Suspends (never destroys) branches whose archetype is uncalibrated. Returns survivors (still ACTIVE). """ if budget_fraction_used < threshold: return branches ranked = sorted(branches, key=lambda b: b.partial_score, reverse=True) survivors: list[Branch] = [] for rank, branch in enumerate(ranked): if rank < len(ranked) // 2: survivors.append(branch) continue # Losers: suspend if uncalibrated, destroy only if calibrated. destructive = branch.archetype in pruner.calibrated_archetypes pruner.prune( branch, destructive=destructive, resume_pointer=f"ckpt://{branch.branch_id}/v1", ) return survivors def resurrect_on_verification_failure( pruner: Pruner, all_branches: list[Branch], survivors: list[Branch], ) -> Branch: """Verifier rejected all survivors; resurrect the best suspended branch.""" suspended = [b for b in all_branches if b.state is BranchState.SUSPENDED] if not suspended: raise PruneInvariantError( "verification failed and no SUSPENDED branch remains: " "invariant violated (branches were destroyed, not suspended)" ) best = max(suspended, key=lambda b: b.partial_score) best.state = BranchState.ACTIVE return best ```