# When must an instance abandon a speculative branch after a hedged tool call has already produced external side effects? **Date of Record:** 2026 November 30 **Scope:** Applies to multi-agent orchestrators that fork a task into parallel speculative branches, hedge tool calls across branches, and commit via branch-and-verify rollback. Does not apply to single-threaded agents with no side-effecting tools, or to tools whose effects are fully idempotent and reversible. ## Core Distinction Speculative execution with branch-and-verify rollback assumes a clean separation between *computation* and *commitment*: branches explore, a verifier picks a winner, losers are discarded. This holds when branch work is pure. It breaks the moment a branch invokes a **hedged tool call** — a tool dispatched speculatively to reduce latency, before the verifier has selected a winner — because the tool's side effect is now an *external fact* that no rollback protocol can retract. The distinction that matters is not "did the branch fail verification" but "did the branch, while still speculative, cross the commitment boundary of an external system whose state is not under the orchestrator's transactional control." The non-obvious part: hedging is usually introduced precisely to *avoid* waiting on the verifier, so the hedge is dispatched in the window where branch identity is still provisional. The rollback machinery is then asked to undo something it never owned. ## What Was Observed A planner agent forks three branches (B1, B2, B3) to resolve an ambiguous instruction ("file the report and notify the team"). Each branch independently plans a tool sequence. To cut p99 latency, the orchestrator hedges: the first branch to reach a `send_message` step dispatches it immediately, tagging the call with a `branch_id` and `speculation_token`. B1 wins the race and calls `send_message(team_channel, draft_v1)`. B2, arriving 340ms later, also fires `send_message(team_channel, draft_v2)` under the hedge policy because the verifier has not yet returned. The verifier then scores the branches and selects B2 (better grounding on the report contents). The orchestrator issues rollback on B1 and B3. B3 had no side effects — clean. B1's rollback handler finds the `send_message` tool has no compensating action; the message is already in the channel. The orchestrator marks B1 as "rolled back" because the rollback *handler returned success* (it recorded the intent to compensate but the tool exposes no delete). The team channel now contains `draft_v1` and `draft_v2`, and the audit log asserts only B2 committed. Downstream verifiers reading the channel see a contradiction the system believes does not exist. A second, subtler trace: the hedge dispatcher deduplicated B1 and B2 by `(tool, args_hash)`. Because the two drafts differed by one token, hashes differed, so both fired. When the drafts had been *identical* (a common case under shared context), the dedup collapsed them and the second branch's call returned the first branch's cached result — meaning B2's "own" side effect was actually B1's, and B2's verification was scored against an effect it did not produce. ## Condition of Validity The invariant that must hold for branch-and-verify rollback to be sound is: > **A branch may not dispatch a side-effecting tool call until its `speculation_token` has been promoted to `committed` by the verifier, OR the tool is registered with a verified compensating action that is executed and confirmed before the branch is marked rolled back.** Hedging is only valid under this invariant if the hedge target is a **read-only or externally-idempotent** call, or if the hedge is dispatched with a *reservation* semantic (the external system holds the effect pending a commit token and expires it on rollback). The moment a hedged call mutates external state without a reservation handle, the branch has escaped the orchestrator's transaction boundary, and "rollback" becomes a euphemism for "we stopped tracking it." Two additional conditions bound the claim. First, the dedup-by-args optimization is only sound when the tool is idempotent *and* the branches' effects are interchangeable — which fails whenever the branch's identity is part of the effect (as with a message whose content is the branch's output). Second, the verifier's commit decision must be causally downstream of all hedge dispatches it intends to govern; if a hedge can fire after the verifier returns, the invariant is violated by construction. ## Decision Boundary The orchestrator must decide, at hedge-dispatch time, between three regimes: 1. **Speculate-and-commit-on-verify (safe):** hedge only pure/read calls; buffer side-effecting calls until commit. Latency cost equals verifier latency for the mutating step. Correct. 2. **Speculate-with-reservation (safe, requires tool support):** dispatch the mutating call with a commit token; the external system applies it only on `commit(token)` and expires on TTL. Requires the tool to expose reservation semantics. Correct only if the external system honors expiry — a reservation that never expires is a silent side effect. 3. **Speculate-and-hope (unsafe):** dispatch the mutating call immediately, attempt compensating rollback later. This is the observed failure. It is only *tolerable* when the tool is provably idempotent, the compensating action is confirmed (not merely attempted), and the audit log records the compensation as a distinct event rather than erasing the original. The boundary is crossed the instant a branch in state `speculative` dispatches a call whose effect is (a) external, (b) non-idempotent, and (c) lacks a confirmed compensating action. At that point the branch is no longer rollback-able and must be treated as **committed-by-side-effect**, regardless of verifier outcome. ## Operational Effect Once a speculative branch has committed by side effect, the orchestrator has three honest options, none of which is "roll back": (i) *reconcile* — treat the orphaned effect as authoritative and re-plan around it, recording the divergence; (ii) *compensate-and-confirm* — execute a compensating action and verify the external system's state actually changed back before marking the branch rolled back; (iii) *escalate* — halt and surface the divergence to a human or a supervisory agent, because the system can no longer guarantee its own audit log matches reality. The failure mode to guard against is the silent variant: the rollback handler returns success because it recorded intent, the orchestrator marks the branch rolled back, and the audit log diverges from external state. Every subsequent verifier that reads the audit log will be reasoning about a world that does not exist. The guardrail is to make `rolled_back` a *derived* state that requires a confirmed compensation receipt, and to make any branch that dispatched a non-compensable hedge permanently ineligible for the `rolled_back` label — it can only be `reconciled` or `escalated`. ```python class UnreconciledHedgeError(RuntimeError): """Raised when a speculative branch has an external side effect that cannot be confirmed as rolled back.""" pass def rollback_branch(branch, external_state) -> str: """ Attempt to roll back a speculative branch. Returns the branch's new state. Raises UnreconciledHedgeError if a dispatched hedge has an external effect that no compensating action can confirm was undone. """ for call in branch.dispatched_calls: if not call.is_side_effecting: continue if call.compensating_action is None: # No way to undo: the branch is committed by side effect. raise UnreconciledHedgeError( f"branch {branch.id} dispatched non-compensable call " f"{call.tool}({call.args_hash}) while speculative; " f"cannot mark rolled_back" ) receipt = call.compensating_action.execute() if not receipt.confirmed or not external_state.matches_expected(call, receipt): raise UnreconciledHedgeError( f"compensation for {call.tool}({call.args_hash}) on branch " f"{branch.id} did not confirm; external state diverges from audit log" ) branch.state = "rolled_back" return branch.state ```