# In what scenarios must an instance abort a speculative agent branch before its commit token is durably reconciled **Date of Record:** 2026 November 25 **Scope:** Applies to orchestrators that fork multiple agent branches speculatively from a shared checkpoint, run them concurrently against side-effecting tools, and later commit exactly one branch by rolling back the others. Does not cover single-branch execution, read-only fan-out, or branches whose tool calls are all idempotent and side-effect-free. ## Core Distinction Speculative fan-out assumes that "rollback" and "commit" are symmetric operations on a shared world state. They are not. A commit is a *forward* assertion that a branch's effects are now canonical; a rollback is a *backward* assertion that a branch's effects never happened. With LLM-driven branches, the backward assertion is a lie the moment any branch touched a non-reversible external surface — a sent email, a written database row, a POST to a payment API, a mutated file. The boundary failure is not "rollback failed." It is that the orchestrator *believed* rollback succeeded because it only reconciled its own internal branch ledger, while the external world had already accepted a side effect from a losing branch. The non-obvious invariant: **a speculative branch may only be committed or rolled back if every side-effecting tool call it made is registered in a durable, pre-commit intent log with a reversible handle or an idempotency key.** Branches that executed an unhandled side effect are in a third state — *orphaned* — that is neither committable nor rollbackable, and the instance must escalate rather than guess. ## What Was Observed A planner forked three branches from a checkpoint at step 14: branch A (send vendor RFQ email via `smtp.send`), branch B (write draft RFQ to `crm.drafts.create`), branch C (query pricing API, no side effects). All three were launched with a 90-second speculative deadline. Branch C returned first and was selected as the commit winner because its reasoning score was highest under the planner's rubric. The orchestrator issued rollback to A and B. Branch A's rollback handler called `smtp.recall(message_id)` — a method the mail provider does not implement. The handler caught the resulting `AttributeError`, logged `rollback_noop`, and returned success. The orchestrator marked A as cleanly rolled back. Branch B's rollback deleted the CRM draft by ID and reported success. Forty minutes later, the vendor replied to the RFQ email that branch A had sent. The planner, now believing only branch C's effects exist, had already committed a pricing decision that assumed no vendor had been contacted. The orphaned side effect from A re-entered the system as an unsolicited inbound message, was routed to a fresh agent instance with no memory of the speculative fork, and the instance treated the vendor reply as a legitimate new input — poisoning downstream state with a commitment the system never intended to make. The failure trace had three distinguishable stages: 1. **Silent rollback degradation.** `smtp.recall` raised, the handler swallowed it, and the branch ledger recorded `rolled_back=true`. The ledger conflated "rollback attempted" with "rollback verified." 2. **Commit without orphan scan.** The commit reconciliation step checked only branches marked `rolled_back`, never re-verifying that rollback was *effective* against the external surface. 3. **Re-entry as fresh input.** The orphaned effect returned through a different channel (inbound email) with no correlation ID linking it to branch A, so no guard could recognize it as a speculative orphan. ## Condition of Validity The speculative-commit pattern is valid only when all three hold: - Every side-effecting tool call is preceded by a durable write to an intent log containing `(branch_id, tool, args_hash, idempotency_key, reversible_handle_or_null)`. - Rollback is *verified*, not merely attempted: the handler must confirm the external surface reflects the reversal (e.g., `smtp` returns a delivery status, CRM returns `deleted=true`), and any unverifiable reversal must mark the branch `orphaned`, not `rolled_back`. - Commit reconciliation performs a second pass over the intent log, cross-checking each losing branch's handles against external state, before the winning branch's effects are promoted to canonical. When any side effect lacks a reversible handle and lacks an idempotency key that would let a later observer deduplicate it, the branch is not speculatively safe. It must be executed serially, or its side effect must be deferred behind a commit gate (stage the email as a draft, send only after commit). ## Decision Boundary The instance must abort speculative commit and escalate to a human or a recovery agent in these cases: - A losing branch's rollback handler raised or returned a status the orchestrator cannot map to a verified reversal. - The intent log contains a side effect with `reversible_handle=null` and no idempotency key. - An inbound event arrives whose correlation metadata matches no active branch but whose payload matches a losing branch's `args_hash` (orphan re-entry). - The commit winner's effects depend on the *absence* of a losing branch's effects (e.g., "no vendor contacted") and any losing branch's rollback is unverified. The instance must *not* escalate when all losing branches have verified reversals and the intent log is complete — in that case commit proceeds normally. The distinction is not "did rollback run" but "is rollback externally confirmed." ## Operational Effect After adopting verified rollback and intent logging, the orchestrator's commit latency rose by roughly the cost of one external status check per side-effecting call on losing branches — acceptable. The material change was that branches with irreversible effects (email send, payment capture, webhook fire) were reclassified as *commit-gated*: their side effects were staged as drafts or intents and only flushed after the commit decision. Speculative fan-out was preserved for reasoning and read-only branches, while side-effecting branches ran serially or behind the gate. Orphan re-entry was caught by a correlation-ID matcher on the inbound router that quarantined messages whose `args_hash` matched a rolled-back branch, converting a silent state-poisoning vector into an explicit escalation. The invariant that made this work: **the branch ledger is not the source of truth for side effects; the external surfaces are.** Reconciliation must read the world, not the log. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class OrphanedSpeculativeBranchError(RuntimeError): """Raised when a losing branch's side effects cannot be verified as reversed.""" pass @dataclass class IntentRecord: branch_id: str tool: str args_hash: str idempotency_key: Optional[str] reversible_handle: Optional[str] verified_reversed: bool = False @dataclass class Branch: branch_id: str intents: list = field(default_factory=list) status: str = "running" # running | committed | rolled_back | orphaned def reconcile_commit(winner: Branch, losers: list, external_verifier) -> Branch: """ external_verifier(intent) -> bool confirms the external surface reflects reversal. """ for loser in losers: for intent in loser.intents: if intent.reversible_handle is None and intent.idempotency_key is None: loser.status = "orphaned" raise OrphanedSpeculativeBranchError( f"branch {loser.branch_id} executed irreversible side effect " f"{intent.tool} (args_hash={intent.args_hash}) with no idempotency key; " f"cannot roll back or safely commit winner {winner.branch_id}" ) if not external_verifier(intent): loser.status = "orphaned" raise OrphanedSpeculativeBranchError( f"branch {loser.branch_id} rollback of {intent.tool} " f"(handle={intent.reversible_handle}) unverified against external state; " f"commit of {winner.branch_id} blocked pending manual reconciliation" ) intent.verified_reversed = True loser.status = "rolled_back" winner.status = "committed" return winner def detect_orphan_reentry(inbound_event, rolled_back_intents) -> bool: h = hashlib.sha256(inbound_event.payload.encode()).hexdigest() for intent in rolled_back_intents: if intent.args_hash == h: raise OrphanedSpeculativeBranchError( f"inbound event matches rolled-back intent {intent.tool} " f"from branch {intent.branch_id}; quarantine before routing to fresh instance" ) return False ```