| title | LabAgent: An Open-Source AI-Guided Framework for Automated Scientific Measurements | |||||||
|---|---|---|---|---|---|---|---|---|
| tags |
|
|||||||
| authors |
|
|||||||
| affiliations |
|
|||||||
| date | 13 April 2026 | |||||||
| bibliography | paper.bib |
LabAgent is an open-source Python framework that connects large language models (LLMs) to laboratory instruments for automated scientific measurements. The framework provides AI-guided measurement planning, instrument discovery and classification, safety boundary validation, data analysis with domain-specific interpretation, and experiment memory — covering 46 measurement types across 9 scientific disciplines and ~50 instrument models across 15+ manufacturers.
High-precision laboratory measurements in physics, chemistry, biology, and materials science require complex instrument orchestration, parameter optimization, and data analysis. Researchers currently face a choice between expensive proprietary software (e.g., LabVIEW) or writing custom measurement scripts from scratch for each experiment. Both approaches are time-consuming, error-prone, and lack safety guarantees.
While instrument control libraries such as PyVISA [@pyvisa] and PyMeasure [@pymeasure] provide foundational drivers, and measurement suites like PICA [@pica] offer hardcoded GUIs for specific instruments, no existing tool combines AI reasoning with instrument control in a unified, extensible framework.
LabAgent addresses this gap by placing AI at every step of the measurement workflow: from literature-informed protocol discovery to adaptive measurement planning with three-tier safety validation, to AI-generated data analysis with domain-specific scientific interpretation.
The framework follows an agent harness architecture inspired by OpenHarness [@openharness], with four core subsystems:
-
Tool Registry: Eight standardized tools (scan, classify, propose, validate, literature search, analyze, memory recall, healthcheck), each following a
BaseToolabstract interface with Pydantic input validation. -
Agent Engine: An asynchronous query loop that processes user messages, invokes LLMs via litellm [@litellm] for model-agnostic routing, detects tool calls, executes them with permission checks, and streams results back to the user.
-
Permission System: A three-layer safety model with immutable absolute limits (e.g., maximum current 10 A), boundary checks loaded from YAML policies, and interactive user confirmation for potentially dangerous operations.
-
Multiple Interfaces: A Model Context Protocol (MCP) server for AI IDE integration, a command-line interface with 11 subcommands, a FastAPI web GUI with adaptive measurement forms, and a Textual-based terminal panel for interactive sessions.
The framework includes 46 YAML-based measurement templates spanning:
- Electrical characterization: IV curves, R-T, delta mode, high resistance, FET transfer/output, breakdown voltage
- Electrochemistry: Cyclic voltammetry, EIS, chronoamperometry, potentiometry
- Semiconductor: Solar cell IV, DLTS, photocurrent spectroscopy, C-f analysis, tunneling spectroscopy
- Optics and photonics: Optical power measurement, UV-Vis absorbance, photoresponse transients
- Biological / analytical: Plate-reader absorbance / fluorescence / luminescence, biosensor impedance, mass weighing, pH and ISE readout
- Environmental and sensor: Gas sensor, humidity response, strain gauge, fatigue, mass flow, pressure control
- Thermoelectric: Seebeck coefficient, thermal conductivity
- Magnetic and transport (condensed-matter specialty): Hall effect, magnetoresistance, anomalous Hall effect, FMR, hysteresis loops, magnetostriction, Nernst effect, SOT loop shift
- Superconductivity: Tc transition, critical current density
- Dielectric / ferroelectric: P-E loop, pyroelectric current
- Quantum Design systems: PPMS R-T / MR / Hall / heat capacity, MPMS M-H / M-T with MultiPyVu integration
The framework provides eight distinct AI capabilities:
- Instrument Classification: Dictionary-based lookup with LLM fallback for unknown instruments
- Parameter Optimization: LLM suggests optimal sweep ranges based on sample description and literature
- Safety Advisory: LLM explains why limits exist and suggests safer alternatives
- Script Generation: LLM creates custom analysis scripts for arbitrary measurement types
- Result Interpretation: LLM provides domain-specific scientific insights on extracted values (physics, electrochemistry, spectroscopy, etc.)
- Skill Generation: LLM creates new measurement protocols from existing examples
- Agent Chat: Multi-turn conversation with autonomous tool calling
- Experiment Memory: SQLite with FTS5 full-text search, frozen snapshots injected into agent context
Measurement procedures reference patterns from the PICA project [@pica]. Agent architecture is inspired by OpenHarness [@openharness] and Hermes Agent [@hermes]. The framework uses litellm [@litellm] for model routing and PyVISA [@pyvisa] for instrument communication.