arXiv(opens in a new tab)cs.AISep 2026Cited by 6 papers on PaperVantage

Manuscript Offprint

arXiv:2609.04148

Terminal-Universe: Turning Agent Trajectories into Scalable Terminal Environments

Jie Wu, Zhenru Zhang, Beichen Zhang, Xuwu Wang, Yuhui Su, Mouxiang Chen, Peng Wang, Zhihai Wang, Que Shen, Hao Zhou, An Yang, Fei Huang, Yujiu Yang, Dayiheng Liu

Abstract

As terminal-based code agents become increasingly prevalent, the corresponding agent trajectories have accumulated at scale, while realistic, executable environments remain scarce. However, environments are what agent post-training actually requires: each one can be re-queried into many verifiable tasks and provides the execution feedback, whereas a trajectory is a single frozen demonstration. Rather than generating environments from scratch, we observe that the tool-execution history in the existing agent trajectories exposes the structure and contents of the environments in which they ran, making it possible to reconstruct those environments from the trajectories themselves. Thus, we introduce Terminal-Universe, a framework which turns each trajectory into a reusable environment and explores it for synthesizing new tasks and continued interactions. Specifically, Terminal-Universe replays the file operations recorded in a trajectory to restore each file before the agent modified it, yielding a partial workspace; a completion agent then supplies the missing files and dependencies. On this recovered workspace, we both reconstruct the original intent task and synthesize entirely new ones. Besides, we also scale the tasks for the corresponding environment along two complementary axes: breadth and depth, to reproduce a routine pattern of real engineering practice. For breadth, we mine directional dependency relations between related environments and synthesize cross-workspace queries spanning multiple code-bases, as developers routinely do in real-world development. For depth, we extend the initial single-turn query into a multi-round session that captures iterative user feedback and requirement refinement via a user agent. Applied to publicly available terminal agent trajectories, Terminal-Universe produces 37.3k task-sufficient environments. Supervised fine-tuning of Qwen3.5-27B on this corpus improves single-round performance on Terminal-Bench 2.1 by 11.9 points and multi-round performance on EvoCode-Bench v2 MT@4 by 13.8 points.

1 Introduction

As terminal-based code agents become increasingly prevalent, the trajectories they produce have accumulated at scale, while realistic, executable environments remain scarce. This gap matters because a trajectory and an environment are not equally useful. A trajectory is a single, fixed record: its quality is bounded by the responses of the policy model that produced it, and we cannot check whether the changes it made to the codebase are actually correct. An environment has none of these limits, because the same task can be solved again by a stronger model, the result can be verified by our own tests, and harder tasks can be posed on the same workspace. For post-training, the environment is therefore the resource worth scaling. Expert-authored benchmarks show what a good environment looks like. Terminal-Bench (Merrill et al., 2026), for example, pairs every task with a custom container, an instruction, and an executable verifier. This reliability comes from manual effort, which also limits how many tasks can be built, while effective post-training needs far more environments than manual curation can provide. Supplying realistic, verifiable environments at training scale is therefore the challenge we address.

Existing work scales executable environments in three ways. Repository-based methods build tasks from the git history of a real repository (Pan et al., 2024; Jain et al., 2025). For a bug that was fixed in the past, they use git to roll the repository back to the state just before the fix to form the environment, take the original bug report as the task, and reuse the tests that came with the fix to check the solution. Perturbation methods take a repository that passes its tests, inject a bug so that some tests now fail, and ask the agent to fix it (Yang et al., 2025; Lin et al., 2026). A few repositories can yield many tasks this

∗^{*}Work done during the internship at Qwen Team, Alibaba Group.

Figure

Figure 1: Overview of Terminal-Universe. A trajectory and an environment are two views of the same episode, so prior work rolls out a trajectory from an environment while we invert the mapping and recover an environment from a trajectory (left). Reconstruction proceeds in two stages, deterministic replay followed by agentic completion (middle). Each recovered environment is then re-queried within one workspace, across multiple dependent workspaces, or over multiple user rounds (right). Figure 2 details each mechanism.

way, but every task is a repair task, and the range of tasks is limited by the source repositories and the kinds of bugs that can be injected. Task-conditioned synthesis generates the task and its environment together from scratch, guided by categories or compositional axes (Gandhi et al., 2026; Ivison et al., 2026), skill taxonomies (Hua et al., 2026), or skill graph (Fan et al., 2026). These methods offer control over coverage and task-environment alignment, but the environment is not tied to any real project, so its realism depends entirely on the generator, which tends to produce small and tidy workspaces rather than real code.

