Compare agent approaches
Run candidates on separate branches and use a check to select a result.
What this example covers
Section titled “What this example covers”Use this example to try several fixes for the same bug. Each candidate works in its own sandbox and branch; your test command decides which result can be accepted.
- Competing candidatesRace up to eight candidates and keep the first acceptable one.
- Choose an agentCompose Codex and Claude Code from their harness presets.
- Claude CodeSign in on the host; the Setup image already contains its CLI.
- Sandbox sessionsRun the tests in the candidate’s open sandbox.
- BudgetsOne budget bounds the attempts and tokens of every candidate.
- Repository and branchEach candidate commits on a named branch in its own worktree.
Write the script
Section titled “Write the script”Save the files shown in the tabs next to the outpost.config.ts from Installation. Run compete.ts to compare the candidates.
Prepare the candidates and verify their work before considering a merge.
Ask for confirmation in compete.ts, then check integration again before merging.
Run the script
Section titled “Run the script”It prints each candidate’s status and branch, for example claude winner outpost/speculation/<id>/claude and codex cancelled …, then asks before merging. Review the branch with git diff before you answer.
Understand the steps
Section titled “Understand the steps”API reference: SpeculationResult, SpeculativeCandidateResult and SpeculationIntegration.
Adapt the example
Section titled “Adapt the example”Try one agent with several approaches
Section titled “Try one agent with several approaches”Give the same agent different briefs. With three candidates and concurrency: 2, the third starts only when one of the first two finishes without winning.
Let a review agent decide
Section titled “Let a review agent decide”A reviewer dispatched in the candidate’s sandbox reads its commits and returns a typed verdict. Pass the function as validate: review.
The review’s tokens do not count in budget. The winner’s commit is read after validate, so the reviewer must not commit.
Resume after a crash
Section titled “Resume after a crash”Pass durability to speculate(): attempts, usage and outputs are saved through a transport, and a completed race is returned without running again.
version is part of the race identity: after changing the candidates or validate, start a new race under a new runId. Durable races need a provider with recovery, today mounted Docker or Podman, and keep every candidate’s worktree. After a crash, recover the race before replaying it: Competing candidates.
Limits
Section titled “Limits”speculate()does not merge, push or open a pull request.- A
cleanintegration is not a lock: any later change to the checkout makes it stale, so check again right before merging. - Running candidates can exceed the token limit before their usage is reported.
- A worktree with uncommitted, untracked or ignored files, such as
node_modules, stays under.outpost/workspaces: see Retention and cleanup.
API: speculate · SpeculationResult · SpeculativeCandidateResult · checkSpeculationIntegration · SpeculativeValidation · SpeculationDurability.