Build an autonomous research agent
Build a research loop that generates hypotheses, searches literature, runs sandboxed experiments, judges results with paired tests, schedules branches with UCB, critiques drafts and writes a LaTeX paper.
Build it step by step
- 1Hypothesis GeneratorPhase 19: Capstone projects
- 2Literature RetrievalPhase 19: Capstone projects
- 3Experiment RunnerPhase 19: Capstone projects
- 4Result EvaluatorPhase 19: Capstone projects
- 5Paper WriterPhase 19: Capstone projects
- 6Critic LoopPhase 19: Capstone projects
- 7Iteration SchedulerPhase 19: Capstone projects
- 8End-to-End Research DemoPhase 19: Capstone projects
What You'll Build
A deterministic auto-research loop made of eight contract-first components: a hypothesis generator with a temperature ramp and novelty filter, a BM25 plus citation-graph literature retriever, a subprocess experiment runner, a statistical result evaluator, a skeleton-first paper writer, a structured critic loop, an asyncio UCB scheduler, and an end-to-end orchestrator that composes them. Unlike the lesson 57 demo, which stubs the first four stages, your end-to-end run uses your real generator, retriever, runner and evaluator on an experiment and a paper corpus you chose.
Requirements
- Hypothesis generator. A sampler (mock LLM by default) called over a temperature ramp (default six passes from 0.2 to 1.2), parsed into typed
Hypothesisrecords (variables,metric,baseline_ref), filtered by a hashed bag-of-words cosine novelty threshold (default 0.25) and ranked by0.4 * novelty + 0.3 * specificity + 0.3 * testability. Same seed, same queue. - Literature retrieval. A corpus of at least 30 paper records on a topic you pick (real titles and abstracts you collected, or carefully written mock ones), BM25 from scratch (k1 1.5, b 0.75), BFS over the citation graph capped at 2 hops, dedup by id and the blended
final_scorewith per-paper score fields. - Experiment runner. An
ExperimentSpecexecuted in a subprocess with a hard wall-clock timeout and a polled RSS memory cap, terminal statesok,timeout,oom,crash, the last JSON stdout line taken as metrics, one-knob ablations and a seed forwarded to the script. Write your own experiment script that does real numeric work (for example a numpy model whose accuracy or loss depends on a config knob) and show each terminal state at least once. - Result evaluator. Direction-aware improvement, optional log scaling, a 2 percent threshold, a paired t-test written by hand (incomplete beta via continued fraction), seed pairing with
PairingError, and the five-row verdict table (failed, noise, noise, improved, regressed). Test your t-test against one known reference value and say where it came from. - Paper writer. A
Paperskeleton with sections, figures and bib entries, the four validation gates, figures injected from experiment manifests, and an all-or-nothing write ofpaper.tex,references.bibandmanifest.json. - Critic loop. Scores on five dimensions (clarity, novelty, evidence, methodology, related work), structured suggestions applied by a reviser, and termination by target (every dimension at least 8.0), plateau (mean gain below 0.1 for two rounds) or budget (5 rounds), with a per-round trace.
- Scheduler. UCB1 with c = sqrt(2) and untried branches first, three asyncio slots, pruning below 0.2 mean reward after 3 runs, paper triggers at 0.7, an expander for follow-up hypotheses, and
max_experimentsandmax_secondsbudgets with astop_reason. - End-to-end.
python main.pyseeds the queue from your generator, filters with your retriever, runs your experiment through your runner, turns evaluator verdicts into scheduler rewards, picks the best branch, runs the critic loop and writes the paper. It emits one report, is deterministic (two runs give an identical manifest), and raises typed errors (NoTriggerError,PaperValidationError) instead of continuing on a broken input.
Constraints
- Python standard library plus numpy; CPU only; the whole loop should finish in under a few minutes.
- Mock LLM by default so the run is reproducible. A real model is optional through any OpenAI-compatible endpoint (the KatalockAi API, or a local model); if you use one, keep a
--mockflag that the graded run uses. - Compiling the LaTeX with
pdflatexis optional; the.tex,.biband manifest are what get graded. - The subprocess runner is not a security sandbox. Only run experiment scripts you wrote.
Stretch Goals
- Persist UCB statistics and stage outputs to JSON so a restarted loop resumes without rerunning cheap stages.
- Swap the deterministic critic for a model-based critic that returns the same
Critiqueshape. - Render the scheduler and critic traces as one timeline plot.
How to Submit
Public repo with research/ (generator, retrieval, runner, evaluator, writer, critic, scheduler), experiments/ (your script), corpus/ (your paper records), main.py, tests/ and results/ (demo report JSON, ablation table, paper output). The README must explain how to run the loop, what topic and experiment you chose and why, how an evaluator verdict becomes a scheduler reward, how determinism is guaranteed, and one case where a verdict was noise or failed and what that told you.
How It's Reviewed
Professor Katalock reads your repository and the evidence you paste, and scores each criterion out of 100. You pass with a weighted total of 70 or more and no criterion below 40. A copied or padded submission is flagged and fails.
Submit
Push your work to a public GitHub repository with a README that explains how to run it, then paste the evidence below. Up to 3 reviews a day, free.
- Full output of `python main.py`, including the scheduler stop_reason and the critic trace
- Output of running the demo twice plus a diff (or hash comparison) of the two manifests
- The ablation table and the verdict JSON for at least one hypothesis
- The first 40 lines of the generated paper.tex
- Output of `python -m pytest -q`
- A short reflection on one verdict that was noise or failed
Reviews are done by AI against the rubric above. They check the evidence in your repository; they are not a substitute for a human code review, and a review can be wrong. If you think it is, improve the README so the evidence is unmistakable and resubmit.