Skip to content

Latest commit

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

spex

Speculative Execution for Coding Agents

License Node Zero dependencies SWE-bench

how it worksdemoresultsreproducetry it

Coding agents run a serial loop: think, call a tool, wait for the output, think again. Spex breaks the loop. It predicts the agent's next tool calls from its trajectory, runs them in parallel before they are asked for, and serves cached results the instant the agent asks. Codex gets tool outputs before it knows it needs them.

how it works

  1. Predict. A zero-token transition table, mined with PrefixSpan from 2,146 real agent trajectories, ranks the most likely next tool call. No LLM speculator, no extra tokens burned.
  2. Resolve. The verifier resolver turns the prediction into an exact command from repository conventions.
  3. Speculate. Likely commands run in a shadow queue with a budget of 2 slots. If a speculation hits while still running, it is promoted to the main queue.
  4. Serve. The agent calls prefetch_verify and gets the cached output instantly. Served output is byte identical to the terminal, wrong guesses are never shown to the model, and every edit fences stale results.

demo

Spex Demo Video

results

Head to head against vanilla Codex on SWE-bench Verified: 42 instances across 7 repositories, 84 sealed runs.

Measure Spex Baseline Result
trace wall 2,338,733 ms 2,715,988 ms 13.9% less
verification calls 110 67 64% more with Spex
resolved 38/42 38/42 identical
  • Lossless speedup. 13.9% less wall time at identical resolution. Spex removes the wait without changing what the agent solves.
  • 80% of verification served instantly. 88 of 110 calls answered from speculation, hiding 44,592 ms of verifier time.
  • Verification becomes free, so the agent checks more. 64% more verification calls, and it still finishes faster.
  • It scales with your pain. Savings track suite cost, up to 6.6 seconds hidden per call, projecting to minutes on real multi-minute CI suites.
  • Every number is reproducible. An analyzer recomputes every claim from the committed traces. No live benchmark or model access required.

Full report with methodology and disclosures: speculator/evals/harder-sealed-report.md.

Moat. Prior speculative-agent work uses an LLM speculator that burns tokens and caps latency gains around 50%. Spex uses a zero-token table on the highest-value vertical, coding verification, and is the only one proven lossless on real bugs. It is not a faster model. It is the same model with the waiting removed.

Spex timeline: verification overlaps thinking

reproduce

From the repo root:

cd speculator && env -u NODE_OPTIONS node --test                unit tests (56)
env -u NODE_OPTIONS python3 mining/eval.py                      offline recall, held out trajectories
env -u NODE_OPTIONS python3 mining/eval_spike.py                recall on out of distribution codex sessions
env -u NODE_OPTIONS node speculator/scripts/bench.mjs 1 --swebench   live a/b on swe bench verified

Requires Node 20+, python3, and for the live benchmark the codex CLI authenticated with access to the pinned model. Raw evidence from the reported runs is committed: one row per run in speculator/bench-results.jsonl, one event trace per run in speculator/bench-runs/.

try it

The ready-made demo instance is pytest-dev__pytest-6197, a real SWE-bench bug with a small localized fix and a fast verifier, so the tool fires a few times and it resolves quickly.

  1. Generate the demo repository offline from the clone cache:
cd speculator && bash scripts/swebench-repo.sh pytest-dev__pytest-6197 /tmp/spex-demo
  1. Run the CLI on it:
node src/cli.mjs /tmp/spex-demo
  1. Give it exactly this task and nothing more, so the model routes verification through the tool:
Fix the failing tests in this repo and verify your fix.

Watch for the model to read the seeded AGENTS.md and call prefetch_verify. The CLI shows a cache-hit line as the pre-run verification is served during the model's own thinking. That is the tool firing.

For the vanilla baseline, generate with --baseline for no AGENTS.md and no tool, then run plain codex in the repository.

installation and testing for judges

Supported platforms: macOS with Node 20 or later. Python 3 is needed for the mining evaluation. An authenticated Codex CLI with access to the pinned model is needed only for the live tool and live benchmark.

git clone https://github.com/cchang3906/spex.git
cd spex/speculator

Spex has zero runtime npm dependencies. That is the complete installation.

To test the tool live, run one of these and give it a task:

node src/cli.mjs /path/to/repo
SPEX_BASELINE=1 node src/cli.mjs /path/to/repo

To verify the published claims without rerunning the benchmark:

node --test
node scripts/analyze-harder-bench.mjs

The analyzer recomputes every published number from the committed traces in speculator/bench-runs/harder-sealed-r1/. No credentials are required to read this repository or run the offline verification.

About

馃敭 Speculative tool execution: predicts and pre-runs verification while the model works, then serves results on demand.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages