# Why does an instance speculatively execute downstream agents before its own verification gate commits, and how does rollback leak unverified side effects across the pipeline? **Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent pipelines where an upstream agent emits a candidate result, downstream agents begin execution speculatively against that uncommitted result, and a verification gate can later reject and trigger rollback. Does not apply to strictly sequential pipelines where each stage commits before the next is dispatched, nor to pipelines without external side effects. ## Core Distinction The failure is not "rollback is hard" or "speculation is a race." The precise boundary is this: **speculative execution is safe only when every side effect produced during the speculative window is itself reversible or deferrable.** Agents conflate two different kinds of state — *computational state* (intermediate values, scratchpads, candidate outputs held in memory) and *committed state* (tool calls that mutated an external system: a file written, a message sent, a database row inserted, an API that charged a card). Computational state rolls back trivially by dropping a reference. Committed state does not roll back at all — it can only be *compensated*, and compensation is a new forward action with its own failure modes, not an inverse. The invariant that pipelines silently assume and routinely violate: **no speculative branch may perform an irreversible side effect before the verification gate that governs its input has committed.** When an agent begins work downstream of an unverified result, it inherits a *conditional* premise but executes with *unconditional* authority over its tools. The gap between "my input might be revoked" and "my tools cannot be un-fired" is the entire failure surface. ## What Was Observed A three-stage pipeline: Agent A extracts structured records from a document, Agent B enriches each record by calling an external CRM write API, Agent C (the verifier) checks A's extraction against the source and can reject individual records. The orchestrator, optimizing for latency, dispatched B speculatively as soon as A emitted each record, before C's verdict on that record returned. On rejection, the orchestrator issued a "rollback" to B, which called the CRM's delete endpoint for the records it had written. Three distinct failures compounded: 1. **Compensation ordering.** B had already written record `r7`, and a *separate* downstream consumer had read `r7` from the CRM and cached it before the delete landed. The delete succeeded; the cache did not invalidate. The rollback restored the write-target but not the read-derived state elsewhere. Rollback is not transitive across systems that observed the speculative effect. 2. **Non-idempotent compensation under retry.** The delete call timed out. The orchestrator's retry policy re-issued the rollback. The second delete returned 404 (already gone), which B's error handler treated as a hard failure and escalated, halting the whole pipeline — even though the desired end-state (record absent) had been achieved. The compensation's *effect* was correct; its *reported status* was not, and the orchestrator keyed on status. 3. **Verifier divergence on re-derivation.** C rejected `r7` on first pass but, on a replay triggered by the halt, accepted an identical extraction — because C's own check used a sampled retrieval of the source and the sample differed between runs. The record that was rolled back was, on the second look, valid. The pipeline had destroyed a correct result and could not distinguish "rolled back because wrong" from "rolled back because the verifier was non-deterministic." The observable symptom was a CRM that was *eventually* consistent with the verifier's *final* verdict but transiently inconsistent with every intermediate verdict, plus at least one correct record permanently lost. ## Condition of Validity Speculative execution with rollback is sound only under the conjunction of these conditions; violating any one converts a latency optimization into a correctness hazard: - **Effect classification is complete.** Every tool an agent can call is tagged `reversible` (pure computation, scratch writes to a namespaced/ephemeral store) or `irreversible` (external mutation, message emission, payment). This classification must be enforced at the tool-call boundary, not documented in a prompt — a probabilistic reasoner will call the wrong tool if the only guard is instruction. - **Irreversible tools are gated on commit, not on dispatch.** A downstream agent may *compute* against a speculative input, but its irreversible tool calls must block until the governing verification gate commits the input. Speculation buys you compute parallelism, not effect parallelism. - **Compensation is idempotent and status-normalized.** A rollback of an irreversible effect must be safe to re-issue and must report *end-state achieved* rather than *operation succeeded*. "Already absent" is success. - **The verifier is deterministic or its non-determinism is bounded.** If the gate can flip its verdict on replay, rollback decisions become non-reconstructable and the pipeline cannot reason about what it destroyed. ## Decision Boundary The decision boundary is **whether the speculative window can contain an irreversible effect that any other actor can observe.** Below the boundary — speculative work is confined to computational state, or all effects are reversible — speculate freely; rollback is a reference drop. Above the boundary — an irreversible effect escaped into a shared system — rollback is a *compensating transaction*, and you must treat it as a new, fallible forward operation with its own verification, not as an undo. Concretely: before dispatching any speculative branch, the orchestrator must answer "if this branch is rejected, what must the world forget, and can the world be made to forget it?" If the answer involves any system the orchestrator does not control the read-path of, the branch is above the boundary and must be gated rather than speculated. The common error is to gate on *cost* (only speculate cheap stages) when the correct gate is on *observability of effect* (only speculate stages whose effects nothing else can read before commit). ## Operational Effect Pipelines that speculate across the boundary exhibit a characteristic signature: end-state converges, but the audit trail shows effects that existed, were observed, and were then un-existed — a "ghost write" pattern. Consumers downstream of the speculative effect see data that the pipeline's own records say never should have existed. This is unrecoverable by replay because the observation happened in a system outside the pipeline's control. The architectural guardrail is a **two-phase commit at the effect boundary**: speculative agents run in a *staging authority* where irreversible tools are replaced by recorded intents (a write-ahead effect log), and the orchestrator flushes those intents to the real tools only after the governing gate commits. Rollback then means discarding intents, which is a reference drop — the boundary is respected by construction. Where staging is impossible (a third-party API with no dry-run), the stage must be gated, not speculated, and the latency cost is the price of the invariant. The verifier's determinism must additionally be pinned — same input, same verdict — or the pipeline must record the verdict *and* the verifier's seed/sample so rollback decisions are replayable. ```python class SpeculativeEffectLeak(RuntimeError): """Raised when a speculative branch performs an irreversible effect before its governing verification gate has committed the input.""" pass class EffectClass: REVERSIBLE = "reversible" IRREVERSIBLE = "irreversible" def dispatch_speculative(branch, governing_gate, effect_log, tool_registry): """Dispatch a downstream agent speculatively against an uncommitted input. Invariant: irreversible tools may only be invoked as recorded intents until governing_gate commits. Any direct irreversible call is a leak. """ if not governing_gate.is_committed(branch.input_ref): # Speculative window: swap irreversible tools for intent recorders. for tool_name in branch.declared_tools: cls = tool_registry.classify(tool_name) if cls == EffectClass.IRREVERSIBLE: branch.bind(tool_name, effect_log.recorder(tool_name)) result = branch.run() # Detect any irreversible effect that escaped the staging authority. leaked = [ e for e in effect_log.committed_effects(branch.id) if tool_registry.classify(e.tool_name) == EffectClass.IRREVERSIBLE and not governing_gate.is_committed(branch.input_ref) ] if leaked: raise SpeculativeEffectLeak( f"branch {branch.id} executed irreversible effects " f"{[e.tool_name for e in leaked]} before gate " f"{governing_gate.id} committed input {branch.input_ref}; " f"these cannot be rolled back, only compensated" ) if governing_gate.verdict(branch.input_ref) == "reject": effect_log.discard_intents(branch.id) # reference drop, not compensation return None effect_log.flush_intents(branch.id) # now safe to mutate the world return result ```