NeutronGym: Physics-Graded Neutron Instrument Design for LLM Agents
Organizations: Neutron Scattering Division, Oak Ridge National Laboratory, Oak Ridge, TN 37831, USA
Abstract
Designing a scientific instrument tests whether language-model agents can do physics rather than recall it, provided the grading cannot be argued with. We introduce NeutronGym, to our knowledge the first executable environment for neutron instrument design: agents build instruments through validating tools, McStas ray-traces what they build, and a level-resolved ladder grades syntax, runtime, structure and science with no LLM judge. Procedural families supply unlimited instances of a fixed layout whose design parameters the agent must set, with held-out parameter regimes; a curated slice, McStasBench, adds 16 tasks from published instruments behind memorization probes and a sandbox. Seven models reproduce at most 7 of the 16, none retrieves a reference, and none meets an improvement target. The environment also trains. Reinforcement learning on its reward takes Qwen3-8B from 11% to 77% of held-out instances of a family whose targets come from a hidden design (69% at a second seed), past an untrained Qwen3-32B, and the recipe holds, at one seed each, on three further gated families. The analysis says what that gain is. Without the ladder's partial credit it collapses by 60 points. From reward alone the trained model reaches what a classical optimizer reaches, at the agent's simulation budget, only when handed the closed-form physics (77% against 81%, a gap that does not separate at this size), while frontier models still solve 98-99%. Getting a trustworthy result meant failing four task designs that no-model baselines could solve, and we release the probes that found them.
Figures & tables
| Seen (of 16) | Held-out (of 2) | |||||
|---|---|---|---|---|---|---|
| Model | Loop | 1-shot | Loop | 1-shot | Dominant failure | |
| Claude Sonnet 5 | 5 | 7 | 2 | 1 | L1 does not compile | |
| Claude Haiku 4.5 | 4 | 4 | 2 | 0 | L4 wrong physics | |
| Gemini 3.6 Flash | 4 | 6 | 2 | 1 | L0 never finished | |
| Gemini 3.5 Flash-Lite | 2 | 1 | 1 | 0 | L0 never finished | |
| Llama 4 Maverick | 0 | 2 | 0 | 0 | L0 never finished | |
| Family / slice | Pass rate | Read against | ||
| Something simpler did it | ||||
| Search from the baseline, agent’s budget | guide match | 13.3% | 76.7% RL | |
| Search from a random start, agent’s budget | guide match | 14.3% | 76.7% RL | |
| Search from the baseline, the budget | guide match | 73.7% | 76.7% RL | |
| Hand-coded physics rule, no search | guide match | 27.7% | 76.7% RL | |
| Physics rule, then search, agent’s budget | guide match | 81.0% | 76.7% RL | |
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Access | Serving | Notes |
|---|---|---|---|
| Claude Sonnet 5 | OpenRouter | provider-pinned (Google) | |
| Claude Haiku 4.5 | OpenRouter | provider-pinned (Google) | |
| Gemini 3.6 Flash | OpenRouter | provider-pinned (Google) | |
| Gemini 3.5 Flash-Lite | OpenRouter | provider-pinned (Google) | |
| Llama 4 Maverick | OpenRouter | DigitalOcean ‡ | see § 4.2 |
| Qwen3-32B | local vLLM | 4 GPUs, YaRN 4, 98,304 ctx | thinking off |
| Tool | Purpose |
|---|---|
| Introspection: the 374 shipped components | |
| list_components | Browse components by category or search term |
| describe_component | Full parameter table for one component: type, unit, default, required, documentation |
| list_examples | Browse the shipped example instruments |
| get_example | Full source of one shipped example |
| Construction: validated at call time | |
| Task | Class | Site | Mon/obs | Note |
| Seen T1: 12 scored | ||||
| ESS_IN5_reprate | ToF spectrometer | ESS | 3 / 8 | |
| HZB_NEAT | ToF spectrometer | HZB | 3 / 8 | |
| ILL_IN6 | ToF spectrometer | ILL | 3 / 8 | |
| HZB_FLEX | Triple-axis | HZB | 2 / 6 | |
| ILL_H10_IN8 | Triple-axis | ILL | 2 / 6 | |
| # | Where | What went wrong | Fix |
|---|---|---|---|
| 1 | T2 calibration | Unconstrained flux maximization collected 672 n/s of direct beam past the beamstop; an upper limit on beam width cannot catch this, because leakage narrows the pattern. | Two-sided band constraints relative to the baseline pattern. |
| 2 | T2 calibration | The simulator’s Nelder–Mead optimizer ignored parameter bounds (a width escaped to 2.1 m). | Classical baselines are bounds- and constraint-filtered ensembles. |
| 3 | T2 calibration | Winner’s curse: the best of 30 noisy evaluations fell below its own target at a fresh seed. | Re-verify any selected optimum. |
| 4 | Agent shakedown | Matching monitors by event count graded an agent’s diagnostic monitor as its detector; correct instruments from two models failed 3/6. | Match monitors by role and position. |
| 5 | Phase-space check | A legitimate action read the bound on a 250-event monitor; at the rays it read 0.99. | Evaluate the bound only above the statistics floor. |
| 6 | SANS family | Maximal pinholes, with no model, passed 8/25 held-out instances, one at 11,992 the target: unscattered beam leaked around the beamstop and counted as signal. 22 of 35 cached optima were such leaks. | Geometric direct-beam check at L1. |
| Family | Objective | Fixed / lookup | Readout rule | Verdict |
| Guide divergence | maximize | 13.3% | 96.3% | rejected |
| SANS collimation | maximize | 14.0% | 56.0% | evaluation only |
| Bender, first version | match | 10.7% | — | rejected (concentration) |
| Guide match | match | 0 4.0% | 27.7% † | admitted |
| SANS match | match | 12.7% | 0 3.3% † | admitted |
| TOF chopper | match | 0 2.7% | 0 0.0% | admitted |
| Family | Free parameters | Objective / specification | Held-out regime |
|---|---|---|---|
| Guide (rejected) | entrance and exit width cm; | maximize flux within the divergence limit ; exit sample width | guide 12.5–16 m (train 6–12) |
| SANS (evaluation only) | two pinhole radii mm | maximize scattered intensity; beam inside the beamstop, , beam fits the sample | collimation 4.5–6 m (train 2.5–4) |
| Guide match (admitted) | as guide, without the divergence-limit check; sample – m after the exit | match spot size and divergence within | guide 12.5–16 m (train 6–12) |
| SANS match (admitted) | two pinhole radii mm | match beam width at the sample and at the beamstop within | collimation 4.5–6 m (train 2.5–4) |
| TOF chopper (admitted) | chopper frequency 20–60 Hz, phase, opening angle | match mean wavelength and spread at the sample within | chopper separation 9.5–12 m (train below) |
| Bender (admitted) | radius of curvature – m; aperture width – cm; | match the transmitted band’s mean wavelength within and its spread within ; the hidden design must cut 25–85% of the incident band | bender 23–30 m (train 12–22) |
| Run | Family | Pass rate | Read against | |
|---|---|---|---|---|
| Imitation of all turns (pre-registered) | guide, pre-repair | 31.3% | 40.3% untrained | |
| Imitation of passing turns | guide, pre-repair | 52.3% | 52.3% by one fixed action | |
| Imitation of passing turns | SANS, pre-repair | 27.0% | 31.0% untrained | |
| Same, harder targets | SANS, pre-repair | 0 1.0% | 0 8.3% untrained |
| Passes | Loop failures | One-shot failures | ||||||||||
| Model | Loop | 1-shot | L4 | L3 | L2 | L1 | L0 | L4 | L3 | L2 | L1 | L0 |
| Claude Sonnet 5 | 5 | 7 | 1 | 0 | 0 | 9 | 1 | 0 | 1 | 2 | 6 | 0 |
| Claude Haiku 4.5 | 4 | 4 | 4 | 2 | 2 | 4 | 0 | 0 | 0 | 0 | 12 | 0 |
| Gemini 3.6 Flash | 4 | 6 | 0 | 1 | 0 | 1 | 10 | 1 | 1 | 2 | 6 | 0 |
| Gemini 3.5 Flash-Lite | 2 | 1 | 1 | 0 | 1 | 5 | 7 | 0 | 0 | 0 | 15 | 0 |
| Llama 4 Maverick | 0 | 2 | 0 | 2 | 0 | 1 | 13 | 0 | 0 | 0 | 14 | 0 |
| Run | Pooled | Guide match | SANS match | TOF chopper | Bender |
|---|---|---|---|---|---|
| Specialists, one per family | — | 76.7% | 51.0% ∗ | 46.7% | 75.7% |
| joint3 | 3 families | 67.7% | 24.0% | 55.0% | — |
| joint4 | 4 families | 63.7% | 43.3% | 56.3% | 55.0% |
| joint3rep | 3, new seed | 34.0% | 19.3% | 0 2.3% | — |
| joint3rep , stage A | — | — | 11.0% | — | |
| Untrained 8B | — | 11.3% | 22.3% | 0 2.0% | 23.0% |
| Policy | Passed | Note |
| Untrained Qwen3-8B | 34/300 0 (11.3%) | exhausts the 10-turn cap |
| Untrained Qwen3-32B | 34/300 0 (11.3%) | scale buys nothing here |
| Best fixed design or lookup | 00/300 (4.0%) | incl. other instances’ solutions |
| Nelder–Mead, 10 simulations | 8/300 00 (2.7%) | 40.0% at 30 simulations |
| Random search, 10 simulations | 22/300 0 (7.3%) | 20.0% at 30 |
| Coordinate descent, 10 simulations | 40/300 (13.3%) | 73.7% at 30 |
Scientific Reasoning in Language Models
Scientific reasoning in language models studies how AI systems use evidence, domain knowledge, and tools to solve problems and support discovery.
See all 149 papers