Across these routes, environment construction either starts from an existing environment or is coupled to a newly generated task from scratch. Trajectories, as observations of the environments they ran in, remain largely underexplored as a resource. The tool calls recorded inside a trajectory already reveal the content and structure of the environment it ran in. For instance, the tool Read shows file contents, and Write and Edit show how the workspace changed. This is enough to rebuild an executable copy of the original workspace. Therefore, we propose Terminal-Universe (Figure 1), a framework which turns each trajectory into a reusable environment and explores it for synthesizing new tasks and continued interactions.

Specifically, to construct the environments based on the trajectories (§ 3.1), we first replay the recorded file operations and restore each file to its state before the agent changed it, holding back the agent's own edits so that the workspace starts unsolved. Since replay usually yields only a partial workspace, a completion agent then automatically supplies the missing files and dependencies the task needs, without leaking the solution. For the corresponding tasks, we both reconstruct the original intent queries and synthesize entirely new ones. Besides, to better match real-world software engineering scenarios, we also scale the tasks on the environment along two complementary axes: breadth and depth (§ 3.2). Breadth expansion goes beyond the single-repository setting that most task synthesis assumes. We identify dependency relations between related environments and build cross-workspace tasks that span multiple codebases which are much harder, e.g., reading a reference implementation, moving a feature from one project to another, or connecting two components. Depth expansion turns a single-round task into a multi-round one. After the agent completes an initial query, a user agent asks grounded follow-ups as the workspace changes—extending it with new requirements, or, when a round fails, asking for a fix based on what went wrong. We verify every round, and the outcome is fed back to the agent as natural, user-visible feedback. Every new task comes with a verifier written by an agent inside the container, and we keep only the trajectories whose tests all pass (§ 4).

On publicly available terminal agent trajectories, this pipeline produces 37.3k task-sufficient environments. Over these environments, we generate new queries and use Qwen3.7-Max as the teacher to roll out a solution trajectory for each task. Training Qwen3.5-27B on the resulting data validates the effectiveness of our method: it improves the single-round benchmark Terminal-Bench 2.1 by 11.9 points and the multi-round benchmark EvoCode-Bench v2 MT@4 by 13.8 points (§ 5). Extensive ablations confirm that each component contributes, most notably that re-solving tasks in reconstructed environments far outperforms imitating the raw trajectories.

Table 1: Comparison of representative environment and training-data construction methods. Strategy summarizes the primary mechanism used to construct environments or training tasks. Env. counts reusable source repositories/workspaces or independently constructed environments, and Tasks gives the reported task or training-instance count. Verif. indicates an executable task verifier, Multi-Round denotes extended multi-round queries, and Cross-WS cross-workspace synthesis.

MethodStrategyEnv.TasksVerif.Multi-RoundCross-WS
Endless Term. (Gandhi et al., 2026)task-conditioned3,2553,255✓✗✗
TMax (Ivison et al., 2026)combinatorial sampling14.6k14.6k✓✗✗
CLI-Gym (Lin et al., 2026)env. perturbation291,655✓✗✗
CLI-Universe (Hua et al., 2026)taxonomy-guided6k6k✓✗✗
SkillSynth (Fan et al., 2026)skill graph-guided3,5603,560✓✗✗
OpenThinker-Agent (Raoof et al., 2026)multi-source curation–100k✓✗✗
RST (Li et al., 2026b)recursive evolution37.5k37.5k✓✗✗
CalibForge (Meng et al., 2026)adversarial calibration5,4315,431✓✗✗
Terminal-Universe (ours)trajectory reconstruction37.3k32.0k✓✓✓

To sum up, we make the following contributions:

  • Environments reconstruction. We reframe recorded agent trajectories as a source of reusable executable environments, and reconstruct each one through deterministic replay followed by agentic completion—without needing the original repository or building from scratch.

  • Re-querying methods. We scale the utility of each reconstructed environment through new task generation. Besides the vanilla single-workspace and single-turn tasks, we contribute breadth expansion via cross-workspace task synthesis and depth expansion via multi-round user queries. Each task is paired with an agent-authored verifier, and only trajectories that pass are kept.

  • Empirical validation. Fine-tuning Qwen3.5-27B on the resulting corpus improves Terminal-Bench 2.1 by 11.9 points and EvoCode-Bench v2 MT@4 by 13.8 points over the same base model. Ablations confirm that each component contributes, and notably that re-solving in reconstructed environments far outperforms imitating the raw trajectories.

References (32)