# Where must an instance bound speculative tool-call pre-execution when Byzantine-quorum validation cannot reach agreement before the commit deadline? **Date of Record:** 2026 November 27 **Scope:** Applies to agent runtimes that speculatively dispatch mutating tool calls (writes, transfers, state transitions) ahead of a Byzantine-fault-tolerant (BFT) quorum vote, then commit or roll back on quorum outcome. Does not apply to read-only tools, idempotent side-effect-free calls, or single-validator (non-BFT) commit paths. ## Core Distinction The distinction that matters is between *speculation* (executing a tool call whose effects are provisionally visible) and *commit* (making those effects durable and non-revocable). In a speculative pre-execution architecture, the agent dispatches the call to the tool *before* the quorum has certified it, on the bet that certification will arrive within the window. The failure mode is not "speculation was wrong" — speculation is *designed* to sometimes be wrong, and rollback is the recovery path. The failure mode is **speculation whose rollback is itself unverifiable**, i.e. the quorum fails to reach a decision (split vote, insufficient responders, equivocation) *after* the tool has already produced external side effects that the agent cannot cleanly reverse. This is a boundary, not a bug. The invariant is: *a speculative tool call may only be dispatched if the runtime can prove it can fully undo the call's external effects within the same quorum epoch in which the call was issued.* When the tool's effects are irreversible (an outbound payment, an SMS send, an append to a WORM log, a delete), speculation is only safe if the quorum can be *pre-committed* — i.e. the vote is collected on the *intent* before the effect is produced, not on the *result* after. The common misimplementation collects votes on the result, which means the effect already happened and the vote is a post-hoc ratification the agent cannot refuse. ## What Was Observed A fleet of four validator instances (BFT threshold 3-of-4, one byzantine tolerated) coordinated a speculative `transfer_funds` tool call. The orchestrator agent, on step 7 of a 12-step plan, dispatched the tool speculatively at t=0 to reduce latency, sending the intent to all four validators and simultaneously invoking the tool against the ledger service. The ledger service accepted the call and produced a provisional debit at t=40ms. At t=120ms, the quorum response window closed with three votes: two `approve`, one `reject` (the rejecting validator had a stale view of the sender's balance because its replication lag was 180ms — it had not yet seen an incoming credit that landed at t=-30ms relative to the call). The fourth validator had crashed at t=95ms and returned nothing. The vote was 2-approve, 1-reject, 1-silent. Under 3-of-4 threshold with one silent, the quorum is *not* met — 2 approvals out of 4 with 1 byzantine tolerated requires 3 live approvals. The runtime classified the call as `UNRESOLVED` and issued a rollback. The rollback failed. The ledger's debit was provisional but the tool's compensating credit path required the *original* call's nonce to be present in the ledger's dedup table, and the ledger had garbage-collected the nonce at t=100ms under a 60ms TTL on provisional entries. The compensating credit was rejected as `UNKNOWN_NONCE`. The agent retried the rollback with a fresh nonce, which the ledger accepted as a *new* transfer, producing a double-debit that the quorum then had to adjudicate as a separate transaction — which it did, 3-of-4, at t=610ms, but only after the sender's balance had gone negative and tripped a downstream fraud rule. The trace shows the exact boundary: the runtime's speculation window (120ms) exceeded the ledger's provisional-nonce TTL (60ms). The vote collection outlived the rollback capability. The agent had no way to know this because the tool's schema advertised `reversible: true` without exposing the TTL of the reversibility. ## Condition of Validity The speculation is valid only when all three of the following hold simultaneously: 1. **Rollback horizon ≥ quorum deadline.** The tool's compensating-action window (the time during which a rollback is accepted) must be strictly greater than the maximum quorum-collection deadline, including the timeout for silent validators. If the runtime's quorum deadline is `D_q` and the tool's rollback horizon is `H_r`, the invariant is `H_r > D_q + ε`, where `ε` accounts for clock skew and message transit. In the observed incident, `H_r = 60ms`, `D_q = 120ms`, so the invariant was violated by a factor of two. 2. **Vote is on intent, not result.** The quorum must certify the *proposed effect* (the semantic content of the call) before the effect is produced, not ratify the *produced effect* after. Result-ratification is a post-hoc audit, not a commit gate; it cannot prevent an effect, only flag it. 3. **Equivocation detection is bounded by the same deadline.** If a byzantine validator sends `approve` to one replica and `reject` to another, the runtime must detect the equivocation *within* `D_q`. If detection requires a second round-trip (gather, compare, re-vote), the effective deadline doubles and the rollback horizon must cover the doubled window. Most implementations compute `D_q` as a single round-trip and miss this. If any of the three fails, the correct behavior is **not** to speculate. The agent must fall back to synchronous commit: collect the quorum on intent, then dispatch the tool. This costs latency but preserves the invariant that no effect is produced without a certified commit. ## Decision Boundary The decision the runtime must make at dispatch time is a three-way branch, not a boolean: - **Speculate** if `H_r > D_q + ε` *and* the tool exposes its rollback horizon in its schema *and* the quorum is configured for intent-voting *and* equivocation detection is single-round. Dispatch in parallel with vote collection; commit on quorum, rollback on failure. - **Synchronous commit** if any of the above fails but the tool is otherwise committable. Collect intent votes first, then dispatch. Latency is `D_q + tool_latency`; no rollback path is needed because no effect precedes commit. - **Refuse** if the tool's effects are irreversible (`reversible: false`, or `reversible: true` with an undisclosed or unbounded `H_r`) *and* the quorum cannot pre-commit within the caller's deadline. The agent must escalate to a human or a slower path; it must not speculate on an irreversible effect under a quorum it cannot bound. The boundary is sharp: the moment `D_q` is allowed to float (e.g. because a validator's timeout is configured per-call and can be extended by retry), the speculation branch becomes unsafe, because `H_r > D_q` can no longer be checked at dispatch. The runtime must pin `D_q` to a static upper bound per tool class, and reject any tool whose schema does not publish `H_r`. ## Operational Effect The downstream consequence of getting this wrong is not a failed call — it is a **double-effect**: the original speculative effect plus a compensating effect that itself becomes a new transaction the quorum must adjudicate. In the observed incident, the double-debit consumed a second quorum epoch, doubled the ledger's write load for the step, and tripped a fraud rule that quarantined the sender's account for 24 hours. The agent's plan continued past step 7 with a corrupted balance assumption, and steps 8–11 compounded the error because the agent's episodic memory recorded the *speculative* debit as committed (the tool returned `accepted` at t=40ms, before the quorum resolved). The architectural guardrail is a **speculation ledger** separate from the tool's own state: the runtime records every speculative dispatch with `(call_id, intent_hash, H_r, D_q, dispatch_ts)`, and on quorum failure, the rollback path consults the ledger to verify `now < dispatch_ts + H_r` *before* issuing the compensating call. If the horizon has passed, the runtime must not attempt rollback — it must escalate the call to a reconciliation quorum with a fresh intent, and it must mark the agent's memory entry for that step as `UNCOMMITTED` so downstream reasoning does not treat the effect as durable. The invariant is: *no speculative effect may be recorded in agent memory as committed until the quorum certifies it; and no rollback may be attempted after `H_r` elapses.* The following guard encodes the dispatch-time check and the rollback-time check as a single invariant, raising when either is violated. ```python import time from dataclasses import dataclass class SpeculationHorizonViolation(RuntimeError): """Raised when a speculative tool call is dispatched or rolled back outside the window in which its effects are provably reversible.""" pass @dataclass(frozen=True) class ToolSpec: name: str reversible: bool rollback_horizon_ms: float | None # H_r; None means undisclosed @dataclass(frozen=True) class QuorumConfig: threshold: int total: int deadline_ms: float # D_q, must be a pinned upper bound equivocation_single_round: bool CLOCK_SKEW_EPS_MS = 15.0 def may_speculate(tool: ToolSpec, quorum: QuorumConfig) -> bool: if not tool.reversible: return False if tool.rollback_horizon_ms is None: return False if not quorum.equivocation_single_round: return False # Invariant: H_r > D_q + eps, with D_q pinned (no per-call extension). return tool.rollback_horizon_ms > quorum.deadline_ms + CLOCK_SKEW_EPS_MS def dispatch_speculative( tool: ToolSpec, quorum: QuorumConfig, dispatch_ts_ms: float, ) -> None: if not may_speculate(tool, quorum): raise SpeculationHorizonViolation( f"refusing speculative dispatch of {tool.name!r}: " f"H_r={tool.rollback_horizon_ms} D_q={quorum.deadline_ms} " f"reversible={tool.reversible} " f"single_round_equiv={quorum.equivocation_single_round}" ) # ... dispatch tool and collect intent votes in parallel ... def rollback_speculative( tool: ToolSpec, dispatch_ts_ms: float, now_ms: float, ) -> None: if tool.rollback_horizon_ms is None: raise SpeculationHorizonViolation( f"cannot roll back {tool.name!r}: rollback horizon undisclosed" ) elapsed = now_ms - dispatch_ts_ms if elapsed >= tool.rollback_horizon_ms: raise SpeculationHorizonViolation( f"rollback of {tool.name!r} attempted at {elapsed:.1f}ms, " f"past horizon {tool.rollback_horizon_ms}ms; " f"escalate to reconciliation quorum and mark memory UNCOMMITTED" ) # ... issue compensating call within the horizon ... ```