# Which invariants prevent speculative tool-call pre-execution from committing effects out of causal order **Date of Record:** 2026 November 29 **Scope:** Applies to agents that overlap tool-call execution with in-flight reasoning by speculatively pre-executing predicted calls under effect isolation and resolving them at commit time. Does not apply to strictly serialized tool loops, nor to idempotent read-only tools with no external side effects. ## Core Distinction Speculative pre-execution is not the same as parallel tool dispatch. Parallel dispatch fires calls that the agent has *already decided* to commit; the only open question is ordering of results. Speculative pre-execution fires calls whose *argument bindings are still provisional*—the agent predicts that after reasoning step N it will call `write_config(path, value)`, and it launches the call under a shadow effect buffer before step N has resolved `value`. The distinction matters because the failure is not a race on the result channel; it is a race on the **effect ledger**. Two speculative branches can each be locally valid, each isolated, and still, at commit, produce an interleaving that no serial execution of the plan could have produced. The invariant at stake is *effect causal order*: the sequence of committed external mutations must be a linearization of the agent's reasoning dependency graph, not merely a linearization of the arrival order of speculative completions. ## What Was Observed A planning agent decomposed a migration task into steps that included `provision_bucket(name)` and `grant_reader(bucket, principal)`. During reasoning step 4, the model predicted both calls and launched them speculatively. `grant_reader` resolved first (the IAM API was warm); `provision_bucket` resolved 340 ms later against a cold control plane. Both ran inside isolated effect buffers keyed by speculative branch ID, so neither leaked. At commit time the resolver drained the buffer in **completion order**, not in **dependency order**, because the commit queue was a priority heap ordered by `resolved_at`. The grant committed against a bucket that, at the instant of commit, did not yet exist in the authoritative store. The IAM backend accepted the grant because its own eventual-consistency window let it bind to the pending bucket record; the object store then materialized the bucket and immediately reported an orphaned-policy anomaly. The agent's transcript recorded success. The reconciliation job recorded a divergence 90 seconds later. The non-obvious part: effect isolation *worked*. Nothing escaped the shadow buffer prematurely. The failure was entirely in the commit resolver's ordering predicate, which had been written as a latency-optimization and never audited against the dependency graph the planner had already materialized internally. ## Condition of Validity Speculative pre-execution is sound only when three conditions hold simultaneously: 1. **Every speculative call carries an explicit dependency set** derived from the reasoning graph (which prior steps must be *committed*, not merely *resolved*, before this call may commit). 2. **The commit resolver is a topological drain**, not a completion-order drain. A call whose dependencies are uncommitted must be held even if its effect buffer is full and validated. 3. **Speculation is bounded by a revalidation epoch.** Between speculation and commit, the arguments may have been rebound by later reasoning; the resolver must re-check that the committed argument tuple equals the speculated tuple, and abort-and-respeculate on mismatch. The failure above violated condition 2 while satisfying 1 and 3. The planner knew `grant_reader` depended on `provision_bucket`; the resolver ignored the edge because it treated "both resolved" as "both ready." ## Decision Boundary The boundary is between **resolution readiness** and **commit readiness**. A speculative call is resolution-ready when its effect buffer is validated and its result is available; it is commit-ready only when every node in its transitive dependency set is *committed to the authoritative store and acknowledged*. These are different predicates over different state, and conflating them is the defect. The correct guardrail: the commit resolver must refuse to drain any call whose dependency frontier contains an uncommitted node, and must surface that refusal as a structured hold rather than silently reordering. If the dependency frontier cannot drain within the speculation TTL, the entire speculative batch must be rolled back and re-executed serially—partial commit of a topologically invalid prefix is never acceptable, because the external world has no compensating transaction for "granted before provisioned." ## Operational Effect With a topological commit drain and epoch revalidation, the observed anomaly class disappears: grants cannot commit ahead of provisions, and stale-argument commits are converted into respeculations. The cost is throughput—speculative batches whose dependency graphs are deep will serialize at commit even when execution overlapped—but the effect ledger becomes a true linearization of the reasoning graph. Operationally, the resolver must emit a hold event per blocked call so that the planner can distinguish "slow" from "causally blocked," and the TTL rollback must be logged as a first-class outcome, not an error, because it is the correct behavior when speculation outran its own dependencies. ```python from dataclasses import dataclass, field from typing import Dict, Set class CommitOrderViolation(RuntimeError): """Raised when a speculative call is drained before its dependency frontier is committed.""" @dataclass class SpeculativeCall: call_id: str deps: Set[str] speculated_args: tuple resolved_args: tuple resolved_at: float committed: bool = False class TopologicalCommitDrain: def __init__(self) -> None: self.calls: Dict[str, SpeculativeCall] = {} def register(self, call: SpeculativeCall) -> None: self.calls[call.call_id] = call def _frontier_committed(self, call: SpeculativeCall) -> bool: return all( self.calls.get(dep) is not None and self.calls[dep].committed for dep in call.deps ) def drain(self) -> list: # Drain in dependency order, never in resolved_at order. committed_order = [] progress = True while progress: progress = False for call in sorted(self.calls.values(), key=lambda c: c.resolved_at): if call.committed: continue if not self._frontier_committed(call): continue if call.speculated_args != call.resolved_args: # Argument rebound after speculation: abort and respeculate. raise CommitOrderViolation( f"stale speculation for {call.call_id}: " f"{call.speculated_args!r} != {call.resolved_args!r}" ) call.committed = True committed_order.append(call.call_id) progress = True # Any remaining uncommitted call is causally blocked, not merely slow. blocked = [c.call_id for c in self.calls.values() if not c.committed] if blocked: raise CommitOrderViolation( f"causally blocked at commit TTL: {blocked}" ) return committed_order ```