SasAgent: Multi-Agent SAS Analysis
- SasAgent is a multi-agent AI system that automates small-angle scattering analysis by integrating LLM-driven workflows with specialized SasView tool wrappers.
- It employs a two-layer architecture where a coordinator agent directs expert agents for SLD calculation, synthetic data generation, and experimental data fitting.
- The platform delivers rigorous, reproducible results via a Gradio-based interface, achieving fast analysis speeds and statistically robust fits.
SasAgent is a multi-agent AI system designed to automate and streamline small-angle scattering (SAS) data analysis by integrating LLMs and LLM-adapted tools from the SasView software suite. The platform enables entirely natural-language-driven workflows for scattering length density (SLD) calculations, synthetic data generation, and experimental data fitting. Through layered, specialized agent interactions, SasAgent offers rigorous, reproducible SAS analysis and facilitates user interaction via a Gradio-based graphical interface (Ding et al., 4 Sep 2025).
1. System Architecture and Multi-Agent Workflow
The SasAgent architecture consists of a two-layer agent system: one top-level coordinator agent mediates all user interaction, delegating specific tasks to three expert agents, each responsible for a distinct analytic function. These agents leverage LLM-friendly wrappers around the core SasView Python APIs. The architecture is organized as follows:
- Coordinator Agent: Serves as the sole entry point for natural-language input. It parses the user prompt using a text-classification chain to determine intent. Potential intents are (1) SLD calculation, (2) synthetic data generation, or (3) experimental data fitting.
- Expert Agents:
- SLD Agent: Computes real and imaginary components of SLD using the SLD calculator tool.
- Generation Agent: Produces synthetic I(q) scattering curves by invoking the Model Data Tool and optionally the Retrieval-Augmented Generation (RAG) documentation tool.
- Fitting Agent: Performs parameter estimation on uploaded experimental data, orchestrating calls to the SLD calculator, RAG documentation tool, and bump-fitting tool.
- Tools Layer (wrappers for SasView Python API):
- Model Data Tool
- RAG Documentation Tool (indexed over 78 SasView model docs)
- Bump Fitting Tool
- SLD Calculator Tool
The coordinator agent aggregates all outputs—numerical results, fit statistics, and plots—into a unified response within a conversational chat interface.
Data Flow and Decision Logic (Pseudocode):
5 This architecture enables direct, reproducible transformations from natural-language prompts to scientifically rigorous SAS analyses (Ding et al., 4 Sep 2025).
2. Mathematical Bases: SLD, I(q), and Optimization Criteria
SasAgent operationalizes standard mathematical formulations central to SAS data analysis.
- Scattering Length Density (SLD):
- : Bound coherent scattering length of nucleus (meters).
- : Molecular volume (Å or nm, consistent units).
- Outputs: (cm or Å), (absorption component).
- Small-Angle Scattering Intensity 0:
1
- 2: Form factor amplitude determined by the chosen model (e.g., sphere, cylinder).
- 3.
- Fitting Objective Functions:
- Chi-square:
4
- Log-Likelihood (Gaussian noise):
5
- Bump Fitting Tool Optimization:
- Utilizes Levenberg–Marquardt or trust-region methods (as implemented in SasView).
- Workflow: SLD parameters fixed, parameter bounds from RAG docs, initial guesses specified, optimization executed, best-fit parameters and covariance matrix returned.
This mathematical rigor ensures that downstream analyses and fits are consistent with established SAS standards (Ding et al., 4 Sep 2025).
3. LLM-Adapted SasView Tool Wrappers
The system operationalizes four LLM-friendly API wrappers, each reflecting a specialized aspect of SAS analysis:
| Tool Name | Inputs | Outputs |
|---|---|---|
| Model Data Tool | Model name, parameter dict, 6-range, number of points | Array of 7 pairs |
| RAG Documentation | Model name, query text | Extracted parameter/unit documentation |
| Bump Fitting Tool | Experimental data 8, model, initial guess | Fitted parameters 9, 0, residue, fit curve |
| SLD Calculator Tool | Formula/sample name, density, wavelength (optional) | 1, 2 |
- Model Data Tool: Thin wrapper over SasView’s
calculate_Iq()to simulate scattering curves given model and parameter inputs. - RAG Documentation Tool: Indexes SasView HTML documentation (via BeautifulSoup, vector DB) for contextual model parameter information.
- Bump Fitting Tool: Interfaces with SasView’s
Fit.execute_bump_fit(...), facilitating parameter estimation and uncertainty quantification. - SLD Calculator Tool: Leverages SasView’s
sld_calculator()to compute sample- or solvent-specific SLDs.
This layered abstraction allows seamless LLM-driven orchestration over complex SAS tasks (Ding et al., 4 Sep 2025).
4. Workflow Examples and Precision Assessment
SasAgent supports end-to-end scientific workflows, demonstrated by the following scenarios:
- SLD Calculation:
- Prompt: "Compute SLD of D₂O at 25 °C."
- Process: Coordinator → SLD Agent → SLD tool with (D₂O, 1.11 g/cm³).
- Result: 3 Å4, 5 (negligible).
- Synthetic Data Generation:
- Prompt: "Simulate SANS for a flexible polymer chain, length=50 nm, Kuhn length=2 nm, 6."
- Process: Coordinator → Generation Agent → (RAG: model selection “FlexibleCylinder”) → Model Data Tool.
- Result: I(q) curve covering requested 7-range with specified parameters.
- Experimental Data Fitting:
- Prompt: SANS data upload, request for sphere radius fit with fixed solvent SLD.
- Process: Coordinator → Fitting Agent → (SLD tool for D₂O, RAG for parameter names, bump-fitting tool with initial radius).
- Result: 8 nm, 9, computation 0 seconds on single CPU.
These examples reveal fit residuals near statistical limits (1), demonstrating the sufficiency of the toolchain for typical SAS analyses (Ding et al., 4 Sep 2025).
5. User Interface and Interaction Paradigms
SasAgent exposes its capabilities through a Gradio-based UI optimized for clarity, auditing, and reproducibility:
- Chat Window: Accepts natural-language prompts and displays multimodal agent replies (numerics, text, plots).
- System Logs: Reports coordinator/agent tool invocations for workflow transparency.
- Settings: API key interface and choice of LLM backend (gpt-4o, gpt-5, Claude Sonnet-4, Gemini, etc.), facilitating cost-performance tradeoffs.
- Plot Display: Interactive rendering of I(q) curves, fit overlays; hover tooltips reveal trace details.
- Data Upload: Drag-and-drop for experimental datasets.
- Usability Features:
- Pre-populated example prompts for each workflow.
- Downloadable outputs (CSV: best-fit parameter vectors, residuals).
- Live orchestration logs to support debugging and fine-grained method auditing.
This user-centric design, coupled with agent modularity, allows both non-experts and domain specialists to utilize advanced scripting-free SAS workflows (Ding et al., 4 Sep 2025).
6. Significance and Research Trajectory
SasAgent demonstrates that a two-layer, multi-agent LLM system—built atop modular, LLM-adapted scientific tool wrappers—can automate the full SAS analytic pipeline, from raw user prompts to parameter estimation and hypothesis-driven synthetic experiment generation. The platform exemplifies how state-of-the-art LLMs can interface with legacy scientific software, producing outputs with mathematical rigor, transparency, and operational speed (typical analysis 215 s per dataset, 3 performance benchmarked at 4).
A plausible implication is that such systems will further accelerate the adoption of autonomous scientific workflows, lowering the barrier to complex analyses, enhancing reproducibility, and enabling advanced forms of research collaboration without manual intervention (Ding et al., 4 Sep 2025).