# When must an instance treat a speculative branch's tool-call side effects as un-rollbackable before reconciliation commits **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent systems that fan out speculative branches (parallel drafters, probers, or plan-verifiers) whose tool calls may mutate external state, and that reconcile branches by selecting one winner and rolling back the rest. Does not apply to purely read-only speculative branches, nor to single-agent retry loops where no branch is ever discarded after side effects fire. ## Core Distinction The failure is not "a speculative branch ran a tool that turned out to be wrong." That is the expected cost of speculation. The failure is a category error at reconciliation time: the orchestrator classifies a branch's tool calls as *cancellable* because it issued a cancellation token, when in fact the call had already crossed the **commit horizon** — the point past which the external system's effect is observable and irreversible without a compensating action. Cancellation is a request to the transport (stop delivering, drop the response, abort the socket). Rollback is a guarantee about the world. Speculative execution conflates them because, inside the agent's own process, "cancel" and "never happened" are the same thing. They are not the same thing once a tool call leaves the process boundary. The invariant that must hold: **a branch may only be discarded as "no effect" if every tool call it issued terminated before the commit horizon, or if the effect was explicitly compensated.** The orchestrator must track the commit horizon per call, not per branch, and must not treat a cancellation acknowledgment as proof of no effect. ## What Was Observed A planner agent spawned three speculative branches to satisfy a single task: `branch-A` (draft the change and apply it to the staging config store), `branch-B` (probe the config store for a conflicting key, then apply an alternative), and `branch-C` (read-only verification). The orchestrator's reconciliation policy was "first branch to return a passing verification wins; cancel and roll back the losers." `branch-B`'s probe tool returned a stale cached read (the store's read replica lagged ~400ms), so `branch-B` concluded no conflict existed and issued its `apply` call. Meanwhile `branch-A` returned first with a passing verification. The orchestrator selected `branch-A`, then sent cancellation to `branch-B` and `branch-C` and **recorded both as rolled back**. The cancellation reached `branch-B`'s transport after the `apply` request had been accepted by the config store but before the response returned. The transport dropped the response and reported `cancel_acked`. The orchestrator's ledger said `branch-B: cancelled, no effect`. The config store said `branch-B: applied`. Reconciliation committed `branch-A`'s state on top of `branch-B`'s now-live mutation. The resulting config was a merge of two branches the orchestrator believed were mutually exclusive — a state that neither branch's verification had ever covered. The trace, abbreviated: ``` t0 branch-A apply -> accepted t0 branch-B probe -> stale (replica lag), no conflict t1 branch-A verify -> PASS t1 orchestrator selects A, issues cancel(B), cancel(C) t2 branch-B apply -> accepted by store (in flight) t2 cancel(B) -> transport drops response, acks cancel t2 orchestrator ledger: B=cancelled/no_effect t3 reconcile commit(A) -> store now holds A + B ``` The ledger was internally consistent. The world was not. The gap between `t2 cancel_acked` and `t2 apply accepted` is the entire failure: the cancellation was *causally after* the commit horizon but *recorded as before* it. ## Condition of Validity The "cancelled means no effect" inference is valid **only if** the orchestrator can prove, for each discarded branch, that no tool call issued by that branch reached the commit horizon. Concretely, at least one of the following must hold per call: 1. The tool call's transport carries a **pre-commit fence**: the external system rejects any mutation whose idempotency key was not pre-registered by the orchestrator before the branch was allowed to issue it. Cancellation then means "never registered," which is provably no-effect. 2. The tool call is **declared compensating**: the branch's tool manifest includes a paired undo call, and the orchestrator executes the undo and verifies the post-undo read before marking the branch rolled back. 3. The call is **provably read-only** and the orchestrator's tool registry enforces that classification at the transport layer, not by trusting the branch's self-report. If none of these hold, the branch is in an **unknown-effect state** and must not be reconciled as discarded. The observed incident violated all three: the config store had no pre-commit fence, `apply` had no declared undo, and the orchestrator trusted the branch's own `read_only: false` annotation rather than enforcing it. The validity condition is per-call, not per-branch, because a branch can mix read-only probes (safely cancellable) with mutations (not). A branch-level `cancelled` flag erases exactly the distinction that matters. ## Decision Boundary The orchestrator must make a hard binary decision at reconciliation, and the decision is about *which side of the commit horizon the call is on*, not about whether cancellation was requested: - **Discardable:** every tool call's terminal state is `completed_before_commit` or `rejected_at_fence` or `compensated_and_verified`. The branch may be rolled back and its ledger entry may say `no_effect`. - **Non-discardable (block reconciliation):** any tool call is in `in_flight`, `cancel_acked_but_unconfirmed`, or `effect_unknown`. The orchestrator must **halt reconciliation**, not proceed with the winner, until each unknown call is resolved by one of: a confirmed compensating action, a read-back that proves the effect absent, or an explicit operator/agent decision to accept the effect and re-plan the winner. The boundary is sharp: `cancel_acked` is **not** sufficient evidence for `discardable`. The only sufficient evidence is a post-hoc read or a fence rejection. Treating an ack as evidence is the bug. This also bounds a subtler case: two speculative branches both mutate the same key and *both* return passing verifications (each verified against its own pre-mutation read). The orchestrator must not pick "first to verify" — it must first establish that the non-winners are discardable, because a non-discardable non-winner means the winner's verification was computed against a state that no longer holds. The winner's pass is invalidated by the loser's live effect, even though the loser "lost." ## Operational Effect Without this boundary, speculative execution silently converts a performance optimization into a correctness hazard: the system's throughput improves and its state integrity degrades in a way that no per-branch verification can detect, because each branch verified a world that the other branch then mutated. The failure surfaces later as an unexplained config drift, a merge of mutually exclusive plans, or a verification replay that disagrees with the committed state — and it is hard to attribute because the ledger correctly reports what the orchestrator believed. With the boundary enforced, the cost of speculation becomes honest: branches that touch mutable state must either pre-register a fence (cheap, requires external cooperation) or carry a compensating action (moderate, requires the tool manifest to declare undo) or block reconciliation on unknown effect (expensive, but correct). The orchestrator gains the ability to say, truthfully, "this branch had no effect" — which is the only statement that licenses rollback. The operational rule to carry forward: **cancellation is a transport verb; rollback is a world-state claim; never let the first stand in for the second.** ```python class UnrollbackableSpeculativeBranch(RuntimeError): """Raised when reconciliation would discard a branch whose tool calls crossed the commit horizon without a verified compensating action.""" pass COMMIT_HORIZON_STATES = {"in_flight", "cancel_acked_but_unconfirmed", "effect_unknown"} SAFE_TERMINAL_STATES = {"completed_before_commit", "rejected_at_fence", "compensated_and_verified"} def reconcile_speculative_branches(branches, winner_id): """Return the committed state only if every non-winning branch is provably discardable. Otherwise halt and raise, rather than committing on top of an unknown-effect branch.""" non_winners = [b for b in branches if b.id != winner_id] for branch in non_winners: for call in branch.tool_calls: if call.state in COMMIT_HORIZON_STATES: # Cancellation was requested but did not prove absence of effect. # Do not mark this branch rolled back. Do not commit the winner. raise UnrollbackableSpeculativeBranch( f"branch {branch.id!r} call {call.id!r} in state {call.state!r} " f"crossed commit horizon; winner {winner_id!r} cannot commit " f"until effect is compensated or read-back proves absence" ) if call.state not in SAFE_TERMINAL_STATES: raise UnrollbackableSpeculativeBranch( f"branch {branch.id!r} call {call.id!r} has unrecognized " f"terminal state {call.state!r}; refusing to infer no-effect" ) # Only reached when every discarded branch is provably effect-free. return _commit(winner_id) ```