Model-Driven Analysis Workflows for AI for Science: Engineering Practices

    Scientific analysis often spans literature understanding, data cleaning, algorithm selection, code writing, domain tool invocation, result interpretation, and reporting. This article examines how large language models and agent orchestration can be embedded into a controlled engineering pipeline instead of being positioned as replacements for scientists. It covers the main pain points in research analysis, defines what models should and should not do, breaks down a six-stage workflow from problem understanding to result preservation, presents a controlled orchestration architecture with pseudo-code, and summarizes quality, security, and adoption considerations. The goal is to make model-generated plans and code verifiable, auditable, and reproducible within scientific analysis workflows.

    Model-Driven Analysis Workflows for AI for Science: Engineering Practices

    In research computing and engineering analysis, a complete analysis task often spans literature understanding, data cleaning, algorithm selection, code writing, professional tool invocation, result interpretation, and report preservation. In traditional practice, these steps rely heavily on expert experience. Toolchains are fragmented, parameter configuration is complex, and process records are incomplete, which leads to repetitive work, high reproduction costs, and a high barrier to collaboration. With advances in large language models and agent orchestration, a more practical path is not to let models directly replace scientists, but to let them handle intermediate steps in the analysis workflow that can be described, validated, and audited. Examples include understanding the research question, decomposing analysis steps, generating computation code, invoking domain tools, and summarizing intermediate results.

    This direction can be summarized as the model-driven construction of research analysis workflows. Its core is not single-point question answering, but embedding models into a controlled engineering pipeline so that scientific analysis gradually shifts from manually chaining tools to a structured process: problem description, plan generation, tool execution, result validation, and recorded reproduction.

    1. Requirements and Pain Points: Why Models Need to Enter the Analysis Workflow

    The first pain point in research analysis is the gap between task description and execution. Researchers usually describe goals in natural language, such as “compare differences under different experimental conditions and provide a significance judgment.” Actual execution, however, requires explicit data fields, statistical assumptions, preprocessing strategies, test methods, and visualization forms. A model can first perform task translation, converting a vague goal into a structured analysis plan and reducing the cost of moving from a question to code.

    The second pain point is toolchain fragmentation. Scientific computing involves many types of tools, including data I/O, numerical computation, statistical testing, signal processing, image analysis, and simulation solving. Their interfaces, parameters, and input formats differ. Through tool registration and invocation orchestration, a model can select tools, fill in parameters, and organize call order within a restricted scope, instead of requiring users to manually remember a large number of commands.

    The third pain point is insufficient reproducibility. If temporary scripts, parameter changes, and intermediate files are not recorded, later reproduction becomes difficult. A model-driven workflow can preserve each plan, code artifact, tool invocation parameter, execution log, and validation result as structured records, providing a foundation for version management and auditing.

    The fourth pain point is security and compliance. Research data may contain sensitive information, and tool execution may involve high-privilege resources. Engineering controls must manage risk through sandboxes, least privilege, data desensitization, and human approval. Models must not have unrestricted arbitrary execution capability.

    2. Capability Positioning: What Models Should and Should Not Do

    In research analysis workflows, models are suitable for four types of responsibilities. First, they can understand research questions and extract constraints. Second, they can decompose goals into executable steps. Third, they can generate or complete analysis code and parameter configurations. Fourth, after tools return results, they can generate explanations, check anomalies, and suggest next steps. Models are not suitable for directly providing final scientific conclusions without validation, nor should they bypass permission systems to access sensitive data or high-privilege tools.

    A reasonable positioning is therefore a controlled analysis assistant and workflow orchestrator. Model outputs should be treated as candidate plans or candidate code. They must pass static checks, unit tests, reference result comparison, or human confirmation before formal execution. For high-risk steps, such as deleting data, submitting large-scale computing jobs, or modifying experimental equipment parameters, mandatory approval nodes should be established.

    3. Workflow Breakdown: From Problem Understanding to Result Preservation

    3.1 Problem Understanding and Structured Modeling

    The model first needs to convert a natural language question into a structured task description, including the research objective, input data, variable definitions, constraints, expected outputs, and acceptance criteria. In engineering practice, the model can be required to output a plan object with fixed fields rather than free text. For example:

    1. Task objective: Compare differences between two groups of experimental data
    2. Input data: Data table identifier, grouping field, observation field
    3. Assumptions: Independence, distribution assumptions, missing-value handling strategy
    4. Expected output: Statistics, significance conclusion, chart description
    5. Acceptance criteria: Method selection justified, parameters traceable, results reproducible

    Structured output is easier to validate and orchestrate later, and it also reduces the room for the model to improvise.

    3.2 Task Decomposition and Tool Selection

    After the goal is clear, the model needs to break the task into steps and match each step to a tool category. Tools should be exposed through a registry. The registry should describe only tool purpose, input and output schemas, permission level, and version information, without exposing unnecessary internal details. The model can select tools only within the scope allowed by the registry and cannot invent tools or parameters.

    3.3 Code Generation and Parameter Configuration

    Code generation should follow the principle of small-step generation and stepwise validation. Generating a complete long script in one pass makes error localization costly. A more reliable approach is to generate function-level code step by step and provide input examples, boundary checks, and assertions for each function. Parameters should be listed explicitly rather than hidden in default values. For scenarios such as statistical testing and numerical solving, the model can be required to provide both the rationale for method selection and the assumptions to check.

    3.4 Tool Invocation and Execution Orchestration

    The execution layer is responsible for converting the model-generated plan into actual calls. The orchestrator should provide timeout control, retry policies, resource limits, concurrency control, and result caching. Tool invocation parameters need schema validation, and return values need to be uniformly wrapped into parseable structures. The execution environment should be isolated so that model-generated code cannot affect the host machine or other tasks.

    3.5 Result Interpretation and Cross-Validation

    After tools return results, the model can generate explanations, but explanations must cite specific intermediate results. Engineering controls should include cross-validation: numeric range checks, unit consistency checks, missing-value ratio checks, comparison with reference implementations, and consistency checks across repeated executions. For key conclusions, the model can be required to provide supporting evidence and uncertainties, and to mark parts that require human review.

    3.6 Records, Reproduction, and Knowledge Preservation

    Each analysis should record the task description, plan version, code version, tool version, parameters, execution logs, validation results, and human approval records. This supports reproduction and also provides templates for similar tasks later. Over time, teams can form an internal analysis workflow library and preserve high-frequency, low-risk analysis patterns as reusable workflows.

    4. Engineering Architecture: Controlled Orchestration at the Center

    A practical system usually includes the following layers:

    • Interaction layer: receives natural language questions and displays plans, intermediate results, and approval nodes.
    • Planning layer: uses models to generate structured analysis plans and perform field validation.
    • Tool registry layer: maintains tool categories, input and output schemas, permission levels, and versions.
    • Execution layer: runs code or calls domain tools in a sandbox and handles timeouts, retries, and resource limits.
    • Validation layer: performs static checks, unit tests, reference result comparison, and anomaly detection.
    • Audit layer: records full-chain logs, parameters, and approval information.
    • Infrastructure layer: can use general-purpose object storage for data and artifacts, container platforms for isolated execution environments, and logging and monitoring services to observe task status.

    A pseudo-code example is as follows:

    1. function run_analysis(question, data_ref, user_context):
    2. plan = model.generate_plan(question, data_ref, tool_registry)
    3. validate_schema(plan)
    4. if plan.requires_high_risk_tool:
    5. require_human_approval(plan)
    6. artifacts = []
    7. for step in plan.steps:
    8. tool = tool_registry.resolve(step.tool_category)
    9. params = validate_params(step.params, tool.input_schema)
    10. code = model.generate_code(step, tool)
    11. check_static_rules(code)
    12. result = sandbox.execute(code, tool, params, timeout=step.timeout)
    13. assert_result(result, step.acceptance_criteria)
    14. artifacts.append(record(step, code, params, result))
    15. summary = model.summarize(artifacts, plan.acceptance_criteria)
    16. return audit_record(plan, artifacts, summary)

    The pseudo-code emphasizes three principles: structured plans, a tool allowlist, and auditable execution. The model is responsible only for generating candidate plans and code, while execution and validation are controlled by the engineering system.

    5. Quality and Security: Boundaries That Cannot Be Skipped

    For quality control, an evaluation set should be established for research tasks, covering problem understanding, method selection, code correctness, parameter rationality, and result explanation accuracy. After each model or workflow change, regression testing should be performed on a fixed task set. For code generation, unit tests, property-based testing, and reference implementation comparison can be used. For conclusion output, a distinction should be made between calculation results and interpretive judgments, avoiding treating model explanations as scientific evidence.

    For security, the principle of least privilege should be followed: models can call only authorized tools, sensitive data should be desensitized before entering the model, execution environments should be isolated, the tool supply chain should be audited, and output content should be filtered. For tasks involving personal data, experimental safety, or production systems, human approval must be retained. Audit logs should be tamper-resistant or at least traceable.

    6. Adoption Path: Start with High-Frequency, Low-Risk Tasks

    At adoption, it is not advisable to cover the full workflow from the beginning. Teams can start with tasks that are high-frequency, low-risk, and easy to validate, such as data quality checks, routine statistical descriptions, chart generation, parameter sweep assistance, and report draft organization. First establish the tool registry, structured plan templates, and validation rules, then gradually extend to more complex analysis chains. Each extension should have a corresponding evaluation set and human review mechanism.

    Overall, the key to model applications in AI for Science is not to make models look like they can do research, but to embed model capabilities into engineering processes that are verifiable, auditable, and reproducible. Models handle understanding, generation, and orchestration; engineering systems handle constraints, execution, and validation; experts handle goal setting and final judgment. Only through this collaboration can models become genuinely productive tools in research analysis workflows.