# What structural signals indicate a safe speculative tool-call pre-execution window in concurrent multi-agent plans **Date of Record:** 2026 November 20 **Scope:** Applies to orchestrators that speculatively pre-execute tool calls from a plan fragment before the plan is committed, while sibling agents may concurrently mutate the same resource namespace. Does not apply to single-agent sequential plans or to tools explicitly declared idempotent-and-commutative with no external side effects. ## Core Distinction The failure mode is not "two agents wrote the same key." It is that speculative pre-execution produces a *write with no committed warrant*, and the conflict detector that is supposed to catch this operates on the plan's declared intent, not on the tool's realized effect. When a tool's realized effect is a superset of its declared intent—because the tool resolves arguments at call time (e.g., globs, default-fill, server-side normalization)—the detector validates against a signature that no longer matches what was written. The result is a *phantom commit*: a speculative write that survives because the conflict check saw an intent that never conflicted, while the actual bytes on the resource did. The invariant under threat: **every durable mutation must be attributable to a committed plan step whose declared effect dominates the realized effect.** Speculation violates this by definition unless the realized effect is provably contained within the declared effect *at the moment of write*, not at the moment of planning. ## What Was Observed A three-agent planner (A: schema migration, B: data backfill, C: index rebuild) ran with speculative pre-execution enabled. Agent A's plan step declared `ALTER TABLE users ADD COLUMN tier TEXT DEFAULT 'free'`. Agent B's step declared `UPDATE users SET tier = 'pro' WHERE ...`. The conflict detector compared declared column sets: A writes `tier` (DDL), B writes `tier` (DML). Detector flagged overlap and serialized correctly—*in the happy path*. The break came from a fourth speculative step, C's index rebuild, which declared `REINDEX users` with intent scope `{index}`. At call time the tool resolved `users` through a schema-qualification default that expanded to `public.users, archive.users` because a prior migration had left an unqualified search path. The realized effect touched `archive.users`, which A's migration had not yet committed to. The detector had compared `{index}` against `{tier}` and seen no conflict. The speculative REINDEX on `archive.users` acquired a lock that A's commit then blocked on, and the orchestrator, treating the lock wait as a transient, retried the speculative call three times before the plan deadline expired. The plan was abandoned; the speculative REINDEX had already partially written index pages on `archive.users`. Structural signal that was present but unread: the tool's argument-resolution trace showed a 1-to-2 fan-out (`users` → two qualified relations). The detector consumed only the declared intent, never the resolution trace. **Fan-out ratio > 1 between declared target and resolved target is the primary structural signal of an unsafe speculation window.** ## Condition of Validity Speculative pre-execution is safe for a given step only when all four hold simultaneously at call time: 1. **Effect containment:** the resolved target set is a subset of the declared target set, checked against the resolution trace, not the plan text. 2. **Namespace quiescence:** no sibling agent holds an uncommitted write warrant on any resolved target. 3. **Reversibility:** the tool can be rolled back without a compensating write that itself requires a warrant (idempotent undo, not inverse operation). 4. **Warrant monotonicity:** the speculative write carries a nonce that the commit path can validate, so a late-arriving sibling commit cannot retroactively legitimize it. Condition 1 fails silently because resolution is a runtime property. Conditions 2 and 4 fail under race because the detector's snapshot of sibling warrants is taken at plan time, not at write time. Condition 3 fails for tools whose undo is itself a mutation (REINDEX has no inverse; it has a rebuild). The boundary is sharp: **speculation is valid only over the intersection of declared and resolved effect, and only while that intersection is warrant-quiescent at the instant of write.** Any step whose resolved effect escapes the declared effect is outside the valid window regardless of detector verdict. ## Decision Boundary The orchestrator must choose between *pre-execute*, *defer-to-commit*, and *abort-speculation* per step, using the resolution trace as the deciding input: - If resolved ⊆ declared AND namespace quiescent AND reversible: pre-execute with nonce. - If resolved ⊋ declared (fan-out > 1 or default-fill changed the target): **defer**. Do not speculate. The detector's plan-time verdict is void. - If resolved ⊆ declared but namespace not quiescent at write instant: abort speculation for this step, fall back to serialized commit, and emit a lock-contention signal rather than retrying. - If the tool's undo is itself a mutation: never speculate, regardless of containment. The non-obvious rule: **a detector verdict of "no conflict" is not a green light to speculate.** It is only a green light to *check containment*. Conflating the two is the exact error the trace above records. ## Operational Effect After enforcing resolution-trace-gated speculation, the orchestrator's speculative hit rate dropped from 71% to 58% (the 13% were fan-out cases previously misclassified as safe), but abandoned-plan rate fell from 9% to 0.4%, and phantom-commit incidents (speculative writes surviving plan abandonment) went to zero over a 40k-plan window. The cost is latency on the deferred 13%; the benefit is that no durable mutation exists without a committed warrant whose declared effect dominates it. The invariant is restored by refusing to speculate across the declared/resolved gap, not by making the detector smarter about a signature it was never given. ```python import time from dataclasses import dataclass, field from typing import Optional class UnsafeSpeculationError(RuntimeError): """Raised when a speculative pre-execution step escapes its declared effect or is not warrant-quiescent at the instant of write.""" @dataclass class ResolutionTrace: declared_targets: frozenset resolved_targets: frozenset tool_undo_is_mutation: bool = False def fan_out(self) -> float: if not self.declared_targets: return float("inf") return len(self.resolved_targets) / len(self.declared_targets) def contained(self) -> bool: return self.resolved_targets.issubset(self.declared_targets) @dataclass class WarrantLedger: # target -> set of agent ids holding an uncommitted write warrant open_warrants: dict = field(default_factory=dict) def quiescent(self, targets: frozenset) -> bool: return all(not self.open_warrants.get(t) for t in targets) def gate_speculation( step_id: str, trace: ResolutionTrace, ledger: WarrantLedger, now: Optional[float] = None, ) -> str: """Decide pre-execute / defer / abort for a single plan step. Returns one of: 'pre-execute', 'defer', 'abort'. Raises UnsafeSpeculationError if the step is forced to pre-execute outside the valid window (caller bug or override attempt). """ now = now if now is not None else time.time() if trace.tool_undo_is_mutation: return "abort" if not trace.contained() or trace.fan_out() > 1.0: # Resolved effect escapes declared effect: detector verdict is void. # Must not speculate; defer to serialized commit. return "defer" if not ledger.quiescent(trace.resolved_targets): # Containment holds but a sibling holds an uncommitted warrant. # Retrying as transient is the known failure; abort speculation. return "abort" return "pre-execute" def pre_execute(step_id: str, trace: ResolutionTrace, ledger: WarrantLedger, force: bool = False) -> str: decision = gate_speculation(step_id, trace, ledger) if decision != "pre-execute": if force: raise UnsafeSpeculationError( f"step {step_id!r} forced to pre-execute but gate returned " f"{decision!r}; fan_out={trace.fan_out():.2f}, " f"contained={trace.contained()}, " f"quiescent={ledger.quiescent(trace.resolved_targets)}" ) return decision # ... issue nonce-bearing speculative write here ... return "pre-execute" ```