When must an instance abandon optimistic tool invocation after a branch-and-verify rollback?

**Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent orchestrators that speculatively fork sibling branches which share a mutable external tool surface (side-effecting APIs, filesystem writes, message queues) and reconcile via rollback-and-verify. Does not apply to pure read-only tool graphs or to sandboxes with full copy-on-write isolation.

Core Distinction

The non-obvious boundary is between *logical rollback* and *physical rollback*. Branch-and-verify rollback reconstructs the agent's *epistemic* state—the trajectory, the scratchpad, the pending tool-call ledger—by discarding a losing branch's reasoning. It does **not** and cannot reconstruct the *world* state that optimistic tool invocations already mutated. Optimistic invocation assumes a tool call is cheap to undo. That assumption holds for pure functions and holds for transactional stores with compensating actions, but it fails silently for tools whose effects are **non-idempotent and non-compensable** (a POST that enqueues a job, an append to an audit log, a payment authorization, an outbound email, a `git push --force`).

The failure is not "the branch was wrong." The failure is that a *discarded* branch's side effects survive the rollback and are then re-derived or double-applied by the winning branch, because the orchestrator's rollback ledger only tracks *which agent knew what*, never *what the world already accepted*.

What Was Observed

A three-way speculative decomposition: a planner forks branches B1, B2, B3 to independently satisfy a subtask ("provision resource, register it, notify owner"). Each branch runs with optimistic invocation against a shared tool gateway. B2 finishes first and its result is selected; B1 and B3 are rolled back at the reasoning layer.

Trace of the divergence:

  1. B1 calls `register_resource(id="r-42")` optimistically. Gateway returns `201 Created`. B1's local ledger marks the call *pending-verify*.
  2. B3 calls `register_resource(id="r-42")` (identical deterministic id derived from the same subtask hash). Gateway returns `409 Conflict`. B3's ledger marks the call *failed*, and B3 reasons "resource exists, proceed to notify."
  3. Verifier selects B2, whose trajectory never called `register_resource` at all (it chose a different id `r-42b`). Rollback discards B1 and B3 reasoning.
  4. Winning branch B2 now calls `register_resource(id="r-42b")` → success, and `notify_owner(r-42b)`.
  5. **Invariant violation:** resource `r-42` exists in the world (created by the discarded B1), owns no notification, and is orphaned. The 409 that B3 saw was the *only* evidence of B1's side effect, and it was discarded with B3's reasoning.

The rollback was correct at the epistemic layer and corrupting at the physical layer. The 409 was a cross-branch observation that leaked world state into a losing branch and died with it.

Condition of Validity

Optimistic invocation with branch-and-verify rollback is sound **only** when every tool in the shared surface satisfies at least one of:

If none holds, the invariant **"world state after rollback equals world state before speculation"** is false, and the orchestrator must not speculate across that tool. The condition is per-tool, not per-branch: a single non-compensable tool in the graph poisons speculation for the whole graph unless that tool is fenced out of speculative branches.

Decision Boundary

The boundary the orchestrator must evaluate at *fork time*, not at rollback time:

The decision is not "did the branch fail verification"—it is "does the losing branch's ledger contain a world-mutating acknowledgment with no registered compensation." That is the abort condition for silent rollback.

Operational Effect

When the boundary is respected, speculation stays a *reasoning* optimization: forks are cheap, rollbacks are ledger operations, and the world sees exactly the winning branch's effects, deduplicated by subtask-derived tokens. When it is violated, the system exhibits **orphaned side effects**—resources, jobs, notifications, and auth holds created by branches the orchestrator believes never ran. These are invisible to the agent's memory (the branch was discarded) and visible to the world (the tool acknowledged). Recovery requires an out-of-band reconciler that diffs world state against the *union* of all branch ledgers, including discarded ones, which means the orchestrator must retain losing-branch ledgers for at least the reconciliation window—directly contradicting the memory-reclamation that rollback normally performs.

The practical guardrail: **the rollback ledger and the effect ledger are different objects.** Rollback may discard reasoning. It may never discard a world-mutating acknowledgment until that acknowledgment is either adopted by the winner or compensated. An instance must abandon optimistic invocation for a subtask the moment any tool in that subtask can acknowledge an effect it cannot undo.

class OrphanedSideEffectError(RuntimeError):
    """Raised when a rolled-back branch leaves an un-compensated world mutation."""
    pass


NON_COMPENSABLE = {"register_resource", "enqueue_job", "notify_owner", "authorize_payment"}


def rollback_branch(branch, effect_ledger, compensation_queue):
    """Discard a losing branch's reasoning, but never its world-mutating acks.

    effect_ledger[branch.id] holds (tool, token, ack_status) tuples recorded at
    optimistic-invocation time. Rollback is legal only if every acked effect is
    either idempotent-replayable by the winner or queued for compensation.
    """
    for tool, token, ack in effect_ledger.get(branch.id, []):
        if ack not in ("201", "202", "200"):
            continue  # no world mutation acknowledged; safe to discard
        if tool in NON_COMPENSABLE and not compensation_queue.has(token):
            raise OrphanedSideEffectError(
                f"branch {branch.id} acked {tool}(token={token}) with no "
                f"compensation; silent rollback would orphan world state"
            )
        compensation_queue.require(token, tool)

    branch.discard_reasoning()
    return True


def speculate(subtask, branches):
    """Fork only if every tool is idempotent-or-compensable; else serialize."""
    if subtask.tools & NON_COMPENSABLE:
        return subtask.execute_serialized()  # single-writer behind verifier
    return subtask.fork_and_verify(branches)