A minimal, readable implementation of an auto-research loop: an agent proposes an experiment, runs it, evaluates the result against fixed criteria, and keeps it only if it beat the incumbent — all under a compute budget, with gates a human can tune from manual to automatic.
It trains a small language model from scratch on TinyStories and judges the output on two criteria: coherence, and rhyme in the style of Dr. Seuss. The second one is deliberately arbitrary. Real research criteria usually are.
The substrate is small on purpose. A run finishes in minutes on a single 12 GB consumer GPU, and the training script is short enough to read in one sitting — so the interesting part is the loop around it, not the model.
Most autoresearch demos show an agent generating ideas. Generating ideas was never the hard part. Deciding what to keep is the hard part, and that is a gate, not a model. This repo is about the gates, the ledger they read from, and the criteria they apply.
propose → run → evaluate → keep (within a fixed budget)
Twice: once over pretraining recipes, once over post-training. Same shape, same gates, same ledger; only the artifact under test changes.
Four gates sit on the transitions:
| Gate | Fires | Rule |
|---|---|---|
| G1 | before proposing | Budget remains, and this config hash is not already in the ledger |
| G2 | before running | Auto-approve under a GPU-hour threshold, escalate above |
| G3 | before promoting | Beats the incumbent on loss and clears the criteria floor |
| G4 | in production | No regression on live signals |
Requires uv.
uv sync
uv run pytestRunning the loop needs a Weights & Biases account:
export WANDB_API_KEY=... # or: uv run wandb login
uv run autoresearch --help| Path | Holds |
|---|---|
src/autoresearch/ |
the harness: gates, ledger, criteria, training entry point |
tests/ |
gate predicates and ledger behaviour |
CONTEXT.md |
the glossary — read this before the code |
docs/adr/ |
why it is built this way |
Authoritative state lives in the systems of record you already run — git history, pull requests, and W&B runs — never in agent memory or a scratchpad. A worker can die mid-experiment and lose nothing: it restarts, re-reads the ledger, and continues. That one choice is what makes the loop survivable over days rather than hours, and it is why the gates can be pure functions over state a human can also open and read.
See docs/adr/ for the decisions, and CONTEXT.md for the
vocabulary the code uses.
wandb/senpai (Apache-2.0) runs this architecture at
real scale — thousands of agent-authored pull requests and over eleven thousand tracked
runs across CFD, speech recognition and inference optimization. This repo is the smallest
thing that shows the same shape.
Conventional Commits, explicit file staging, one logical change per pull request. Behaviour changes ship with tests; the gate predicates are pure functions over ledger state and are tested directly.
MIT. See LICENSE.