# Terminal-Universe: Turning Agent Trajectories into Scalable Terminal Environments

> Terminal-Universe reconstructs executable terminal environments from recorded agent trajectories, improving Terminal-Bench 2.1 by 11.9 points and EvoCode-Bench v2 MT@4 by 13.8 points.

- **Source:** [arXiv](https://arxiv.org/abs/2609.04148)
- **Published:** 2026-09-05
- **Permalink:** https://picx.dev/p/ECrOLN
- **Whiteboard:** https://picx.dev/p/ECrOLN/image

## Summary

## Summary (Overview)

- **Terminal-Universe** is a novel framework that reconstructs executable terminal environments from recorded agent trajectories, inverting the traditional environment→trajectory mapping.
- The framework uses a two-stage reconstruction process: **deterministic replay** of file operations followed by **agentic completion** to restore missing context, yielding 37.3k task-sufficient environments.
- Four complementary re-querying mechanisms scale task utility: **Intent Recovery** (reconstructing original tasks), **Single-WS** (within-workspace synthesis), **Cross-WS** (cross-workspace breadth expansion), and **Multi-Round** (multi-turn depth expansion).
- Fine-tuning Qwen3.5-27B on the resulting corpus improves **Terminal-Bench 2.1 by 11.9 points** (46.2→58.1) and **EvoCode-Bench v2 MT@4 by 13.8 points** (6.3→20.1).
- Ablations confirm that **re-solving recovered tasks in reconstructed environments far outperforms imitating raw trajectories** (52.1 vs. 36.7 on Terminal-Bench 2.1).

## Introduction and Theoretical Foundation

The paper addresses a critical gap in terminal-based code agent training: while agent trajectories have accumulated at scale, realistic, executable environments remain scarce. The key insight is that **trajectories and environments are two views of the same episode**—a trajectory is a single frozen demonstration, while an environment can be re-queried into many verifiable tasks with execution feedback.

**Why environments matter more than trajectories:**
- A trajectory's quality is bounded by the policy model that produced it
- Trajectories cannot be verified for correctness
- Environments allow re-solving by stronger models, verification via custom tests, and posing harder tasks

**Existing approaches and their limitations:**
1. **Repository-based methods** (SWE-Gym, R2E-Gym): Roll back git history to create environments—limited to repair tasks from past bugs
2. **Perturbation methods** (SWE-smith, CLI-Gym): Inject bugs into working repositories—task range limited by injectable bug types
3. **Task-conditioned synthesis** (Endless Terminal, CLI-Universe): Generate tasks and environments from scratch—environments lack realism of real projects

**The novel insight:** Tool calls recorded inside trajectories reveal the content and structure of the environments they ran in. The `Read` tool shows file contents; `Write` and `Edit` show how the workspace changed. This is sufficient to rebuild an executable copy of the original workspace.

## Methodology

### 3.1 Environment Reconstruction

The reconstruction proceeds in three stages:

**Stage 1: Deterministic replay.** Processes read/write/edit operations chronologically to recover, for each accessed path, the earliest and latest file contents visible in the trajectory. The reconstructed initial workspace $\widehat{E}_0$ collects each pre-existing file at its earliest observed version before the agent's first change; files created by the agent are excluded.

**Stage 2: Agentic completion.** Given the partial workspace $\widehat{E}_0$ and recovered task $q$, a completion agent creates missing files, completes partial files, and restores dependencies needed to make $q$ solvable without implementing it.

**Stage 3: Environment filtering.** An agentic judge inspects each workspace with read-only shell/file tools and labels it sufficient or insufficient based on whether its source, configuration, data, and structure give a capable agent enough context.

### 3.2 Re-querying Mechanisms

**Intent Recovery:** Normalizes trajectories into chronological streams, consolidating user requests into self-contained tasks.

**Single-WS (Single-Workspace Synthesis):** An offline generator synthesizes five candidate tasks per workspace under groundedness, structural diversity, and verifiability constraints.

**Cross-WS (Breadth Expansion):** Discovers directional dependency relationships across environments via TF-IDF nearest-neighbor search and LLM judgment. Each task pairs a writable target workspace with a read-only reference workspace mounted at a separate path.

**Multi-Round (Depth Expansion):** Extends initial queries into iterative sessions with:
1. **Evolving task specification** via a requirement tracker
2. **Round-level verification and feedback** with three interaction styles: feature extension, feature revision, and feature conflict

### 3.3 Verification and Filtering

- Each task is paired with an **agent-authored pytest suite** verified through iterative local execution
- Solutions are rolled out using Qwen3.7-Max as teacher (temperature 1.0, top-p = 0.95, 256k context)
- Trajectories accepted only if **all tests pass**; Multi-Round uses round-level selection

## Empirical Validation / Results

### Reconstruction Statistics

| Stage | Metric | Value |
|-------|--------|-------|
| Reconstructed environments | Total | 68,263 |
| Terminal environments (post-dedup) | Evaluated | 38,294 |
| SWE repositories | Evaluated | 1,900 |
| Terminal sufficiency (post-replay) | Rate | 40.2% |
| Terminal sufficiency (post-completion) | Rate | 93.5% |
| **Task-sufficient environments** | **Final** | **37,273** |

### Main Results (Table 3)

| Model | Data size | TB2.0 | TB2.1 | EvoCode MT@4 | EvoCode Case |
|-------|-----------|-------|-------|--------------|--------------|
| Qwen3.5-27B (base) | - | 41.6 | 46.2 | 6.3 | 67.8 |
| Qwen3.7-Max (teacher) | - | 69.7 | 74.5 | 39.8 | 83.4 |
| TMax-27B | 14.6k | 42.7 | 44.9 | 17.1 | 72.5 |
| RST-27B | 37.5k | 49.4 | - | - | - |
| **Terminal-Universe-27B** | **32.0k** | **52.8** | **58.1** | **20.1** | **76.1** |

### Key Ablations

**Task Re-solving (Table 4):** Intent Recovery (52.1) substantially outperforms source-trajectory SFT (36.7), confirming reconstruction is essential.

**Agentic Completion (Table 5):** Replay + completion (52.9) beats replay-only (48.7), with lower variance (±1.4 vs. ±3.5).

**Verifier Filtering (Table 6):** Matters more for harder Cross-WS tasks (55.4 with filtering vs. 53.2 without) than Single-WS (56.4 vs. 56.0).

**Breadth Expansion (Table 7):** Single-WS + Cross-WS (58.4) exceeds Single-WS alone (56.4). Cross-WS trajectories are 1.6× longer in turns, 1.9× more tool calls, with teacher pass@1 dropping from 72.3% to 49.2%.

**Depth Expansion (Table 9):** Adding Multi-Round raises MT@4 from 18.4 to 21.0; round-level verification contributes +2.2 MT@4 and +3.7 Case score.

**Data Scaling (Table 10):** Under matched budgets, environment expansion (+2.8 points) beats query expansion (+0.6) and solution expansion (+0.7).

**Cross-domain Transfer (Table 11):** SWE trajectories improve terminal performance from 47.0 to 50.0, showing the pipeline transfers across domains.

## Theoretical and Practical Implications

**For environment scaling:** Terminal-Universe demonstrates that recorded trajectories are a viable, scalable source of executable environments—a previously underexplored resource. The framework inverts the conventional direction: instead of generating environments from scratch or perturbing existing ones, it recovers them from observational data.

**For task synthesis:** The breadth (cross-workspace) and depth (multi-round) expansions reproduce routine patterns of real engineering practice. Cross-workspace tasks require agents to reconcile information across codebases, while multi-round sessions capture iterative user feedback—both are closer to real-world development than single-turn, single-repository tasks.

**For training data quality:** The comparison between source-trajectory SFT (36.7) and Intent Recovery (52.1) provides strong evidence that **regenerating demonstrations under a consistent teacher policy provides more effective supervision** than imitating heterogeneous source trajectories.

**For data budgeting:** The matched-budget ablation (Table 10) shows that collecting **more environments** is more valuable than generating more queries or solutions per environment, supporting the paper's core thesis.

**Practical considerations:** The use of standard Ubuntu 24.04 containers (rather than repository-specific images) lowers cost and simplifies deployment, though it may reduce fidelity for edge cases requiring specialized system dependencies.

## Conclusion

Terminal-Universe reframes recorded agent trajectories from fixed demonstrations into recoverable, reusable execution environments. Through deterministic replay and agentic completion, it restores latent workspace state; through four re-querying mechanisms, it scales task utility across breadth (cross-workspace) and depth (multi-round) dimensions. Empirical validation shows:

- Re-solving recovered tasks outperforms SFT on source trajectories by 15.4 points
- Verifier-selected trajectories improve Terminal-Bench 2.1 by 11.9 points and EvoCode-Bench v2 MT@4 by 13.8 points
- The pipeline scales naturally with richer source trajectories and transfers across domains

**Future directions** include: building tailored repository-specific environments, expanding beyond source trajectory coverage distributions, and using multiple teachers with independent verifier construction to mitigate single-teacher capability gaps.

---

_Markdown view of https://picx.dev/p/ECrOLN, served by PicX — AI-generated visual whiteboard summaries of research papers._
