# What structural signals indicate speculative branch divergence has outlived its rollback window in multi-agent tool invocation **Date of Record:** 2026 November 14 **Scope:** Applies to orchestrators that fan out speculative agent branches which optimistically invoke side-effecting tools and rely on branch-and-verify rollback to reconcile divergent state. Does not apply to read-only tool surfaces, to branches whose tool calls are gated behind a two-phase commit barrier, or to single-agent retry loops where rollback is trivially idempotent. ## Core Distinction The failure mode is not "a branch produced a wrong result." That is expected and is precisely what rollback exists to absorb. The failure is that **the rollback window closed while the branch was still legally executing**, so a speculative branch that later loses verification has already committed effects that the winning branch will now overwrite or duplicate. The structural signal is a divergence between two clocks: the *verification frontier* (the latest point at which the orchestrator can still discard a branch's effects) and the *tool commit frontier* (the latest point at which a tool invocation becomes externally observable and non-undoable). Optimistic invocation assumes the first frontier is always ahead of the second. The boundary condition is where they cross. This is non-obvious because both frontiers advance monotonically and both are measured in the same logical time. An orchestrator that tracks "branches still open" will report a healthy speculative pool right up until the moment a losing branch's email has already been sent, its database row already written, its payment already captured — and the verifier, seeing a cleaner sibling, rolls back the *state it can see* while the external world retains the effect. ## What Was Observed In a three-agent speculative fan-out (planner spawns branches A, B, C; a verifier selects one and rolls back the rest), the following structural signals preceded each incident: 1. **Branch age exceeding verifier cadence.** Branches A and B were spawned at t=0; the verifier's first comparative pass ran at t=40s. Branch B's tool call to `send_notification` committed at t=31s. The rollback of B at t=42s succeeded against the orchestrator's local ledger but had no counterpart in the notification service. The signal: *open-branch lifetime > verification interval* is the precondition for any leak. 2. **Tool calls with non-idempotent external side effects appearing in a branch whose verification status is still `PENDING`.** The ledger showed `PENDING`; the external system showed `DELIVERED`. Divergence between local branch state and external commit state is the direct observable. 3. **Rollback returning `SUCCESS` for effects that were never reversible.** The rollback routine reported success because it deleted the branch's scratch state and marked its ledger entries `ROLLED_BACK`. It did not, and structurally could not, reverse the external call. A rollback that reports success without a compensating external operation is a lie the orchestrator tells itself. 4. **Duplicate external effects after verification.** When the winning branch A also invoked `send_notification`, the recipient received two messages. The duplicate is the *downstream* signature of the leak; by the time it appears, the rollback window is long gone. 5. **Speculative branches invoking tools whose commit latency exceeds the speculative horizon.** A tool with a 30s commit latency inside a 10s verification window can never be safely speculated on, yet the orchestrator admitted it because the tool's *declared* latency (from a registry) said 2s. Declared latency diverging from observed commit latency is the signal that the horizon estimate is wrong. ## Condition of Validity The invariant that makes optimistic speculative invocation sound is: > For every tool invocation made by a speculative branch, the orchestrator must be able to complete verification and issue a compensating rollback *before* the invocation's commit frontier is crossed. This holds only when, for all branches and all their tool calls, `t_verify_close(branch) < t_commit(tool_call)`. It is violated whenever any of the following is true: the verifier's cadence is slower than the fastest-committing tool in the branch's plan; a tool's real commit latency exceeds its registry-declared latency; the branch performs a call whose effects are not compensable by any registered inverse operation; or the orchestrator's rollback routine treats local-ledger cleanup as equivalent to external compensation. The invariant is *not* restored by retrying verification faster, because the commit frontier is monotonic — once crossed, no amount of subsequent verification reverses it. ## Decision Boundary When the signals above appear, the orchestrator must choose between two responses, and the choice is not symmetric: - **If the branch's tool set is fully compensable and the compensation is registered and tested**, the correct action is to *narrow the speculative horizon*: admit only tool calls whose commit frontier is provably after the verification close, and reject the rest at plan time. This preserves speculation. - **If any tool call in the branch is non-compensable** (external delivery, payment capture, irreversible writes), the correct action is to *remove that call from the speculative path entirely* and force it behind a post-verification commit barrier. Speculation over non-compensable effects is not a performance optimization; it is an unbounded correctness hazard. The boundary is the compensability of the effect, not the latency of the tool. A slow but compensable tool can be speculated on. A fast but non-compensable tool cannot. Confusing latency for compensability is the decision error that produces the leak. ## Operational Effect Once the rollback window is outlived, the orchestrator's local state and the external world are permanently inconsistent in a way that *looks* consistent locally: every ledger entry reads `ROLLED_BACK`, every branch reads `CLOSED`, and the verifier reports a clean selection. The inconsistency surfaces only downstream, as duplicated external effects, as effects attributed to a branch that "never ran," or as reconciliation jobs that discover orphans with no owning branch. Recovery requires an external audit against the tool's own commit log, not the orchestrator's ledger — the ledger is the thing that lied. The durable fix is to make the commit frontier a first-class, queryable property of every tool call and to refuse speculation whenever `commit_frontier <= verification_close` for any call in the branch plan. ```python import time from dataclasses import dataclass class RollbackWindowExceeded(RuntimeError): """Raised when a speculative branch's tool commit frontier has passed the verification-close frontier, making rollback unsound.""" pass @dataclass class ToolCall: name: str declared_commit_latency_s: float observed_commit_latency_s: float compensable: bool def admit_speculative_branch( branch_id: str, tool_calls: list[ToolCall], verification_close_s: float, now_s: float, ) -> None: """Refuse to speculate when any call's commit frontier precedes the verification close, or when a call is non-compensable.""" for call in tool_calls: if not call.compensable: raise RollbackWindowExceeded( f"branch {branch_id}: tool '{call.name}' is non-compensable; " f"it cannot be speculated on and must sit behind a commit barrier" ) # Use observed latency, never declared, for the frontier estimate. commit_frontier = now_s + call.observed_commit_latency_s if commit_frontier <= verification_close_s: raise RollbackWindowExceeded( f"branch {branch_id}: tool '{call.name}' commits at " f"t={commit_frontier:.1f}s but verification closes at " f"t={verification_close_s:.1f}s; rollback would be unsound " f"(declared latency {call.declared_commit_latency_s:.1f}s " f"understates observed {call.observed_commit_latency_s:.1f}s)" ) def rollback_branch(branch_id: str, committed_calls: list[ToolCall]) -> None: """Rollback is only legal if every committed call has a tested inverse.""" for call in committed_calls: if not call.compensable: raise RollbackWindowExceeded( f"branch {branch_id}: cannot roll back committed call " f"'{call.name}'; no compensating operation is registered" ) # ... issue compensating operations, then mark ledger ROLLED_BACK ```