Get Started
Home
Topics
Search
Library
Agents · Code Generation · Sep 3, 2026

Terminal-Universe: Turning Agent Trajectories into Scalable Terminal Environments

Source: research paper via Hugging Face Daily Papers
0:00 / 7:24
Agent logs are usually mined as imitation demos, but this rebuilds the sandbox each trajectory ran in by replaying file ops, filling gaps with a completion agent, then letting a stronger teacher re-solve and grade. At matched volume, imitation drops Qwen3.5-27B to 36.7 on Terminal-Bench; re-solving lifts it to 52.1.
TL;DR
Terminal-Universe turns recorded agent trajectories into re-executable workspaces by replaying the file operations they logged, then uses an agent to fill in missing files. Fine-tuning on tasks re-solved in these rebuilt environments beats fine-tuning on the original trajectories by ~15 points on Terminal-Bench.
Why It Matters
You’re training a coding agent. You have thousands of logged sessions where past agents ran shell commands, read files, and edited code. Each log is a frozen demo: you can imitate it, but you can’t grade a new attempt, pose a harder variant, or check if the edits it made were actually correct. What you really want is the sandbox those sessions ran in, so a stronger teacher can re-solve the task and a verifier can score the result. Building those sandboxes by hand, the way Terminal-Bench does, doesn’t scale. Prior automated approaches either mine git history for bug-fix commits (SWE-Gym), inject bugs into healthy repos (SWE-Smith), or generate synthetic tasks from scratch, which tends to yield tidy toy workspaces rather than realistic code. This paper’s angle: the trajectory itself already contains enough file reads and writes to reconstruct the workspace it ran in.
How It Works
The core observation is that a trajectory’s Read, Write, and Edit tool calls implicitly describe the filesystem the agent saw. Reconstruction runs in two stages. First, deterministic replay walks the tool calls in order and, for every file the agent touched, keeps the earliest observed version. That gives you the workspace as it looked before the agent started solving, with the agent’s own edits held back so the task is unsolved. Second, agentic completion: because trajectories only expose files the agent actually opened, the replayed workspace is usually incomplete. A completion agent inspects the partial workspace and the recovered task, then creates missing supporting files and dependencies, with an explicit instruction not to implement the solution. A separate judge agent then checks whether the completed workspace has enough context for the task, and drops it if not.
On top of the recovered workspace, they generate four kinds of tasks: recovering the original user intent, synthesizing new single-workspace tasks, cross-workspace tasks that force one repo to depend on another (paired via TF-IDF retrieval plus an LLM relation judge), and multi-round sessions where a user agent poses grounded follow-ups after each round. Every synthesized task gets an agent-authored pytest verifier, and only trajectories that pass all tests are kept.
for traj in trajectories: workspace = replay_file_ops(traj) # earliest version of each file workspace = completion_agent(workspace, task) # fill missing deps if not judge_sufficient(workspace, task): continue for task in [intent_recovery, single_ws, cross_ws, multi_round]: tests = verifier_agent(task, workspace) traj_new = teacher.solve(task, workspace) if all_pass(tests, traj_new): keep(traj_new)
Core Insight
The default move when you have a pile of agent logs is to fine-tune on them directly, treating each trajectory as a demonstration. This paper shows the opposite works better. Treat the trajectory as a fossil of an environment, rebuild the environment, and have a stronger teacher re-solve the task inside it. The load-bearing evidence is a head-to-head at matched data volume: imitating the raw trajectories actually hurts the base model, while re-solving the same recovered intents lifts it substantially.
What They Found
The load-bearing result: at 35.8k matched records, training on raw source trajectories drops the base Qwen3.5-27B from 47.0 to 36.7 average on Terminal-Bench 2.1, while training on re-solved intent-recovery data lifts it to 52.1. Same tasks, same volume, different environments and different teacher. This is the finding that justifies the whole pipeline.
Secondary evidence:
•
On Terminal-Bench 2.1, the full mixture (single-workspace + cross-workspace + multi-round) reaches 58.1, a +11.9 gain over base.
•
On EvoCode-Bench v2, the multi-round benchmark, MT@4 rises from 6.3 to 20.1.
•
Agentic completion matters: replay-only environments hit 48.7, replay+completion hits 52.9 at matched volume. Deterministic replay alone leaves most workspaces missing too much context.
•
Budget allocation: given a fixed record count, doubling the number of environments beats doubling queries-per-environment or solutions-per-query. New workspaces carry new supervision; new queries on the same workspace mostly don’t.
•
Cross-workspace tasks are genuinely harder: teacher pass@1 drops from 72.3% on single-workspace to 49.2% when the task forces the agent to read a second repo.
•
Transfer: applying the pipeline to SWE-bench-style repository trajectories (rather than terminal ones) still lifts Terminal-Bench 2.1 from 47.0 to 50.0, so the reconstruction trick isn’t tied to one domain.
What’s Useful
Reach for this when you have a corpus of tool-call logs from a shipped agent and you want to turn them into training data with a real grader, not just imitation targets. The recipe: parse the logs into a file-operation stream, restore the pre-edit state of every file the agent touched, use a stronger model to fill in the surrounding project, then have that stronger model re-solve the task while a verifier checks the final workspace. The trajectories that pass become your supervised fine-tuning set. The multi-round pattern, where a user-agent poses grounded follow-ups and a private verifier scores each round before translating failures into user-visible complaints, is directly applicable to any agent product where users iterate on a persistent workspace.
The paper produces 37.3k reconstructed environments and 32.0k filtered training trajectories totaling ~1.42B tokens, built from public sources including SWE-Gym, SWE-Smith, SWE-rebench, and two public terminal-trajectory corpora. Container images are plain ubuntu:24.04 rather than repo-specific, which lowers deployment cost. The paper doesn’t specify a code or data release URL in the provided text.
Takeaway
Your agent logs aren’t demonstrations to imitate. They’re incomplete recordings of environments to rebuild. The trajectory tells you what files existed and how they started. Restore that starting state, let a stronger model try the task again, and grade the outcome. That gives you a signal a frozen log never can.
Caveats
•
The rebuilt workspace is inherently lossy. Files the original agent never opened, implicit system dependencies, and network resources leave no trace. Manual inspection of 30 completions found 8 introduced substantial extra code not needed for the task, which is noise the trainer eats.
•
One teacher model (Qwen3.7-Max) writes the tasks, the solutions, and the verifiers. Its blind spots are shared across all three roles, so a wrong solution may pass a wrong test the same model wrote. Using independent models for verification is left to future work.
•
Everything runs in a generic Ubuntu container. Repositories that need specialized system libraries, custom compilation, or repo-specific images will reconstruct with reduced fidelity, and the domain coverage is capped by whatever the source trajectory pool happens to contain (heavily Python, per the paper’s own breakdown).
Topics
Don't miss new content
Log in to follow topics and personalize your feed.
By content type
Research Paper217 episodes
AI217 episodes