AI for Science: Agent-Driven Reconstruction of the Research Workflow
This article explains how research-focused AI agents move beyond question answering to take ownership of verifiable, replayable analysis workflows. It outlines a five-layer architecture that prevents models from directly accessing data, shows how ambiguous research questions are compiled into executable task specifications, and details sandboxing, dependency pinning, tool registries, and triple-cross validation. It also covers reproducibility, auditing, common anti-patterns, and a phased adoption roadmap for teams building trusted scientific agents.
1. From “Assisted Q&A” to “Owning the Workflow”: The Capability Boundary of Research Agents
Over the past two years, large models have mainly served research scenarios as tools for “Q&A and polishing”: explaining concepts, rewriting abstracts, and translating literature. Once models are connected to a research analysis platform with data and tool capabilities, their role begins to change fundamentally—shifting from offering text-based suggestions to taking ownership of a verifiable segment of the analysis workflow. The core of this shift is not model parameter scale, but the combination of three things: structured understanding of the research question, executable code generation, and standardized invocation of domain tools.
The boundary must be defined first. Agents are suited to “process-oriented, verifiable, replayable” work, such as data cleaning, statistical testing, visualization, batch literature information extraction, and parameter sweeps. They are not suited to making conclusive judgments without human review, such as clinical interpretation, final adjudication of causal inference, or safety conclusions. Writing the boundary into system design—rather than into a disclaimer—is the dividing line that determines whether such a platform can be deployed.
2. Overall Architecture: Five Decoupled Layers to Avoid “Models Directly Operating on Data”
A robust implementation is typically divided into five layers, with explicit contracts between them:
- Interaction layer: receives natural-language research intent and outputs a structured task specification.
- Orchestration layer: breaks the specification into an execution graph with dependencies and decides serial, parallel, and retry strategies.
- Tool layer: manages callable capabilities through a registry, including statistics, plotting, retrieval, and format conversion.
- Execution layer: runs generated code in an isolated sandbox with resource and network egress restrictions.
- Recording layer: persists inputs, code, dependency versions, outputs, and logs to support reproduction and auditing.
The key principle is that the model only produces “plans and code” and never holds data read/write permissions directly; all side-effect actions must go through the tool layer and execution layer.
3. Task Understanding: Compiling Vague Questions into Executable Task Specifications
Research questions often omit premises. The system needs a “clarify—complete—confirm” loop to make implicit assumptions explicit. An intermediate representation can be defined as follows:
{"objective": "Compare the difference in metric A between two sample groups","dataset": {"ref": "ds_2024_03", "schema_version": "v2"},"assumptions": ["The two groups are independent", "Metric A is approximately normally distributed"],"checks": ["Normality test", "Homogeneity of variance test"],"outputs": ["Statistical table", "Box plot", "Draft methods paragraph"],"constraints": {"runtime_sec": 600, "no_network": true}}
With a task specification in place, the orchestration layer can perform static validation: whether data references exist, whether output types are supported, and whether constraints can be satisfied. This step intercepts many plans that “look reasonable but cannot be executed.”
4. Code Generation and Execution: Sandboxing, Dependencies, and Determinism
Model-generated code must be treated as untrusted input. Engineering recommendations include: containerized execution, read-only mounting of raw data, writing to a separate output directory, disabling outbound network access, setting CPU and memory limits, and terminating on timeout. Dependencies should not be implicitly upgraded; use a lock file to pin versions, ensuring the same task specification produces consistent results at different times.
# Example: the execution contract for invoking generated coderesult = executor.run(code=plan.code,inputs={"data": "readonly://ds_2024_03"},outputs="writeonly://out/plot.png",limits={"cpu": 2, "mem_gb": 4, "timeout_sec": 600},seed=20260806)assert result.status in {"ok", "failed"} and result.log_ref
Fixing the random seed, recording dependency versions, and saving hashes of intermediate artifacts form the three essentials of “reproducibility.”
5. Tool Invocation: Registry, Schema Validation, and Least Privilege
The tool layer should provide machine-readable descriptions: name, purpose, input/output schemas, resource cost, and whether network access is required. The model can only select from the registry, validate schemas before invocation, and validate result types afterward. Permissions follow least privilege: retrieval tools may access the network but only for whitelisted purposes, computation tools have no network access, and file-writing tools are restricted to specific directories.
When a tool is missing, the correct behavior is to “declare failure and suggest an alternative path,” rather than letting the model fabricate a nonexistent interface. This point is often overlooked in reviews, yet it is a critical line of defense for data trustworthiness.
6. Result Validation: Triple Cross-Checking Instead of a Single Judgment
A single model self-assessment is insufficient to support research conclusions. Triple validation can be adopted: first, deterministic validation, comparing statistics against an independent implementation; second, constraint validation, checking whether sample size, missing rate, and unit dimensions meet the premises; third, reproduction validation, rerunning once and comparing output hashes. When the three are inconsistent, the result is downgraded to “pending human review” with an accompanying explanation of the differences.
7. Reproducibility and Auditing: Treating the Process as a First-Class Artifact
The recording layer should store the task specification, plan, code, dependency lock, random seed, raw data version number, output hashes, and elapsed time. The audit perspective focuses on “who, at what time, based on which data version, produced which conclusion version,” rather than only looking at the final charts. Object storage is suitable for artifacts and logs, message queues for peak shaving and task distribution, container platforms for sandbox runtimes, and logging services with monitoring and alerting for failure localization and quota protection—these general capabilities can be provided by cloud platforms such as Baidu AI Cloud in standard categories, making it easy for teams to compose them as needed.
8. Common Anti-Patterns
- Letting the model connect directly to a production database and execute arbitrary statements.
- Replacing statistical tests and reproduction validation with model self-assessment.
- Writing tool descriptions in natural language without input/output schemas.
- Floating dependency versions that make historical results impossible to recompute.
- Handling “tool not found” by fabricating a call, contaminating the entire pipeline.
9. Adoption Roadmap Recommendations
In the first phase, only read-only analysis and visualization are performed to validate the task specification and validation mechanisms; in the second phase, restricted write permissions and batch tasks are introduced, with quotas and alerting improved; in the third phase, domain tool sets and evaluation sets are accumulated, using fixed benchmarks to measure plan success rate, execution success rate, and reproduction consistency rate. The evaluation set should include “non-executable tasks” to test the system’s refusal and degradation capabilities.
In summary, the real engineering challenge of research agents lies not in generation, but in constraints, validation, and recording. Only by solidifying these three aspects can a model evolve from “an assistant that can write code” into “a trusted workflow executor.”
