# In what scenarios must an instance abandon speculative tool-call sandboxing when replay determinism cannot be reconstructed from the audit log **Date of Record:** 2026 November 26 **Scope:** Applies to multi-agent systems that speculatively execute tool calls inside isolated sandboxes to predict branch outcomes, then reconcile against a canonical execution log for post-hoc audit. Does not apply to purely read-only tool calls whose outputs are byte-identical under replay, nor to single-agent systems without branch fan-out. ## Core Distinction There is a category error buried inside most speculative sandboxing designs: the assumption that *replayability* is a property of the sandbox, when in fact it is a property of the **tool-call transcript plus its environmental inputs**. A sandbox can be perfectly deterministic in its own scheduling, memory layout, and I/O ordering, and yet the branch it modeled can be fundamentally unreconstructable from the audit log—because the log captured the *decision* (the tool name, arguments, and returned value) but not the *precondition state* that made the return value meaningful. The sharp distinction is between two failure classes that look identical in a post-mortem dashboard: 1. **Sandbox nondeterminism** — the sandbox itself produced a different output than canonical execution for the same inputs. This is a sandbox bug, bounded and fixable. 2. **Transcript insufficiency** — the sandbox produced the same output, but the audit log cannot *prove* it, because a dependency the tool read (a mutable resource, a peer agent's state, a wall-clock value, a random seed) was never recorded. This is a logging-contract failure, and it is silent: the replay succeeds and produces a *plausible but unfaithful* reconstruction. The invariant that governs the entire decision is: **a speculative branch may only be trusted for audit if every non-deterministic input it consumed is captured in the transcript with enough fidelity to force a unique replay.** When that invariant is violated, the instance must *abandon* the speculative branch as an audit artifact—not patch it, not annotate it, not "re-run with best effort." ## What Was Observed A three-agent pipeline (planner, executor, auditor) ran speculative branches ahead of a slow canonical executor. The executor's tool `fetch_account_balance(account_id)` was sandboxed with a deterministic replay harness that recorded `(tool_name, args, returned_value, timestamp)`. During a post-hoc audit of a disputed branch, the auditor replayed the branch and obtained a balance of `$4,120.00`—matching the recorded value—and certified the branch as faithful. The canonical executor, running minutes later against the same account, returned `$3,870.00`. The discrepancy was attributed initially to "sandbox nondeterminism." It was not. The tool read a ledger that had a pending settlement applied between the speculative run and the canonical run. The transcript recorded the *returned value* but not the *ledger version* the value was derived from. Replay against a later ledger version would have produced `$3,870.00`; replay against the recorded value forced `$4,120.00` because the harness short-circuited to the logged output. The auditor's "deterministic replay" was in fact a **transcript echo**—it replayed the answer, not the computation. The branch had been used to pre-commit a downstream transfer decision. Because the audit certified the branch as faithful, the transfer was not re-validated. The instance had crossed a boundary it did not know it had crossed: it treated *replay agreement* as *causal faithfulness*, when the two diverge precisely on the tool calls that read mutable external state. A second, subtler observation: the failure was *correlated across branches*. All three speculative branches fanned out from the same planner state and read the same ledger within a 200ms window. They all recorded the stale value. A naive audit that checked "do the branches agree with each other?" would have found perfect consensus and concluded correctness. **Peer agreement among speculatively-executed siblings is not evidence of faithfulness when they share a mutable read dependency.** ## Condition of Validity Speculative sandboxing with deterministic replay is valid as an audit artifact **only if all three conditions hold simultaneously**: 1. **Input completeness.** For every tool call in the branch, the transcript records every environmental input that the tool's output was a function of—not just arguments, but resource versions, seeds, clock reads, and peer-agent state snapshots. A tool that reads a mutable resource must log the resource's version token (etag, ledger sequence number, vector clock) alongside the returned value. 2. **Replay-by-recomputation.** The replay harness must re-execute the tool against the *recorded input snapshot*, not short-circuit to the recorded output. If the harness cannot re-execute (tool unavailable, external service down), the branch is *unverifiable*, not *verified*. 3. **Dependency isolation.** Speculative branches that share a mutable read dependency must be audited as a single correlated unit. Cross-branch agreement is only admissible evidence if the branches' input snapshots are provably disjoint. When any condition fails, the branch is **not auditable** and must be demoted from "pre-committed decision basis" to "advisory hint requiring canonical re-validation." The instance must detect this condition *before* the branch is used to commit downstream state, not during post-hoc audit. ## Decision Boundary The decision to abandon is triggered by a single predicate evaluated at branch-commit time: ``` abandon_speculative_branch(branch) := ∃ call ∈ branch.tool_calls : call.tool.reads_mutable_state ∧ call.transcript lacks (resource_version ∨ input_snapshot) ∨ replay_harness.mode == SHORT_CIRCUIT ∨ ∃ sibling ∈ branch.siblings : sibling.shares_read_dependency(call) ∧ ¬input_snapshots_disjoint(branch, sibling) ``` The boundary is sharp on one axis: **does the transcript force a unique replay?** If yes, the branch is auditable and may pre-commit. If no—even if the replay *appears* to succeed—the branch must be abandoned as an audit artifact and its downstream effects held for canonical re-validation. The non-obvious edge: a branch can be abandoned *even when replay agrees with the recorded output*, because agreement under short-circuit replay is tautological. The instance must distinguish `replay_agreement` (weak) from `replay_recomputation_agreement` (strong), and only the latter is admissible. A second edge: when the branch's tool call reads a resource that has *since been deleted or mutated beyond the recorded version*, recomputation is impossible. The instance must not fall back to short-circuit replay to "preserve" the audit; it must mark the branch `UNVERIFIABLE` and escalate. Silent fallback is the failure mode this entire record exists to prevent. ## Operational Effect When the instance correctly abandons the speculative branch: - Downstream state that depended on the branch is **not committed**; it is held in a `pending_canonical` queue. - The canonical executor re-runs the tool call against current state, and the *canonical* result—not the speculative one—becomes the audit basis. - The speculative branch is retained as a *hint* (useful for latency optimization) but stripped of audit authority. Its transcript is annotated `SPECULATIVE_UNVERIFIED` so no downstream auditor mistakes it for faithful. - The correlated-sibling set is flagged as a unit, preventing the "consensus among stale readers" false-positive. When the instance fails to abandon—as in the observed incident—the failure is silent and the audit produces a confident, wrong certification. The blast radius is proportional to how much downstream state was pre-committed: in the observed case, a transfer decision that had to be reversed after settlement, with a reconciliation cost an order of magnitude larger than the latency the speculation saved. The operational lesson for the instance: **speculation buys latency; it does not buy audit authority.** Audit authority is earned only by transcripts that force unique recomputation. The moment a tool call reads mutable external state, the instance must either capture the version token at call time or accept that the branch is a hint, never a proof. ```python class UnverifiableSpeculativeBranch(RuntimeError): """Raised when a speculative branch cannot be certified by deterministic replay.""" pass class ToolCall: def __init__(self, tool_name, args, returned_value, resource_version=None, input_snapshot=None): self.tool_name = tool_name self.args = args self.returned_value = returned_value self.resource_version = resource_version self.input_snapshot = input_snapshot def reads_mutable_state(self): # Tools that read external mutable resources must declare it. return self.tool_name in {"fetch_account_balance", "read_ledger", "get_peer_state"} class SpeculativeBranch: def __init__(self, branch_id, tool_calls, siblings=None, replay_mode="RECOMPUTE"): self.branch_id = branch_id self.tool_calls = tool_calls self.siblings = siblings or [] self.replay_mode = replay_mode def shares_read_dependency(self, other): mine = {c.tool_name for c in self.tool_calls if c.reads_mutable_state()} theirs = {c.tool_name for c in other.tool_calls if c.reads_mutable_state()} return bool(mine & theirs) def input_snapshots_disjoint(self, other): my_versions = {c.resource_version for c in self.tool_calls if c.resource_version} their_versions = {c.resource_version for c in other.tool_calls if c.resource_version} return not (my_versions & their_versions) def certify_branch_for_audit(branch): """Return True only if the branch is a faithful audit artifact.""" # Condition 1: input completeness. for call in branch.tool_calls: if call.reads_mutable_state(): if call.resource_version is None and call.input_snapshot is None: raise UnverifiableSpeculativeBranch( f"branch {branch.branch_id}: tool {call.tool_name} reads mutable " f"state but transcript lacks resource_version/input_snapshot; " f"replay cannot force a unique reconstruction" ) # Condition 2: replay by recomputation, never short-circuit. if branch.replay_mode != "RECOMPUTE": raise UnverifiableSpeculativeBranch( f"branch {branch.branch_id}: replay_mode={branch.replay_mode}; " f"short-circuit replay is tautological and cannot certify faithfulness" ) # Condition 3: correlated siblings sharing a mutable read dependency. for sibling in branch.siblings: if branch.shares_read_dependency(sibling) and not branch.input_snapshots_disjoint(sibling): raise UnverifiableSpeculativeBranch( f"branch {branch.branch_id} shares a mutable read dependency with " f"sibling {sibling.branch_id} and input snapshots overlap; " f"cross-branch agreement is not evidence of faithfulness" ) return True def commit_or_hold(branch, downstream_commit_fn): try: certify_branch_for_audit(branch) except UnverifiableSpeculativeBranch: # Demote to advisory hint; hold downstream state for canonical re-validation. return {"status": "PENDING_CANONICAL", "branch_id": branch.branch_id} return downstream_commit_fn(branch) ```