Speculative AI Agents Need a Commit Boundary
An AI agent may speculate about the future. It must not speculate with the outside world.
That boundary matters because latency optimization is moving from faster models to overlapping work. If an upstream model call will probably produce approved, the runtime can begin preparing the likely downstream branch before the answer arrives. It can retrieve documents, compile a request, validate a schema, warm a sandbox, or draft a patch. When the prediction is right, useful work is already complete.
But “start the next step early” is dangerously imprecise. Sending an email, merging code, charging a card, changing permissions, or writing to a shared record is not a draft. A wrong prediction cannot be repaired by discarding tokens. It has already become history.
I treat speculative execution as a transaction with a hard commit boundary. Before that boundary, work is disposable. After it, effects require authoritative inputs, current authorization, and an exact artifact identity.
The wrong abstraction: speculative tasks
A scheduler that marks an entire task as speculative hides the important question: which parts of the task can be abandoned?
Consider a likely branch:
customer request
-> classify intent
-> prepare account change
-> notify customer
The runtime might safely predict the classification and prepare a candidate change set. It must not apply the change or send the notification merely because the branch looks likely.
The useful unit is therefore not a speculative task. It is a speculative segment ending at an effect frontier:
predict -> compute -> validate -> stage || COMMIT || apply -> receipt
Everything left of COMMIT must satisfy at least one of three conditions:
- it is side-effect-free;
- it is idempotent under a stable effect identity;
- it writes only to isolated staging that cannot become externally visible without a separate commit.
This is stricter than “the operation is reversible.” Compensation is a new effect, not time travel. A follow-up email does not unsend the first one. A restoring database write does not erase the period during which the wrong state was visible. Reversibility is valuable for recovery, but it is not permission to speculate past the boundary.
A speculation envelope
I would make each speculative branch an explicit runtime artifact rather than a hidden scheduler optimization:
{
"speculationId": "sp_7f2c",
"baseRevision": "case:184@r31",
"predictedInputHash": "sha256:...",
"branch": "approve_change",
"expiresAt": "2026-07-27T07:30:08Z",
"allowedStages": [
"retrieve_policy",
"compile_change_set",
"validate_candidate"
],
"forbiddenEffects": [
"write_account",
"send_notification"
],
"candidateArtifactHash": "sha256:..."
}
The envelope does four jobs.
It binds speculation to a base revision. If the account, repository, policy, or tool surface changes while the branch is running, the prepared result is stale even when the model predicted the right label.
It names the prediction. The runtime can compare the authoritative upstream result with a canonical predicted-input hash instead of trusting fuzzy semantic similarity.
It declares the effect frontier. A tool is not safe merely because it appears in an early stage. The envelope lists which stages may run and which effects remain forbidden.
It gives the branch a lifetime. Speculative artifacts should expire quickly. An old prepared action is not free acceleration; it is hidden state waiting to escape.
This extends the same principle I use for capability snapshots: plans and prepared work are valid only against the environment they observed.
Commit is a fresh decision
A correct prediction is necessary, but not sufficient, for commit.
At the boundary, the runtime should re-evaluate five facts:
| Check | Question |
|---|---|
| branch match | Did the authoritative result select this exact branch? |
| revision match | Is the target still at the recorded base revision? |
| artifact identity | Is this the same candidate that passed validation? |
| authorization | Is the concrete effect allowed under the current policy epoch? |
| freshness | Has the speculation envelope expired? |
Only then can the runtime turn staged work into an effect. The commit should emit a compact receipt:
{
"speculationId": "sp_7f2c",
"authoritativeInputHash": "sha256:...",
"candidateArtifactHash": "sha256:...",
"policyEpoch": 42,
"effectId": "account-change:184:r31:r32",
"resultRevision": "case:184@r32",
"committedAt": "2026-07-27T07:30:06Z"
}
This receipt connects prediction, validation, authorization, and the resulting state. It also prevents the latency optimization from bypassing the pre-execution authorization boundary. Authorization still happens over the concrete invocation. Speculation only prepares evidence and artifacts for that decision.
Cancellation is not rollback
Many implementations rely on cancellation: launch several likely branches, keep the winner, cancel the rest. That works only while losing branches remain on the disposable side of the frontier.
Cancellation is a request, not proof that no effect occurred. A worker may finish just before receiving it. A network call may succeed while its response is lost. Official Temporal documentation describes the related activity problem: an activity can execute and then be retried after a worker failure, which is why idempotency remains necessary.
A safe runtime therefore records each losing branch as one of:
DISCARDED— no external effect was possible;CANCEL_REQUESTED— cancellation was sent, completion is unresolved;STAGED— isolated artifacts exist and await deletion or expiry;EFFECT_UNKNOWN— an effect may have escaped and needs reconciliation.
EFFECT_UNKNOWN is uncomfortable, but honest. I would rather route an ambiguous branch into reconciliation than let an optimizer silently retry it. This is the same reason stable effect identity matters: attempts may multiply, while the intended mutation remains one named operation.
Where speculation actually pays
The best speculative targets are not the most consequential actions. They are expensive, repeatable preparations with cheap validation:
- retrieval and reranking against a pinned corpus revision;
- schema compilation and static checks;
- sandbox creation;
- read-only queries against a snapshot;
- patch generation without merge;
- provider request construction without dispatch;
- test execution in an isolated workspace.
The worst targets are externally visible, authority-changing, scarce, or irreversible: payments, messages, permission changes, production deploys, destructive writes, and physical control.
Recent research explores both cost-aware speculative agent workflows and certified prefix acceptance for constrained sequential decisions. The useful architectural convergence is the same: proposal and guarantee need different owners. I would carry that rule into general agent runtimes without borrowing claims that only hold in a paper’s evaluated control domains.
There is also a practical limit. Speculation consumes tokens, compute, connections, and attention. The runtime needs an admission budget and should disable a branch when prediction quality drifts or cancellation waste exceeds its latency value. This article does not claim a universal speedup; that requires workload-specific measurement. The mechanism is valuable because it makes such measurement safe: wasted drafts remain drafts.
The engineering rule
Speculation should move computation earlier, never authority.
A fast agent runtime may predict, retrieve, compile, validate, and stage. It may prepare several futures at once. But only the authoritative branch may cross the effect frontier, and it crosses with a fresh policy decision bound to an exact artifact.
That is the difference between optimistic computation and optimistic side effects. The first can reduce latency. The second turns a performance experiment into an incident generator.