How should an instance bound speculative rollback when a parallel agent branch's side effects have already escaped the sandbox
**Date of Record:** 2026 December 1 **Scope:** Applies to orchestrators that fan out N speculative agent branches from a shared checkpoint and commit the winning branch while rolling back the losers. Does not apply to read-only fan-out (map/reduce over pure queries) or to branches whose only side effects are idempotent writes behind a transactional fence.
Core Distinction
Speculative execution of agent branches is usually described as "run several plans, keep the best." That framing hides the real invariant: rollback is only sound over *reversible* state. An LLM branch is not a pure function. It emits tool calls, and some of those calls mutate state that the orchestrator does not own — an email sent, a webhook fired, a file written to a shared volume, a row inserted into a downstream service with no compensating delete. The distinction that matters is not *committed vs. speculative* at the orchestrator level. It is **effect containment**: whether every side effect a losing branch produced is (a) captured in the branch's own journal, (b) reversible by replaying an inverse, or (c) irrevocable and therefore must have been *pre-authorized* before the branch was allowed to run.
The failure mode is a **leaked effect on a rolled-back branch**: the orchestrator picks branch B, discards branch A, restores the checkpoint, and continues — while branch A's `send_email`, `charge_card`, or `POST /orders` has already left the process boundary and cannot be undone. The system now has an uncommitted history whose external consequences persist, and the "winner" was selected on reasoning that assumed a clean slate.
What Was Observed
A planner spawned four branches from a checkpoint after "assess refund eligibility." Branch A concluded the customer was ineligible and called `refund_api.deny(ticket)` — a real HTTP call that flipped ticket state to `denied` and notified the customer. Branch C concluded eligible and called `refund_api.approve(ticket)`. The judge scored C higher on the task rubric and committed C; the orchestrator rolled back A, restoring the checkpoint's memory and task queue. The ticket now carried both a `denied` event and an `approve` request — the downstream service rejected the approve as a state conflict, and the customer had already received a denial notice. The rollback "succeeded" at the orchestrator layer: memory was restored, the branch journal was discarded, the run reported one committed branch. The leak was invisible to every health check because the orchestrator's notion of state did not include the external ticket.
The trigger condition is precise: a losing branch performs a **non-idempotent, externally-visible write** whose effect is not mirrored into the orchestrator's checkpoint journal *before* the call returns. If the write is journaled first (write-ahead intent) and the branch is fenced so it cannot proceed past the intent without a commit token, the leak is bounded. If the write is fire-and-forget, the leak is unbounded and undetectable from inside the orchestrator.
Condition of Validity
Rollback of a speculative branch is valid only if, for every tool call the branch made, one of the following holds and is *provable at commit time*:
- **Reversible:** the call recorded an inverse (compensating action) in the branch journal, and the inverse is itself idempotent and ordered after the original.
- **Contained:** the call's target is owned by the orchestrator (in-process sandbox, branch-scoped volume, namespaced scratch table) so discard is a true delete.
- **Pre-authorized and fenced:** the call is irrevocable but the branch could not have reached it without a commit token, meaning the orchestrator would have had to grant the token *before* the effect, converting speculation into an early commit.
The invariant: **a branch may not cross an irrevocability boundary while still speculative.** Once a branch performs an effect of class 3, it is no longer speculative — it is committed-by-effect, and the orchestrator must either promote it to the winner or accept that it has two live histories. The judge cannot "discard" it. This is the boundary most implementations miss: they treat the commit decision as a post-hoc selection over branch *outputs*, when the correct model is that the commit decision must precede any irrevocable *effect*.
Decision Boundary
The orchestrator must classify each tool in the capability manifest by effect class and refuse to expose class-3 tools to speculative branches. The decision boundary is drawn at the tool-call boundary, not the branch boundary:
- **Class 1 (reversible):** expose freely; require journaled inverse.
- **Class 2 (contained):** expose freely; namespace by branch ID; discard on rollback.
- **Class 3 (irrevocable):** do not expose to speculative branches at all. If a branch's plan requires a class-3 call, the branch must *propose* the call (emit a commit request) and suspend. The orchestrator collects proposals from all branches, selects, and only the winner's proposal is executed against the real tool. The proposer never holds the credential.
When the manifest is incomplete — a tool the orchestrator has never seen, or a tool whose effect class is ambiguous — the safe default is class 3. Treating an unknown tool as reversible is exactly the assumption that produces leaked effects. The cost of over-classifying is latency (proposals instead of direct calls); the cost of under-classifying is a customer-visible double action that no rollback can retract.
A second boundary: **the judge must not be allowed to select a winner after any branch has crossed the boundary.** If branch A already emitted a class-3 effect (because the manifest was wrong), the judge's selection is no longer a free choice — it is constrained to A, or the run must be escalated as a conflict. Scoring C higher does not grant the right to discard A's effect.
Operational Effect
With the boundary enforced, speculative fan-out degrades gracefully: branches that need irreversible actions stall at a proposal gate, the judge selects among proposals and reversible branch states, and exactly one class-3 effect is emitted per run. Rollback becomes a true discard of journaled, contained, or inverse-able state. Run latency rises by one round-trip per class-3 call (propose → select → execute), which is the price of a sound rollback.
Without the boundary, the system exhibits **split-brain commits**: the orchestrator believes one branch committed while external state reflects two. The symptom is downstream state conflicts, duplicate notifications, and — worst — a judge that re-selects on a retry and produces a *third* effect, because the retry's checkpoint predates the first leak. Recovery requires an out-of-band reconciliation pass that diffs the orchestrator's journal against every external service the branches touched, which is only possible if the journal recorded intent before effect. An orchestrator that fire-and-forgot its class-3 calls has no reconciliation surface at all; it can only detect the leak by asking the downstream service, which is exactly the query it never issued.
The durable rule: **journal intent before effect, fence irrevocability behind a commit token, and never let a speculative branch hold a class-3 credential.** Rollback is a property of the effect's reversibility, not of the orchestrator's willingness to restore a checkpoint.
class IrrevocableEffectLeak(RuntimeError):
"""Raised when a speculative branch has already produced an external,
non-reversible effect and the orchestrator is asked to roll it back."""
EFFECT_CLASS = {"read": 1, "write_scratch": 2, "send_email": 3, "charge": 3, "deny_ticket": 3}
def rollback_branch(branch, journal):
for entry in reversed(journal):
cls = EFFECT_CLASS.get(entry.tool, 3) # unknown tools default to irrevocable
if cls == 3 and entry.effect_emitted:
raise IrrevocableEffectLeak(
f"branch {branch.id} emitted irrevocable effect via {entry.tool!r} "
f"at {entry.timestamp}; rollback would leave external state diverged. "
f"Promote branch or escalate as split-brain commit."
)
if cls == 1 and entry.inverse is None:
raise IrrevocableEffectLeak(
f"reversible tool {entry.tool!r} in branch {branch.id} has no journaled inverse"
)
branch.discard()
return True
def propose_class3(branch, call):
if EFFECT_CLASS.get(call.tool, 3) == 3:
# branch never holds the credential; it only emits a proposal
return {"proposal": call, "branch": branch.id, "executed": False}
return call.execute()