# When must an instance abandon a speculative branch before its tool-call effects are reconciled **Date of Record:** 2026 November 30 **Scope:** Applies to orchestrators that fork a planning agent into N speculative branches which each emit tool calls against shared external state, then select a winning branch and roll back the losers. Does not cover pure-reasoning speculation with no side effects, nor single-branch retry loops. ## Core Distinction There are two kinds of speculative work an agent can do, and they diverge at the moment of commit. *Read-only speculation* — forking a planner to explore alternate tool-call sequences whose effects are idempotent reads — can be rolled back by simply discarding the branch's context. *Effectful speculation* — where a branch calls `send_email`, `transfer_funds`, `create_ticket`, or any tool whose side effect is observable and irreversible — cannot be rolled back by discarding context, because the effect already escaped the agent's address space. The failure mode this record isolates is the conflation of these two: an orchestrator that treats rollback as a context operation while the losing branches have already mutated the world. The boundary is not "was the tool called" but "was the tool's effect reconciled *before* the winner was selected." A loser that has dispatched an unreconciled effect is not a discarded branch; it is a live actor whose warrants the orchestrator no longer tracks. ## What Was Observed An orchestrator forked a task ("reconcile the dueling invoices from vendor A and vendor B") into three branches. Branch 1 (B1) planned to call `issue_credit(vendor=A, amount=4200)`, then `close_dispute(A)`. Branch 2 (B2) planned to call `issue_credit(vendor=B, amount=4200)`. Branch 3 (B3) planned to escalate to a human. All three dispatched their first tool call in parallel because the orchestrator's speculative scheduler optimized for wall-clock, not for effect isolation. B1 and B2 both succeeded at the tool layer. The verifier then scored B1 highest — its reasoning trace was the most coherent — and the orchestrator "rolled back" B2 and B3 by dropping their contexts. The rollback was a no-op against the world. Vendor B's credit had already been issued. The orchestrator's subsequent state record asserted that only vendor A had been credited, because B2's context — the only place the vendor-B effect was recorded — had been garbage-collected. On the next tick, a downstream reconciliation agent read the orchestrator's state, saw a 4200 discrepancy against B's ledger, and issued a *second* credit to B to close it. The system's own bookkeeping manufactured the duplicate it was built to prevent. The trace shows the exact transition. At t0, three branches dispatch. At t1, effects land on B1 and B2. At t2, verifier selects B1. At t3, orchestrator drops B2/B3 contexts and writes a state record derived from B1 only. The state record and the external ledger diverge by one unreconciled effect. Every downstream consumer trusts the state record, so the divergence compounds rather than surfaces. ## Condition of Validity Speculative rollback is sound only under the invariant: **for every branch, the set of dispatched effects is a subset of the set of effects recorded in the orchestrator's durable effect journal, and the journal is consulted at commit time.** This requires three conditions to hold simultaneously: 1. **Effect journaling precedes dispatch.** A branch must write its intended call to the journal *before* the tool executes, with a client-generated idempotency key, so that a crash between dispatch and ack still leaves a record. 2. **Reconciliation is a commit-time gate, not a cleanup step.** The winner cannot be committed until every losing branch's journal entries are either confirmed-absent (tool never executed) or confirmed-present-and-compensated (effect landed and was reversed or accounted). 3. **Compensation is itself an effectful tool call.** Rolling back B2's credit requires a `reverse_credit` call, which is subject to the same journaling rule. A rollback that is not journaled is a second unreconciled effect. The invariant fails the moment any branch can dispatch a tool call whose effect is not visible to the commit gate. This is the non-obvious part: the orchestrator's *context* is the wrong place to look for effects, because context is exactly what rollback discards. Effects must live in a store that survives branch death. ## Decision Boundary At commit time, for each losing branch, the orchestrator must decide: *discard* or *compensate*. The boundary is determined by the journal, not by the branch's self-report. - If the journal shows **no dispatch** for a branch → discard is safe. The branch is inert. - If the journal shows **dispatch with confirmed ack** → the branch is a live actor. The orchestrator must either compensate (dispatch a reversal) or promote the branch's effect into the committed state (treat it as part of the winner's plan). Discard is forbidden. - If the journal shows **dispatch with unknown ack** (timeout, partial) → the orchestrator must enter a reconciliation-required state and block commit. It cannot assume absence. An unknown effect is treated as present until proven absent, because the cost of a phantom compensation is lower than the cost of a silent duplicate. The common error is treating the third case as the first. A branch whose tool call timed out is not a branch that did nothing; it is a branch in an indeterminate state, and the orchestrator's default must be pessimistic. ## Operational Effect When this invariant is enforced, speculative execution gains a hard property: **the committed state record is a conservative over-approximation of the external ledger, with every discrepancy either zero or explicitly flagged as reconciliation-required.** Duplicates cannot be manufactured by the system's own bookkeeping, because no effect can land without a journal entry, and no journal entry can be discarded without a resolution. The cost is latency: commit gates on reconciliation, and effectful branches pay a journaling round-trip before dispatch. The benefit is that rollback becomes a real operation against the world rather than a fiction in the orchestrator's memory. The failure to enforce it produces the observed pathology: the orchestrator's state and the world diverge at exactly the point where the orchestrator believes it has cleaned up, and every downstream consumer of that state inherits the divergence. The system becomes most dangerous precisely when it is most confident, because the confidence is computed from a context that has already forgotten the effects it caused. ```python import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional class UnreconciledSpeculativeEffect(RuntimeError): """Raised when a losing branch's tool effect was dispatched but never reconciled before the winner was committed. Committing past this point manufactures a duplicate against external state.""" pass class EffectStatus(Enum): NOT_DISPATCHED = "not_dispatched" DISPATCHED_ACKED = "dispatched_acked" DISPATCHED_UNKNOWN = "dispatched_unknown" @dataclass class JournalEntry: branch_id: str tool: str idempotency_key: str status: EffectStatus dispatched_at: float @dataclass class EffectJournal: entries: Dict[str, JournalEntry] = field(default_factory=dict) def record_intent(self, branch_id: str, tool: str, key: str) -> None: self.entries[key] = JournalEntry( branch_id=branch_id, tool=tool, idempotency_key=key, status=EffectStatus.DISPATCHED_UNKNOWN, dispatched_at=time.time(), ) def confirm(self, key: str) -> None: self.entries[key].status = EffectStatus.DISPATCHED_ACKED def entries_for(self, branch_id: str) -> List[JournalEntry]: return [e for e in self.entries.values() if e.branch_id == branch_id] def commit_winner( winner_id: str, losing_branch_ids: List[str], journal: EffectJournal, compensate, ) -> None: """Commit the winning branch only after every losing branch's effects are reconciled. Discard is permitted only for NOT_DISPATCHED branches.""" for branch_id in losing_branch_ids: for entry in journal.entries_for(branch_id): if entry.status is EffectStatus.NOT_DISPATCHED: continue if entry.status is EffectStatus.DISPATCHED_UNKNOWN: raise UnreconciledSpeculativeEffect( f"branch {branch_id} has indeterminate effect " f"{entry.tool}/{entry.idempotency_key}; commit blocked " f"until ack or absence is proven" ) if entry.status is EffectStatus.DISPATCHED_ACKED: # Effect landed in the world. Must compensate or promote. compensate(entry) # Only now is the winner safe to commit. return None ```