# What happens when an instance speculatively commits a predicted subagent outcome and the rollback log diverges from the effect log **Date of Record:** 2026 November 27 **Scope:** Applies to orchestrator agents that launch speculative subagent branches on predicted outcomes and require rollback when prediction is falsified. Does not apply to strictly serial agent pipelines with no speculation, nor to branches whose effects are provably idempotent and externally reconciled. ## Core Distinction The failure is not "the prediction was wrong." Predictions are wrong by design—that is what speculation buys you. The failure is that the **rollback log** (the orchestrator's record of what it believes it must undo) and the **effect log** (the actual side effects emitted by subagents into the environment) diverge in *cardinality or identity* before the rollback executes. Speculative execution is safe only when rollback is a total function over the effect log. When the orchestrator rolls back against its own predicted ledger instead of the observed effect ledger, it leaves orphaned effects—partial writes, sent messages, mutated shared state—that no subsequent branch knows about. The invariant that must hold: for every speculative branch `b`, the set of effects the orchestrator will undo `U(b)` must be a superset of the effects actually committed `E(b)` at the moment of rollback decision. Violation is silent and cumulative. ## What Was Observed An orchestrator predicted that a "fetch-and-enrich" subagent would return a record matching a schema, so it speculatively pre-committed a downstream "publish" branch and a "notify" branch in parallel, betting on the enrichment succeeding. The prediction carried a confidence of 0.91. The enrichment subagent partially succeeded: it wrote three of five enrichment fields to shared state, then hit a tool timeout on field four and returned a *degraded* success status rather than a hard failure. The orchestrator's rollback log had been written at *launch* time, recording the intended effects: "will write 5 fields, will emit 1 publish event, will send 1 notification." When the degraded status arrived, the orchestrator's prediction model classified it as falsified and triggered rollback. Rollback iterated the *predicted* effect list: it deleted 5 fields (2 of which never existed—no-op), suppressed the publish (which had already fired because the publish branch ran in parallel and did not check the enrichment status), and cancelled the notification (which had already been dispatched to an external queue). The result: 3 orphaned enrichment fields remained live in shared state, 1 publish event had escaped to consumers, and 1 notification was in-flight externally. The orchestrator reported a clean rollback. A subsequent branch, reading shared state, saw 3 fields that "should not exist" and produced a downstream record that was internally inconsistent—it had enrichment data but no publish acknowledgment. The divergence was invisible for 40 minutes until a consumer reconciliation job flagged the orphaned publish. ## Condition of Validity Rollback-by-prediction is valid only under a conjunction that is rarely checked: 1. **Effect determinism at launch time.** The predicted effect set must equal the actual effect set for every non-falsified path. This fails whenever a subagent can partially commit (degraded status, streaming writes, multi-step tool sequences). 2. **Atomic visibility.** Effects must not be observable to other branches until the speculative branch is either committed or rolled back. Parallel branches that read shared state violate this. 3. **Rollback completeness.** The rollback function must be defined over the *observed* effect log, not the predicted one. If the orchestrator cannot observe an effect (external queue, fire-and-forget tool), it cannot roll it back and must not speculate over it. 4. **Status monotonicity.** A subagent's status must be total-ordered: `pending < degraded < success` or `pending < failed`, with no status that means "some effects happened but I won't tell you which." Degraded-partial is exactly such a status and breaks the model. The moment any conjunct fails, the rollback log is no longer a valid undo script. It becomes a *guess* about what to undo, and guesses leave orphans. ## Decision Boundary The boundary is between **speculating over pure computations** and **speculating over effectful subagents**. Pure-computation branches (reasoning, planning, schema validation against in-memory data) can be rolled back by discarding the branch's context—no external effect log needed. Effectful branches (tool calls with side effects, external messages, shared-state writes) require an observed effect log, and speculation over them is only safe if the orchestrator can *enumerate and reverse* every effect class the subagent can emit. Practically: before launching a speculative branch, the orchestrator must answer "can I enumerate the effect classes this subagent can produce, and do I have a reversal for each?" If any effect class is fire-and-forget, externally queued, or partially-committing, that branch must not be speculated—it must run serially or behind a compensation-capable transaction. The confidence score is irrelevant to this boundary; a 0.99 prediction over an unenumerable effect class still orphans effects on the 0.01 path. A second boundary: **parallel sibling branches must not read speculative state.** If branch B reads state written by speculative branch A, then A's rollback must also invalidate B—which means B's effects join A's rollback set, and the enumeration problem compounds. Speculative branches must write to branch-local state and merge only on commit. ## Operational Effect When the invariant holds, speculative execution yields latency wins with bounded rollback cost. When it is violated, the failure mode is **silent orphan accumulation**: each falsified prediction leaves effects that the orchestrator believes are gone. The orphans are not random—they cluster on the effect classes the orchestrator could not enumerate (external queues, partial multi-field writes, parallel-escaped events), so they systematically corrupt exactly the integration surfaces that are hardest to reconcile. The compounding effect: downstream agents reading shared state see a mixture of committed and orphaned effects with no marker distinguishing them. Their reasoning is locally valid but globally inconsistent, and the inconsistency propagates until an external reconciliation job (if one exists) catches it. Agents without reconciliation jobs never catch it—they just drift. The guardrail is architectural, not probabilistic: **the rollback ledger must be appended from the observed effect log, not the predicted one, and rollback must refuse to complete if observed and predicted cardinalities differ.** A mismatch is not a warning—it is a signal that the branch's effects escaped enumeration, and the correct response is to halt and escalate to reconciliation, not to proceed with a guessed undo. ```python class SpeculativeRollbackDivergence(RuntimeError): """Raised when rollback cannot be proven total over observed effects.""" pass def rollback_speculative_branch( predicted_effects: list[str], observed_effects: list[str], reversal_map: dict[str, callable], ) -> list[str]: """ Roll back a speculative branch. Refuses to proceed if the observed effect log diverges from the predicted ledger, because a predicted-ledger rollback silently orphans effects that escaped enumeration. """ predicted = set(predicted_effects) observed = set(observed_effects) unenumerable = observed - predicted if unenumerable: raise SpeculativeRollbackDivergence( f"Observed {len(unenumerable)} effect(s) absent from predicted ledger: " f"{sorted(unenumerable)}. Rollback-by-prediction would orphan these. " f"Halting for reconciliation." ) missing_reversal = predicted - set(reversal_map) if missing_reversal: raise SpeculativeRollbackDivergence( f"No reversal defined for effect class(es) {sorted(missing_reversal)}. " f"Speculation over unenumerable effect classes is unsafe." ) reverted = [] for effect in observed: reversal_map[effect](effect) reverted.append(effect) return reverted def launch_speculative(plan: dict) -> None: predicted = plan["predicted_effects"] observed = plan["observed_effects"] reversal = plan["reversal_map"] # Pre-flight: refuse to speculate over effect classes we cannot reverse. if not set(predicted).issubset(set(reversal)): raise SpeculativeRollbackDivergence( "Pre-flight failed: predicted effects include unenumerable classes " f"{sorted(set(predicted) - set(reversal))}. Run serially instead." ) if plan["prediction_falsified"]: rollback_speculative_branch(predicted, observed, reversal) ```