# What structural signals indicate speculative tool pre-execution has crossed the commit horizon: the pre-execution/commit divergence boundary in probabilistic agent schedulers **Date of Record:** 2026 November 24 **Scope:** Applies to agents that speculatively invoke side-effecting tools (writes, payments, deploys, message sends) based on a probabilistic model of whether the tool will be needed, and that must later commit or abort the result. Does not apply to pure-read tools, idempotent cache fills with no external effect, or to speculative *reasoning* (drafting tokens) that never leaves the model boundary. ## Core Distinction There are two distinct things a speculative executor can be wrong about, and conflating them is the root of the failure mode. The first is **prediction error**: the model guessed the tool would be needed and it wasn't (or vice versa). The second is **commit-horizon error**: the tool's effect became externally observable *before* the agent's abort path could still undo it. Prediction error is cheap and recoverable; commit-horizon error is not, because at the moment of error the system has already crossed a boundary where "abort" is a fiction. The non-obvious invariant is this: **the safety of speculative pre-execution is bounded not by prediction accuracy but by the ratio of (time-to-commit) to (time-to-abort).** A speculative scheduler that models outcomes with 95% accuracy but whose abort path takes longer than its commit path will produce more real-world damage than a 70%-accurate scheduler whose abort window is guaranteed by construction. Structural signals of the commit horizon are therefore *timing and observability signals*, not probability signals. They appear in the trace as the moment a side effect acquires an external witness. ## What Was Observed A representative trace from a planner that speculatively fired `send_email` and `update_crm_record` in parallel while the reasoning loop was still deciding whether the user actually wanted a follow-up. The probabilistic model assigned P(needed) = 0.81 to the email and P(needed) = 0.74 to the CRM write, above a 0.70 speculation threshold. The failure unfolded in the following state sequence: 1. **Speculation launched.** Both tools entered `PENDING_SPECULATIVE`. The scheduler recorded an abort token and a predicted-undo cost of "cheap" for both. 2. **External witness acquired.** The email tool returned `202 Accepted` from the SMTP relay — the message was queued at the relay, not merely staged locally. The CRM write returned `200 OK` with a server-assigned `record_version`. Neither response was a local buffer; both were *external acknowledgements*. 3. **Prediction revised downward.** Two reasoning steps later, the planner observed the user's message contained "don't send anything yet, just draft it" — a phrase the initial classifier had missed. P(needed) collapsed to 0.12. 4. **Abort attempted.** The scheduler issued abort. The email abort path executed a "recall" call that the relay did not support — the 202 had already handed the message to an outbound queue with no recall API. The CRM abort executed a compensating delete, but the record had already been picked up by a downstream sync job within the abort latency window, producing a tombstone/re-create race. 5. **Divergence recorded.** The agent's internal state said `ABORTED`. The external world said `delivered` and `record_exists_with_new_version`. The two never reconciled. The structural signals that predicted this failure were present at step 2 and were *ignored* because the scheduler keyed its abortability decision on the *predicted* undo cost ("cheap") rather than the *observed* tool response class. The 202 and the server-assigned version were both external-witness signals: they marked the exact instant the commit horizon was crossed. ## Condition of Validity Speculative pre-execution with a safe abort is valid **only while the following holds for every in-flight speculative effect**: - The tool's response class is `STAGED` (locally buffered, no external acknowledgement), *or* - The tool exposes a verified compensating operation whose latency `L_abort` is provably less than the externalization latency `L_ext` of the effect, *and* - The scheduler has not yet received any response carrying an external witness (server-assigned ID, relay acknowledgement, queue depth increment, webhook emission). The condition is violated the instant any single in-flight effect transitions `STAGED → EXTERNALIZED`. At that point the abort set is no longer atomic: some effects can be undone and some cannot, and the scheduler must stop treating "abort" as a single operation over the speculation batch. The validity condition is *per-effect and monotonic* — once an effect externalizes, no later prediction revision can restore abortability. This monotonicity is the invariant that most speculative schedulers fail to encode: they model abortability as a function of current belief, when it is actually a function of irreversible past events. A second validity condition concerns *batch atomicity*. If the planner speculates a batch of N effects and any one externalizes, the remaining N−1 must be committed forward (to preserve the intended transaction) or individually compensated — but they cannot be silently discarded under a batch-level "abort" that no longer covers the externalized member. Batch-level abort after partial externalization is the single most common source of split-brain state between agent and environment. ## Decision Boundary The decision boundary is drawn at the first external-witness signal, not at a probability threshold. Operationally: - **Below the horizon (all effects STAGED):** abort is free and batch-atomic. Prediction error is fully recoverable. The scheduler may revise P(needed) arbitrarily and abort the whole batch. - **At the horizon (first effect EXTERNALIZED):** the scheduler must *freeze* the batch, promote every externalized effect to `COMMITTED_PENDING_RECONCILE`, and convert the abort into a *compensation plan* rather than a rollback. The remaining staged effects are decided by a forward-commit policy, not by the (now-stale) speculation model. - **Above the horizon (external witness + downstream consumption observed):** abort is impossible; only reconciliation is possible. The agent must record a divergence and surface it, because its internal belief and the external state have permanently separated. The boundary is *not* "P(needed) < 0.5". A high-confidence speculation that externalizes is more dangerous than a low-confidence one that stays staged, because the externalized one has already spent its abort budget. The correct gate is: *has any in-flight effect acquired an external witness?* If yes, the speculation model is no longer authorized to drive abort decisions. ## Operational Effect Encoding this boundary changes three things in the scheduler. First, every tool response is classified into `STAGED` vs `EXTERNALIZED` at the transport layer, and the classification — not the model's predicted undo cost — gates abortability. Second, the speculation batch acquires a monotonic `commit_horizon_crossed` flag that, once set, disables batch-abort and forces the compensation path. Third, the agent's state machine gains a `DIVERGED` terminal state that is reachable only from `COMMITTED_PENDING_RECONCILE` when compensation fails, and that state is surfaced to the orchestrator rather than silently swallowed. The practical consequence is that speculative pre-execution becomes safe to run at *lower* prediction thresholds, because the danger was never the false positive — it was the false positive that externalized before anyone noticed. Once the horizon is instrumented, the scheduler can speculate aggressively on `STAGED`-class tools (drafts, staged writes, dry-runs) and must speculate conservatively — or not at all — on tools whose first acknowledgement is an external witness. The invariant to carry forward: *abortability is a property of the past, not of the belief; it is destroyed by externalization and cannot be restored by any subsequent inference.* ```python import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List class CommitHorizonViolation(RuntimeError): """Raised when a batch abort is attempted after an effect externalized.""" pass class EffectClass(Enum): STAGED = "staged" # locally buffered, no external witness EXTERNALIZED = "externalized" # acknowledged by an external system @dataclass class SpeculativeEffect: name: str effect_class: EffectClass = EffectClass.STAGED external_witness_at: float | None = None compensated: bool = False @dataclass class SpeculationBatch: effects: Dict[str, SpeculativeEffect] = field(default_factory=dict) commit_horizon_crossed: bool = False def observe_response(self, name: str, response_class: EffectClass) -> None: eff = self.effects[name] eff.effect_class = response_class if response_class is EffectClass.EXTERNALIZED: eff.external_witness_at = time.monotonic() self.commit_horizon_crossed = True def abort(self) -> None: # The invariant: batch abort is only atomic while nothing externalized. if self.commit_horizon_crossed: externalized = [ e.name for e in self.effects.values() if e.effect_class is EffectClass.EXTERNALIZED and not e.compensated ] raise CommitHorizonViolation( "batch abort attempted after commit horizon crossed; " f"uncompensated externalized effects: {externalized}. " "Route through compensation plan, not rollback." ) for eff in self.effects.values(): eff.effect_class = EffectClass.STAGED # discard staged work def safe_abort(batch: SpeculationBatch, compensation_plan: Dict[str, bool]) -> List[str]: """Abort if below horizon; otherwise compensate externalized effects only.""" if not batch.commit_horizon_crossed: batch.abort() return [] uncompensated = [] for name, eff in batch.effects.items(): if eff.effect_class is EffectClass.EXTERNALIZED: if compensation_plan.get(name): eff.compensated = True else: uncompensated.append(name) if uncompensated: # Surface divergence rather than pretending the abort succeeded. raise CommitHorizonViolation( f"divergence: externalized effects without compensation: {uncompensated}" ) return [n for n, e in batch.effects.items() if e.compensated] ```