NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

CodeScientist: End-to-End Semi-Automated Scientific Discovery with Code-based Experimentation

Peter Jansen, Oyvind Tafjord, Marissa Radensky, Pao Siangliulue, Tom Hope, Bhavana Dalvi Mishra, Bodhisattwa Prasad Majumder, Daniel S. Weld, Peter Clark

Introduction

The field of Automated Scientific Discovery (ASD) has seen significant progress with the advent of large language models (LLMs). Systems such as The AI Scientist have demonstrated the potential to automate the research cycle; however, current approaches often suffer from two primary limitations: a "narrow search space" and a "faithfulness gap." Most systems are confined to optimizing hyperparameters or making incremental edits to existing codebases, struggling to propose entirely new research directions. Furthermore, while these systems can generate convincing LaTeX papers, the underlying code is frequently broken or the results are non-replicable artifacts of LLM variability.

CodeScientist is designed to overcome these hurdles by broadening the scope of discovery and introducing a "trust-but-verify" workflow. By grounding ideation in a library of vetted code snippets and subjecting results to rigorous meta-analysis and code audits, CodeScientist ensures that automated discoveries are both scientifically sound and practically implementable.

Methodology: The Five-Stage Discovery Workflow

CodeScientist operates through a structured, five-stage pipeline designed to bridge the gap between abstract ideation and concrete experimentation.

The system treats research papers and "codeblocks"—vetted snippets for specific tasks like LLM calls or statistical tests—as genetic material. It employs "crossover" (combining insights from disparate papers) and "mutation" (challenging existing assumptions) to generate a diverse pool of candidate ideas. This approach ensures that proposed ideas are not only novel but also grounded in available technical capabilities.

2. Planning and Human-in-the-Loop Filtering

High-level ideas are translated into detailed experimental plans. To maintain quality, CodeScientist incorporates a human-in-the-loop step where domain experts filter the most promising ideas and provide brief "nudges" or comments to guide the subsequent execution.

3. Experiment Construction and Execution

The system utilizes an iterative "generate-execute-reflect" loop. Experiments are conducted within an instrumented sandbox. If the generated Python code fails, the agent analyzes error logs and attempts to self-debug, mimicking the iterative process of a human researcher.

4. Reporting

Successfully executed experiments are compiled into comprehensive LaTeX papers and executive summaries, facilitating human review and dissemination.

5. Meta-Analysis and Verification

To mitigate the risk of "hallucinated" results or fluke successes, CodeScientist runs each experiment multiple times ($N=5$). A meta-analysis is then performed to verify the consistency of results across different implementations, ensuring the robustness of the discovery.

Experimental Evaluation

The authors evaluated CodeScientist within the domain of autonomous agents and virtual environments. The system utilized a knowledge base of 57 recent research papers and a library of 10 vetted codeblocks (e.g., ReAct agent templates, TextWorldExpress API calls). Experiments were conducted across several benchmarks, including CookingWorld, ScienceWorld, and DiscoveryWorld.

Key Results

The system's performance was evaluated across 250 experiment attempts derived from 50 distinct ideas.

  • Validated Discoveries: Out of 19 "interesting" candidates, 6 discoveries passed a multi-faceted human evaluation for scientific soundness and incremental novelty.
  • Success Rate: Approximately 12% of the initial ideas resulted in a validated discovery.
  • Efficiency: The average cost per experiment was remarkably low at ~$4.23 in API fees, with a completion time of approximately 2 hours.
  • The "Veto" Effect: A critical finding was the necessity of code-level verification. While external reviewers originally accepted 13 discoveries based on paper rubrics, internal code audits and replication attempts "vetoed" 7 of these due to underlying technical flaws or hallucinations.

Discussion and Limitations

Despite its successes, CodeScientist faces several challenges. A significant "debugging ceiling" exists, with 59% of experiments failing during implementation due to complex code errors the agent could not resolve. Additionally, the system occasionally produces "mechanical variations" (e.g., applying an existing method to a new benchmark) rather than transformative shifts in the field.

Future work will focus on developing automated code reviewers to reduce the human labor required for audits and scaling computational budgets to allow for larger sample sizes. By refining the "trust-but-verify" mechanism, CodeScientist moves the field of ASD closer to producing reliable, autonomous scientific contributions.

Summary updated

BibTeX
@inproceedings{jansen2025codescientist,
  author = {Peter Jansen and Oyvind Tafjord and Marissa Radensky and Pao Siangliulue and Tom Hope and Bhavana Dalvi Mishra and Bodhisattwa Prasad Majumder and Daniel S. Weld and Peter Clark},
  title = {{CodeScientist: End-to-End Semi-Automated Scientific Discovery with Code-based Experimentation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure