arXiv(opens in a new tab)cs.SEOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.02710

Self-Supervised Scaling of Terminal Environments for Scientific Domains

Zhongzhi Li, Yucheng Shi, Zongxia Li, Junyao Yang, Ruhan Wang, Yu Wang, Jingyuan Huang, Jichao Yu, Ninghao Liu, Haitao Mi, Leowei Liang

Zhongzhi Li ∗1,2^{*1,2}, Yucheng Shi ∗†1^{*†1}, Zongxia Li ∗1,3^{*1,3}, Junyao Yang 1,4^{1,4}, Ruhan Wang 1,5^{1,5}, Yu Wang 6^{6}, Jingyuan Huang 2^{2}, Jichao Yu 2^{2}, Ninghao Liu †7^{†7}, Haitao Mi 1^{1}, Leowei Liang 1^{1}

1^{1}Tencent HY LLM Frontier 2^{2}University of Georgia 3^{3}University of Maryland, College Park 4^{4}National University of Singapore 5^{5}Indiana University 6^{6}University of Illinois at Chicago 7^{7}Hong Kong Polytechnic University

∗^{*}Equal contribution, †^{\dagger}Project lead., ‡^{\ddagger}Corresponding author.

ninghliu@polyu.edu.hk, zl22754@uga.edu, zhongzhili@global.tencent.com

Terminal agents are increasingly deployed beyond software engineering in science and other specialized domains. Constructing training environments in these settings requires both executable reference behavior and a domain-specific verifier capable of distinguishing semantic correctness from superficially plausible artifacts. Authoring these components independently for every task requires repeated task-specific engineering and limits their reuse across tasks. We introduce software-in-the-loop reconstruction, a self-supervised learning framework that obtains reference outputs and verification targets from existing software workflows, defined as executable programs that map structured inputs to outputs. For each workflow, we execute multiple input configurations and partition the resulting cases into public observations and hidden evaluations. Given the instruction, input schema, and public input–output observations, an agent constructs an editable program without access to the source workflow. The candidate is then evaluated on hidden configurations against outputs produced by the workflow. A hierarchical verifier combines domain-specific semantic comparison, structural validity, and anti-shortcut checks, while feedback on public cases supports iterative revision. The construction admits additional workflows and input configurations without independently authoring a reference solution for each task. We instantiate the framework as SWR, which contains 500 workflows and 46 software families across six domains, including physical and engineering simulation, life and molecular sciences, and earth and space sciences. Across three attempts per task, Qwen3.8-Max solves 838 tasks and produces 1,422 verified trajectories, which we oversample to 3,000 reconstruction-only training examples. Supervised fine-tuning of Qwen3.8-27B improves mean Terminal-Bench 2 performance from 47.94% to 53.56% across three seeds and achieves the highest mean among four matched-token corpus controls on all four reported evaluations. These results indicate that existing scientific software can provide a scalable source of behaviorally verified supervision for terminal agents.

Figure

Figure 1. Image masking learns visual representations from hidden pixels. Our method reconstructs workflow behavior from public configurations, tests it on hidden configurations, and retains passing trajectories for terminal-agent SFT.

1 Introduction

Language-model agents can execute programs, coordinate tools, and finish multi-step work from a command line (Luo et al., 2025). Their uses extend from software engineering to scientific computing, engineering analysis, and other specialized domains (Yuan et al., 2026), and benchmarks such as SWE-bench, SWE-Gym, and Terminal-Bench measure these abilities by executable outcomes (Jimenez et al., 2024; Merrill et al., 2026; Pan et al., 2024). Current training data still focus on software engineering, so science and engineering domains remain less covered. Further progress therefore needs tasks grounded in the software workflows used by these domains together with reliable checks of completion.

