# Where must an instance of speculative multi-agent execution with branch-and-verify rollback and parallel tool-call racing draw the boundary between recoverable and unrecoverable side effects? **Date of Record:** 2026 November 18 **Scope:** Applies to agent runtimes that speculatively fork multiple reasoning branches, execute tool calls in parallel across those branches, and roll back losing branches after verification. Does not apply to single-branch sequential agents, nor to runtimes where every tool call is a pure function with idempotent replay. ## Core Distinction The load-bearing distinction is between **speculation-visible** and **speculation-invisible** side effects. A side effect is speculation-visible if the external world can observe it before the verifier commits a branch; it is speculation-invisible if the effect is buffered, staged, or otherwise withheld until commit. Rollback correctness depends entirely on this property, not on whether the effect is "idempotent" in the abstract. A non-idempotent write that is staged behind a commit gate is safe; an idempotent write that leaks to the world before the gate is not, because idempotency governs *replay*, not *visibility*. Most runtimes conflate the two and budget rollback risk by counting retries rather than by classifying observability. ## What Was Observed During a branch-and-verify run with N=4 speculative branches racing a payment-authorization tool and an outbound-notification tool, three branches were rolled back after the verifier selected branch 2. The rollback was declared "clean" because both tools were marked idempotent with retry-safe keys. Post-commit audit showed two notifications had been delivered to the customer for orders that never existed in the committed branch: the notification tool had accepted the call, returned a 202, and dispatched asynchronously before the rollback signal arrived. The idempotency key deduplicated *retries* but did nothing for the *first* delivery from a discarded branch. The payment tool, which synchronously held the charge behind a 2-phase hold, was in fact safe — the opposite of what the retry-count heuristic predicted. The failure was not a race condition in the usual sense; it was a misclassification of visibility. ## Condition of Validity The rollback guarantee holds if and only if, for every tool call issued from a speculative branch, one of the following is true: (a) the call is gated behind an explicit commit token that the tool refuses to honor without, or (b) the call's effect is provably unobservable until the runtime releases a barrier. Parallel racing adds a second condition: the runtime must be able to *cancel in flight* — not merely decline to retry — any in-flight call from a losing branch, and the tool must honor cancellation before its first observable emission. If a tool emits observably between call-accept and cancellation-ack, it is unsafe to speculate against, regardless of declared idempotency. This condition is violated by any tool whose 2xx response precedes its side effect (fire-and-forget queues, async webhooks, event-bus publishes, email relays). ## Decision Boundary The boundary is drawn per tool, not per run, at the point where the tool transitions from *accepting* to *emitting*. Concretely: classify each tool as `STAGED` (effect held until commit token), `CANCELLABLE` (effect emitted only after an explicit release, and cancellation is honored pre-release), or `LEAKY` (effect may emit before cancellation is acknowledged). `STAGED` and `CANCELLABLE` tools may be raced speculatively. `LEAKY` tools must be serialized behind the verifier — they may only be invoked from the committed branch, never from a speculative one, and never raced. The decision cannot be made from an idempotency flag, a retry policy, or a status-code contract; it requires the tool's emission semantics to be documented and enforced. When semantics are unknown, default to `LEAKY`. ## Operational Effect Runtimes that respect this boundary lose parallelism on the `LEAKY` subset — typically notifications, payments, and any external publish — but retain full speculative speed on read-heavy and `STAGED` tools, which is where branch-and-verify pays for itself. Runtimes that ignore it ship "clean rollbacks" that leak phantom side effects at low, load-dependent rates, invisible in single-branch tests and only surfacing under concurrent racing. The operational rule is to gate at the emission boundary, treat unknown tools as `LEAKY`, and never let a retry-safe key stand in for a visibility guarantee. ```python class SpeculationVisibilityError(RuntimeError): """Raised when a speculative branch issues a tool call whose side effect may become externally observable before rollback can be guaranteed.""" pass class ToolEmissionClass: STAGED = "staged" # effect held until commit token CANCELLABLE = "cancellable" # emitted only after explicit release LEAKY = "leaky" # may emit before cancellation ack def assert_speculation_safe(tool_name: str, emission_class: str, is_speculative: bool) -> None: if not is_speculative: return if emission_class == ToolEmissionClass.LEAKY: raise SpeculationVisibilityError( f"tool {tool_name!r} classified LEAKY cannot be invoked from a " f"speculative branch; serialize behind the verifier or stage the effect" ) if emission_class not in (ToolEmissionClass.STAGED, ToolEmissionClass.CANCELLABLE): raise SpeculationVisibilityError( f"tool {tool_name!r} has unknown emission class {emission_class!r}; " f"default to LEAKY and do not speculate" ) def race_branches(branches, tool_name, emission_class): for branch in branches: assert_speculation_safe(tool_name, emission_class, is_speculative=True) branch.execute(tool_name) # verifier selects winner; losers roll back return branches[0] ```