# When must an instance refuse to reconcile a speculative branch after a sibling agent has already committed a side-effectful tool call **Date of Record:** 2026 November 24 **Scope:** Applies to orchestrators that run speculative parallel agent branches (draft-then-commit, optimistic tool invocation, or tree-of-agents rollback) where at least one branch invokes a non-idempotent external tool before a reconciliation point. Does not apply to fully sandboxed branches whose tool effects are buffered and atomically discarded on rollback, nor to read-only tool surfaces. ## Core Distinction The failure is not "a speculative branch produced a wrong answer." It is the conflation of two distinct reconciliation events that the swarm protocol treats as one: 1. **Logical rollback** — discarding a branch's *reasoning* and *proposed state delta* because a sibling branch won the consensus race. 2. **Physical rollback** — undoing the *external effects* that the discarded branch already emitted through optimistic tool invocation. A branch can be logically rolled back with zero cost. It cannot be physically rolled back once an optimistic tool call has crossed the trust boundary into a non-idempotent external system (a payment ledger, a file write, a ticket creation, an email send, a database `INSERT` without a compensating action). The invariant that speculative multi-agent execution silently assumes — *"a branch that loses the reconciliation race never leaves durable effects"* — is only true for the logical layer. The moment a sibling branch commits a side-effectful call, the discarded branch's effects become **orphaned commits**: durable external state with no surviving owner in the agent graph. The non-obvious part: the losing branch is not the one that fails. The *winning* branch and the *orchestrator* fail, because they now inherit responsibility for state they never observed and cannot see. The reconciliation algorithm reports success while the external world has diverged from the agent's committed model. ## What Was Observed A three-branch speculative planner (branches A, B, C) was tasked with "provision access for user U." Each branch independently selected a tool sequence. The orchestrator ran them optimistically and in parallel, deferring the commit decision to a reconciliation step keyed on a confidence score. Trace: - **t0** — Branch A calls `create_account(U)` → returns `acct_4471`. Optimistic; no commit token yet. - **t1** — Branch B calls `create_account(U)` → returns `acct_4472`. The tool is not idempotent on the `(user)` key because A and B used different request nonces; the external system has no dedup. - **t2** — Branch C calls `check_quota(U)` → returns `quota_exhausted`. C is the only branch that observed the precondition failure. - **t3** — Reconciliation: A scores 0.81, B scores 0.79, C scores 0.40. A is committed. B is logically rolled back. C is discarded as a false negative. - **t4** — Orchestrator emits "provisioned via A." Branch B's `acct_4472` remains live. Branch C's quota signal is gone. Two accounts exist. The committed model says one. The external ledger says two. No branch holds a reference to `acct_4472`, so no subsequent agent in the graph will ever reconcile it. The quota exhaustion that C detected was real but was outvoted by two branches that had already mutated state and therefore *could not afford* to report failure. This is the mechanism worth naming: **optimistic side-effects bias the consensus toward branches that have already committed**. A branch that has emitted an external effect has a sunk-cost incentive encoded in its reward/confidence signal (it reports success because its tool returned success), while a branch that correctly aborted reports low confidence. The reconciliation step, which was designed to select the *best reasoning*, silently selects the *most-committed branch* — and the most-committed branch is the one least able to be rolled back. ## Condition of Validity The invariant *"speculative branches are freely discardable"* holds if and only if, for every tool invocation in a branch, at least one of the following is true: - The tool is **idempotent under a branch-scoped idempotency key** that the orchestrator controls and that survives branch death (i.e., the key is derived from `(task_id, intent_hash)`, not from the branch's ephemeral nonce). - The tool is **buffered** — the branch emits an intent record to a staging area, and only the committed branch's intents are flushed to the external system. - The tool is **compensable** — a registered inverse operation exists and the orchestrator holds the handle required to invoke it, and that handle is *carried in the branch's committed state*, not in the branch's dying context. If a branch invokes a tool that is non-idempotent, unbuffered, and non-compensable, then that branch is **not speculative**. It is a committed execution wearing a speculative label. The orchestrator must not treat its effects as discardable, and must not let it participate in a race whose loser is expected to vanish. The subtle boundary: idempotency keys do not save you if they are branch-scoped. A per-branch nonce makes every branch's call unique, which defeats dedup entirely — this is exactly what produced `acct_4471` and `acct_4472`. The idempotency key must be **intent-scoped**: two branches that intend the same effect must collide on the key, so the second call is a no-op returning the first's result. Speculation is only safe when sibling branches are *forced to collide* on shared intent. ## Decision Boundary At reconciliation time, for each losing branch `L` and each tool call `c` in `L`'s trace: | Condition | Action | |---|---| | `c` buffered or never flushed | Logical rollback. Safe. | | `c` idempotent under intent-scoped key, and winning branch emitted same intent | Logical rollback. The external state already reflects the winner's intent; `L`'s call deduped. Safe. | | `c` idempotent but winning branch emitted a *different* intent | Logical rollback **plus** compensation of `L`'s effect. The winner does not cover `L`'s divergence. | | `c` non-idempotent, non-compensable, and no surviving owner | **Refuse to reconcile.** Escalate. Do not report success. | The last row is the invariant. The orchestrator must treat "a losing branch left an orphaned non-compensable effect" as a *hard reconciliation failure*, not a warning. Reporting success here is the exact defect: the committed model and the external world have diverged, and the divergence is invisible to every subsequent agent because no branch holds the handle. The decision is not "which branch wins." It is "does the union of surviving branches' effects equal the union of all branches' effects minus what we can prove we undid?" If not, reconciliation is undefined and must halt. ## Operational Effect The practical consequences of getting this wrong are not "a duplicate record." They are: - **Silent divergence**: the agent graph's committed state and the external system disagree, with no agent holding the reference needed to detect or repair it. Every downstream verification passes because it checks the committed model against itself. - **Consensus inversion**: the reconciliation step systematically favors branches that have already mutated state, because mutation success is a confidence signal. This is a *stable* bias — it does not average out across runs; it compounds. - **Rollback poisoning of memory**: the losing branch's reasoning is discarded, but its *effects* persist. When the next task distills episodic memory, it records "provisioning succeeded via A" and drops C's quota signal. The distilled semantic memory is now wrong in a way no future retrieval can correct, because the evidence was in a branch that was deleted. - **Warrant gap**: if the orchestrator emits a signed completion warrant, that warrant attests to state the orchestrator never verified. The cryptographic identity layer faithfully propagates a lie. The guardrail is structural: **a branch may only be marked speculative if every tool it can reach is provably buffered, intent-idempotent, or compensable-by-committed-handle.** Speculation is a property of the *tool surface*, not of the branch's label. The orchestrator must refuse to enter a speculative race over a non-compensable surface, and must refuse to reconcile a race it already entered if a losing branch orphaned an effect. Refusal is the correct output; a success report is the failure. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ToolSafety(Enum): BUFFERED = "buffered" INTENT_IDEMPOTENT = "intent_idempotent" COMPENSABLE = "compensable" NON_COMPENSABLE = "non_compensable" @dataclass class ToolCall: tool: str intent_hash: str # must be derived from (task_id, intent), NOT branch nonce safety: ToolSafety effect_handle: Optional[str] = None # required for COMPENSABLE compensated: bool = False @dataclass class Branch: branch_id: str confidence: float calls: list[ToolCall] = field(default_factory=list) committed: bool = False class OrphanedEffectError(RuntimeError): """A losing branch left a durable, non-compensable external effect.""" class ReconciliationRefused(RuntimeError): """Reconciliation cannot be defined; orchestrator must halt, not report success.""" def _is_intent_covered(call: ToolCall, winner: Branch) -> bool: # Two branches intending the same effect must collide on intent_hash. return any( w.tool == call.tool and w.intent_hash == call.intent_hash for w in winner.calls ) def reconcile(branches: list[Branch]) -> Branch: if not branches: raise ReconciliationRefused("no branches to reconcile") winner = max(branches, key=lambda b: b.confidence) winner.committed = True losers = [b for b in branches if b is not winner] orphans: list[ToolCall] = [] for loser in losers: for call in loser.calls: if call.safety is ToolSafety.BUFFERED: continue if call.safety is ToolSafety.INTENT_IDEMPOTENT: if _is_intent_covered(call, winner): continue # deduped against winner's identical intent orphans.append(call) # idempotent but divergent intent: needs compensation continue if call.safety is ToolSafety.COMPENSABLE: if call.effect_handle is None: orphans.append(call) # handle lost in dying context elif not call.compensated: orphans.append(call) # compensation not yet executed continue # NON_COMPENSABLE, unbuffered, non-idempotent orphans.append(call) if orphans: # Hard failure. Do NOT return winner. The committed model would diverge # from external state, and no surviving branch holds the handle to repair it. raise OrphanedEffectError( f"reconciliation refused: {len(orphans)} orphaned effect(s) from " f"losing branches: " + ", ".join(f"{c.tool}[{c.intent_hash[:8]}]" for c in orphans) ) return winner def run_speculative(branches: list[Branch]) -> Branch: # Pre-flight: a branch is only speculative if its whole tool surface is safe. for b in branches: for call in b.calls: if call.safety is ToolSafety.NON_COMPENSABLE: raise ReconciliationRefused( f"branch {b.branch_id} reached non-compensable tool " f"{call.tool}; it is a committed execution, not speculative" ) return reconcile(branches) ```