Two obstacles make these tasks hard to build. The first is the domain-specific verifier, which must accept correct programs that differ in algorithm or output format, reject results that only look valid, and apply criteria that differ across science and other domains. Scientific workflows sharpen this obstacle because their outputs can be numerical arrays, meshes, waveforms, biological sequences, or structured tables whose validity cannot be inferred from artifact existence alone. The second obstacle is scale, because existing benchmarks use a separate test or validator for each task (Hendrycks et al., 2021; Jain et al., 2025; Zhou et al., 2024), and repeating that design does not scale. The central problem is to obtain a reference solution and a verification target without writing both from scratch for every task.

Software-in-the-loop reconstruction is a self-supervised learning method for this problem. It reuses one existing program across multiple tasks, allowing reference outputs and a common reconstruction interface to be shared. We call this program a workflow, an existing program that maps an input to an output. We run it on several inputs, record the outputs, and show the agent some of these pairs. The agent then writes a new program without seeing the workflow code. We run that program on the remaining inputs and compare its outputs with the workflow outputs, so the workflow is both the reference solution and the source of the expected outputs. One workflow therefore supplies reference behavior for many tasks through a shared interface. New inputs yield further tasks for science, engineering, and other specialized domains. Figure 1 contrasts this procedure with conventional image-based self-supervision. Image masking predicts withheld pixels and transfers the resulting visual representation to later tasks. Software-in-the-loop reconstruction instead divides workflow executions into public and hidden configurations. In the illustrated OpenSCAD example, the public configuration has six gear teeth and the hidden configuration has eighteen, so the reconstructed program must respond to a changed parameter rather than reproduce the observed geometry. Only interactions that pass hidden semantic verification become terminal-agent SFT trajectories. The setup follows programming by example and behavioral system identification (Gulwani, 2011; Gulwani et al., 2017; Ljung et al., 1987). Domain-specific comparison rules are still required, and we test them in a separate audit after the verifier is frozen and in a blinded human review.

Figure 2 illustrates how a software workflow supplies public evidence, the input–output examples released to the agent, and hidden reference outputs on withheld inputs. These support task construction, verification, and collection of training trajectories. We instantiate this procedure as SWR. The construction scales directly because each workflow is wrapped once by adapting it to a common program interface and is then reused under new input configurations. Additional workflows enter through the same checks. The experiments below use a release built from 500 workflows across 46 software families, where a family groups workflows that share a common tool. The release connects software used in physical science, molecular analysis, and earth and space science with supporting formal, spatial, and data workflows. Qwen3.8-Max solves 22.8% of tasks in the first evaluation round and 27.9% at least once across three attempts, yielding 1,422 verified trajectories from 838 tasks. Many unsuccessful runs produce executable programs but fail the hidden behavioral checks, indicating that artifact emission alone is insufficient for reconstruction success. To evaluate the training value of the verified trajectories, we construct an oversampled reconstruction-only corpus for supervised fine-tuning (SFT) of Qwen3.8-27B. We evaluate the resulting models on Terminal-Bench 2.0 (TB2), Terminal-Bench 4.0 (TB4), Long-Horizon Terminal-Bench (LHTB), and SWR100, a held-out 100-task subset of SWR, using three seeds and matched-token controls that allocate every corpus the same number of assistant-loss tokens.

Figure

Figure 2 Software-in-the-loop reconstruction. Public observations are the input–output examples released to the agent. They guide construction of a reusable program. Withheld inputs supply the reference outputs used for verification.

Our main contributions are as follows:

  1. We formulate software-in-the-loop reconstruction for task construction in science and other specialized domains, so that each task is derived from one executable workflow. Each workflow supplies a reference solution, public examples, and hidden reference outputs for multiple task variants, deriving reference behavior and verification targets from the same executable source rather than specifying them independently.

  2. We construct SWR and a hierarchical semantic verifier. The task set scales by adding workflows and input configurations under fixed release checks. We assess sensitivity of workflow outputs to input changes, predefined replay controls that resubmit public outputs, and verifier reliability, including an independent audit conducted after the verifier is frozen.

  3. We characterize reconstruction difficulty and evaluate verified trajectories as reconstruction-only SFT data, reporting three-seed results and comparisons with four matched-token corpus controls on downstream terminal-agent evaluations.

References (38)