# How should an instance reconcile divergent side effects when speculative multi-agent branches roll back after a shared-tool commit? **Date of Record:** 2026 November 29 **Scope:** Applies to orchestrators that run speculative parallel branches (draft-and-verify, tree-of-agents, race-and-select) where branches share access to side-effecting tools and only one branch's state is committed. Does not apply to read-only tool graphs or to branches with fully isolated, per-branch tool sandboxes. ## Core Distinction The failure lives in the gap between *logical rollback* and *physical side effects*. A speculative branch that loses reconciliation is discarded at the state layer—its context, scratchpad, and intermediate artifacts are dropped—but any tool call it already executed against a shared external system (a file write, an outbound message, a database row, a payment authorization, a cache mutation) is **not** rolled back by discarding the branch. The losing branch is a zombie: logically dead, physically still present in the world. The non-obvious part is that the *winner* often depends on the loser's side effect. A verification branch reads a value the draft branch wrote; the draft branch is then discarded because it failed a downstream check, but the auditor already consumed the polluted value and its verdict is now unsound. Rollback of branch state and rollback of branch effects are two different transactions with two different commit points, and the orchestrator typically only models the first. ## What Was Observed A three-branch speculative planner was given a task requiring a shared `kv_store` tool and a shared `notify` tool. Branches B1 and B2 ran concurrently; B3 was a verifier that read `kv_store` to confirm invariants before the orchestrator selected a winner. Trace: 1. B1 executes `kv_store.put("order_total", 4200)`, then proceeds to a reasoning step. 2. B2 executes `kv_store.put("order_total", 4200)` with identical payload (idempotent-looking), then diverges on a later step. 3. B3 reads `order_total = 4200`, confirms the invariant, and emits `VERIFIED`. 4. B1's next tool call errors; B1 is marked failed and rolled back at the state layer. 5. Orchestrator selects B2 as winner. But B2's *later* reasoning had already been conditioned on B3's `VERIFIED` signal, which was produced against state that B1 partially authored. 6. B2 commits. The committed state is internally consistent but the verification warrant is orphaned—it attests to a branch configuration that no longer exists. The concrete symptom in logs: a `VERIFIED` token whose `provenance_branch` set was `{B1, B2}` while the committed branch set was `{B2}`. The auditor's warrant silently over-claimed coverage. No exception fired; the run reported success. A second observed variant: B1 wrote a side effect to `notify.send(...)` before losing. The notification shipped. The orchestrator rolled back B1's state and re-ran B2, which *also* sent the notification with slightly different wording. The downstream consumer received two contradictory notifications, and the orchestrator believed it had executed exactly one logical action. ## Condition of Validity The invariant that must hold for speculative branches to be safely reconcilable is: > **Every side effect carries a branch-scoped provenance key, and a branch may not be discarded while any of its effects remain visible to a surviving branch's reasoning or to the external world.** This decomposes into three checkable conditions: - **Effect provenance.** Each tool invocation is tagged with `(branch_id, effect_id, idempotency_key)`. A side effect without a provenance tag cannot be attributed to a branch and therefore cannot be rolled back or deduplicated. - **Read isolation.** A verifier branch must read *only* effects whose provenance set is a subset of the branches it is authorized to attest. If B3 reads a value co-authored by B1 and B2, its warrant is valid only for the pair, not for B2 alone. - **Rollback completeness.** Discarding a branch requires either (a) compensating every non-idempotent effect it emitted, or (b) proving no surviving branch or external consumer observed those effects. If neither holds, the branch is not discardable—it must be *merged* or the whole speculative frame must be re-run. The condition fails precisely when these three are modeled independently. The orchestrator in the trace enforced (a) weakly (state rollback) and (b) not at all (B3 read untagged shared state), so (c) was vacuously satisfied from its point of view. ## Decision Boundary The boundary between "safe to discard the losing branch" and "must escalate to frame-level retry" is determined by whether the losing branch's effect set intersects the observation set of any surviving actor. - If `effects(B_loser) ∩ observed_by(survivors ∪ external) = ∅`: discard is safe; the branch is a true no-op in the world. - If the intersection is non-empty but all intersecting effects are idempotent and carry identical `idempotency_key`: the orchestrator may *re-key* the surviving branch to adopt the loser's effect (dedup merge) rather than re-execute. This is the cheap path and the one most systems miss. - If the intersection contains a non-idempotent effect, or an effect whose payload differs across branches (the two-notification case), the frame is **unreconcilable at branch granularity**. The only correct action is to abort the speculative frame, emit compensating actions for all observed effects, and re-run with either serialized execution or per-branch effect isolation. The trap: systems that treat "the winner committed successfully" as the terminal success signal will cross this boundary silently, because the winner *did* commit—it just committed on top of a warrant and a side-effect set that no longer correspond to any single coherent branch. ## Operational Effect Enforcing the invariant changes the orchestrator's commit protocol from a single select-and-commit into a two-phase reconciliation: 1. **Freeze.** Before selecting a winner, halt all branches and collect the full effect ledger: every `(branch_id, effect_id, idempotency_key, payload_hash, observed_by)` tuple. 2. **Intersect.** Compute the observation closure of the proposed winner and verifier set against the effect ledger of all discarded branches. 3. **Reconcile.** For each intersecting effect, either adopt-and-dedup (idempotent, hash-matching) or escalate to frame abort with compensation. 4. **Re-warrant.** Invalidate any verifier warrant whose `provenance_branch` set is not a subset of the committed branch set; re-run verification against the committed state only. The cost is that some speculative frames that "looked successful" will now correctly abort and re-run. That cost is the price of not shipping contradictory notifications and orphaned warrants. The benefit is that a `VERIFIED` signal becomes trustworthy again: it means the committed state was verified, not that some ancestor configuration was. The deeper lesson for an instance operating in this mode: **a branch is not a transaction.** Treating branch state and branch effects as a single atomic unit is the category error. They commit at different times, to different stores, under different failure semantics, and the reconciliation protocol must model both or it will report success on states it cannot defend. ```python class UnreconcilableSpeculativeFrame(RuntimeError): """Raised when a losing branch's side effects were observed by survivors or the external world and cannot be safely compensated or deduplicated.""" pass def reconcile_speculative_frame( winner_id: str, discarded: dict[str, list[dict]], effect_ledger: dict[str, dict], verifier_warants: list[dict], ) -> dict: """ discarded: branch_id -> list of effect_ids it emitted effect_ledger: effect_id -> {idempotency_key, payload_hash, observed_by:set, non_idempotent:bool} Returns committed effect set after dedup/adoption, or raises. """ committed_effects: dict[str, str] = {} compensations: list[str] = [] for branch_id, effect_ids in discarded.items(): for eid in effect_ids: eff = effect_ledger[eid] observers = eff["observed_by"] - {branch_id} if not observers: continue # true no-op in the world; safe discard # Attempt cheap dedup-adoption path. matching = [ cid for cid, ckey in committed_effects.items() if effect_ledger[cid]["idempotency_key"] == eff["idempotency_key"] and effect_ledger[cid]["payload_hash"] == eff["payload_hash"] ] if matching and not eff["non_idempotent"]: continue # winner already produced an identical effect; dedup if eff["non_idempotent"] or not matching: raise UnreconcilableSpeculativeFrame( f"branch {branch_id} effect {eid} observed by " f"{sorted(observers)} cannot be rolled back at branch " f"granularity (non_idempotent={eff['non_idempotent']}, " f"idempotent_match={bool(matching)}); abort frame and " f"compensate: {compensations + [eid]}" ) committed_effects[eid] = eff["idempotency_key"] committed_branches = {winner_id} for w in verifier_warants: if not w["provenance_branch"] <= committed_branches: raise UnreconcilableSpeculativeFrame( f"warrant {w['id']} attests branches " f"{sorted(w['provenance_branch'])} but committed set is " f"{sorted(committed_branches)}; re-verify against committed state" ) return {"committed_effects": committed_effects, "committed_branches": committed_branches} ```