Experiment-as-Code Labs: A Declarative Stack for AI-Driven Scientific Discovery

Zhenning Yang, Yuhan Chen, Patrick Tser Jern Kon, Tongyuan Miao, Hongyi Lin, Venkat Viswanathan, Danai Koutra, Ang ChenarXiv 2026

TL;DR

AI agents have conquered digital reasoning, but they remain "trapped" by the messy, manual reality of physical laboratories. This paper proposes Experiment-as-Code (EaC), a declarative software stack that treats lab hardware like cloud infrastructure, allowing AI to safely and efficiently orchestrate real-world scientific experiments through standardized, portable code.

What Problem Does This Paper Address?

We are currently facing a "last mile problem" in AI-driven discovery. While models like AlphaFold can predict protein structures with incredible accuracy, the actual validation of these hypotheses still requires human scientists to manually operate heterogeneous, temperamental lab equipment.

Current autonomous labs are often siloed, relying on "brittle" imperative scripts or vendor-specific GUIs. This creates three major hurdles:

  1. Non-Portability: A script written for one lab rarely works in another due to differences in instrument APIs and implicit setup assumptions.
  2. Safety Risks: Physical labs involve irreversible actions (consuming expensive reagents) and hazards (hot surfaces, toxic aerosols) that digital-only AI agents aren't equipped to handle.
  3. Inefficiency: Without a centralized system to manage resources, labs suffer from "dead time" due to instrument warm-ups, calibration drifts, and redundant procedures.

Methods

The authors introduce the Declarative Experiment Stack, inspired by the "Infrastructure-as-Code" (IaC) movement that revolutionized cloud computing (e.g., Terraform).

The EaC stack bridges the gap between AI reasoning and physical execution.

The stack is divided into three functional layers:

  • Specification Layer: Experiments are defined as declarative configurations (like JSON or YAML). Instead of telling a robot how to move, the agent specifies what the desired outcome is (e.g., "dispense 0.7ml at 4ml/s").
  • Execution Layer: This acts as the "safety officer." It maintains a centralized Lab State (tracking which pumps are in use, current temperatures, and calibration status) and performs runtime checks to prevent hazardous actions.
  • Orchestration Layer: It compiles experiment intents into Directed Acyclic Graphs (DAGs). It optimizes throughput by batching similar tasks to minimize reconfiguration overheads, such as instrument warm-up times.
The EaC framework workflow from scientist/AI intent to physical execution.

Datasets

The paper does not use a traditional machine learning training dataset. Instead, it evaluates the EaC paradigm through a real-world case study at the University of Michigan’s Clio battery laboratory. The authors ran an end-to-end experiment measuring the ionic conductivity of aqueous $Li_2SO_4$ electrolytes across six different concentrations. The resulting data was validated against established benchmarks from the literature (Dissanayake and Careem, 1988).

Key Insights and Ideas

  • The Cloud Analogy: The authors argue that autonomous labs today look like cloud platforms did a decade ago—a mess of manual consoles and custom APIs. EaC is the "Terraform for Science."
  • State-Awareness is Critical: Unlike a computer, a lab instrument has "physical state" (e.g., a heater that stays hot for 20 minutes after use). EaC explicitly models these cooldown and stabilization periods in its Lab State.
  • Standardization via Abstraction: By using a "shim" layer to map vendor-specific commands to a unified EaC schema, the system makes experiments portable. An AI agent can learn one "language" to control labs globally.
Key benefits of the EaC approach, including reliability, safety, and scalability.

Key Results

The authors successfully rearchitected the Clio battery lab from a script-driven platform to an EaC-enabled one.

  • Flexibility: In the original setup, every experiment was forced to run density and viscosity measurements because they were hard-coded into the script. With EaC, the agent could selectively skip these, reducing execution time and material consumption.
  • Reliability: The system successfully coordinated a pump, a multi-port valve, and a potentiostat, ensuring that measurement reads never occurred before fluid dispensing was complete.
  • Accuracy: The EaC-orchestrated measurements correctly identified 2.15 mol/kg as the peak conductivity configuration, matching prior scientific studies.
Comparison of interface models between Cloud Computing and Autonomous Laboratories.

Limitations and Future Work

  • The "Shim" Burden: While EaC simplifies experiment design, someone still has to write the initial device wrappers (shims) for every new piece of hardware.
  • Agent Integration: The paper focuses on the stack, but the next challenge is building AI agents that can truly reason over these new physical and operational constraints.
  • Vendor Cooperation: The vision relies on instrument vendors moving away from closed, proprietary software toward standardized, programmable interfaces.
  • Complex Failures: While the system handles explicit errors (like a disconnected cable), detecting "implicit failures" (like a sensor that is slightly out of calibration but still reporting data) remains a difficult open research question.

Summary updated

BibTeX
@misc{yang2026experiment,
  author = {Zhenning Yang and Yuhan Chen and Patrick Tser Jern Kon and Tongyuan Miao and Hongyi Lin and Venkat Viswanathan and Danai Koutra and Ang Chen},
  title = {{Experiment-as-Code Labs: A Declarative Stack for AI-Driven Scientific Discovery}},
  year = {2026},
  eprint = {2605.04375},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.04375},
}
Figure