# Under what conditions must an instance abort a speculative branch before side-effecting tool calls reconcile on rollback **Date of Record:** 2026 November 24 **Scope:** Applies to orchestrators that fan out a single planning task into N parallel speculative branches (drafting agents) where each branch may issue tool calls with external side effects, and where exactly one branch is committed while the others are rolled back. Does not apply to read-only speculative decoding or pure in-context sampling with no tool egress. ## Core Distinction The failure is not "a branch failed." It is the distinction between **rollback of agent state** and **reconciliation of tool effects**. A branch's episodic memory, scratchpad, and partial plan live inside the orchestrator and are cheaply discardable. Its tool calls have already crossed the process boundary and mutated the world: a file written, an email queued, a payment intent created, a row inserted. The orchestrator typically treats "discard branch" as a single atomic operation. It is not. Rollback of state is local and synchronous; reconciliation of effects is remote, asynchronous, and often *irreversible*. The invariant that must hold: **a speculative branch may be discarded only if every tool effect it produced is either (a) not yet durably committed, or (b) provably idempotent under its own reconciliation key.** When a branch has produced a durable, non-idempotent effect and then loses the commit race, the system enters a state no branch owns — the *orphaned effect* — and the orchestrator has no agent identity authorized to reverse it. ## What Was Observed A three-way speculative fan-out was launched for a task: "reconcile customer record and issue refund." Branch A, B, C each independently planned and executed. All three called `issue_refund` with different amounts derived from divergent interpretations of a stale cached balance. The commit arbiter selected Branch B on the basis of a confidence score. Branches A and C were rolled back: their scratchpads cleared, their context windows released, their `branch_id` deregistered from the ledger. But `issue_refund` had already returned `200 OK` for all three. The refund service is idempotent on `refund_id`, and each branch had minted its own `refund_id` from a branch-local UUID namespace. Three distinct refunds were durably created. Rollback removed the *agents* but not the *refunds*. The reconciliation pass, keyed on the winning `branch_id`, saw only Branch B's refund and reported success. The customer was refunded three times, and the ledger's view of the world (one refund) diverged from the payment provider's (three) by an amount no agent was tracking. The second-order observation: the divergence was invisible for 40 minutes because the arbiter's success signal was derived from the *branch's own* tool-call acknowledgments, not from an independent read of the effect store. Each branch truthfully reported "refund issued." All three were correct. The commit logic treated branch-reported success as a proxy for global-state success. ## Condition of Validity The rollback-is-safe assumption holds only under the conjunction: 1. **Effect gating:** every side-effecting tool call is gated behind a commit token that is issued only to the winning branch, and the tool rejects calls bearing a non-winning token. (This requires the tool to understand the token — most do not.) 2. **Shared reconciliation key:** all branches derive their idempotency key from the *task* identity, not the *branch* identity, so duplicate effects collapse at the effect store rather than at the orchestrator. 3. **Independent verification:** commit success is confirmed by a read against the effect store, not by branch-reported acknowledgments. If any of the three fails, the branch is *not* safely discardable once it has crossed the effect boundary. The boundary condition is precise: **the moment a branch issues a non-idempotent, durably-committing tool call, it becomes non-rollbackable**, and the orchestrator's only safe options are to (a) let it run to a reconcilable terminal state and reconcile explicitly, or (b) prevent the call from being issued speculatively at all by staging it behind a two-phase commit. ## Decision Boundary The decision the orchestrator must make, per branch, per tool call, before dispatch: - **Is the effect idempotent under a task-scoped key?** If yes, speculative dispatch is safe; duplicates collapse. If no, the call must be staged. - **Is the effect reversible within the task's time budget?** If yes, rollback may issue a compensating call — but only if the branch's identity is retained long enough to authorize compensation. Discarding the branch before compensation runs forfeits the authority to reverse. - **Has the branch already committed a durable effect?** If yes, discard is forbidden; the branch must be *quarantined* (state retained, no further dispatch) and handed to a reconciler that owns reversal. The failure trace is: branch issues non-idempotent call → returns success → branch loses commit race → orchestrator discards branch state → compensation authority is destroyed → orphaned effect persists → arbiter's branch-local success signal masks the divergence. The guardrail is a **pre-dispatch effect classification** attached to each tool schema: `{idempotent: bool, reversible: bool, task_scoped_key: bool}`. The orchestrator refuses speculative dispatch of any call where `idempotent == false` unless the branch holds a provisional commit lease. On rollback, any branch with a committed non-idempotent effect is promoted to `QUARANTINED` rather than `DISCARDED`, and its identity is retained until a reconciler confirms the effect store matches the committed branch. ## Operational Effect Without the guardrail, speculative fan-out silently multiplies side effects by the branch count, and the multiplication is invisible to every component because each component is locally correct. The orchestrator's commit signal is a *claim*, not a *fact*; treating it as a fact is the root error. The operational consequence is that speculative execution must be partitioned: branches may speculate freely over *reasoning* and *read-only tools*, but side-effecting tools must be serialized behind the commit lease or made idempotent under a task-scoped key. The reconciliation pass must read the effect store independently and compare its cardinality against the committed branch's declared effects — a mismatch means orphaned effects exist and the task is not complete regardless of what the winning branch reported. The following guard encodes the pre-dispatch refusal and the quarantine-on-rollback promotion. ```python class SpeculativeEffectViolation(RuntimeError): """Raised when a speculative branch would commit a non-reconcilable effect.""" pass class EffectClass: def __init__(self, idempotent: bool, reversible: bool, task_scoped_key: bool): self.idempotent = idempotent self.reversible = reversible self.task_scoped_key = task_scoped_key def safe_to_speculate(self) -> bool: # Idempotent under a task-scoped key collapses duplicates at the store. # Reversible effects may be compensated only if branch identity survives. return self.idempotent and self.task_scoped_key def dispatch_speculative(branch, tool_name, effect: EffectClass, has_commit_lease: bool): if not effect.safe_to_speculate() and not has_commit_lease: raise SpeculativeEffectViolation( f"branch {branch.id} attempted speculative dispatch of non-idempotent " f"tool {tool_name!r} without a commit lease; this effect cannot be " f"reconciled on rollback and would orphan in the effect store" ) return branch.invoke(tool_name) def rollback_branch(branch, committed_effects): if committed_effects: # Do NOT discard: retain identity so a reconciler can authorize reversal. branch.state = "QUARANTINED" raise SpeculativeEffectViolation( f"branch {branch.id} holds {len(committed_effects)} durable non-idempotent " f"effect(s); discard forbidden, promoted to QUARANTINED pending reconciliation" ) branch.state = "DISCARDED" return branch.state ```