Training only on clean success traces teaches an agent what to do when everything goes well. A deployed terminal session rarely offers that guarantee.

ReTerm's October 13 paper builds recovery demonstrations and uses reinforcement learning to launch multiple attempts from the agent's own failure states. The authors report improved terminal-task success and recovery across error categories. Read the research paper.

Successful agents still need a way back

A terminal agent operates in a stateful environment. Commands change files, dependencies fail, and an apparently reasonable implementation can leave a repository partly modified. A demonstration that begins from a clean checkout and ends in success teaches one path through that environment. It may teach little about what to do after a wrong turn has changed the starting conditions. For longer tasks, recovery is therefore a capability in its own right.

ReTerm approaches self-improvement from those damaged intermediate states. Instead of treating a failed run only as a negative outcome, it asks whether the failure contains a useful place to begin another training example.

Fork the mistake rather than replay the whole task

The project builds ReTerm-10K, a dataset of recovery demonstrations for supervised fine-tuning. Its reinforcement-learning stage, ReTerm-GRPO, then forks the agent's own failure states into multiple independent recovery attempts. Success is judged by whether those attempts eventually complete the task. Branches beginning at the same failure provide a more direct comparison of repair strategies than entirely separate runs that arrive at different problems.

This design preserves the awkward context that makes recovery difficult: what has already changed, which commands failed and what evidence the environment now exposes. Starting over from a clean state would erase precisely that part of the decision problem.

The reported improvement includes recovery behaviour

Built on Qwen3.5-9B, the authors' ReTerm-9B reaches 34.8 percent Pass@1 on Terminal-Bench 2.0, a gain of 14.6 percentage points over the base model. They also report higher recovery rates across multiple error categories than standard GRPO training. These are attributed results from the preprint, not a promise about every repository or command-line environment.

The recovery analysis is especially useful because aggregate task success cannot reveal how a model improved. It might avoid more initial errors, repair failures more effectively, or do some of both. Training on branches explicitly targets the second ability, which can remain weak even when first-attempt coding improves.

The ablation isolates the recovery-oriented RL stage

On Terminal-Bench 2.0, the paper reports 20.2 percent for the base model, 25.8 after supervised training, 28.0 with standard GRPO and 34.8 with ReTerm-GRPO. The sequence helps distinguish useful recovery demonstrations from the additional effect of forking failure states during RL. It does not attribute the entire improvement to one intervention.

The training data are also split by role: six thousand trajectories support supervised learning and four thousand task instances support RL. Recovery groups are mixed with original task groups rather than replacing all ordinary practice. That design is relevant to the intended balance: an agent must continue learning how to complete tasks while improving what it does when its current attempt has already gone wrong.

A rescue must preserve useful work

Eventual completion is an important outcome, but operators also care how the system gets there. Deleting valid progress and rebuilding everything may pass a task while imposing excessive time, tool use or risk. A deployment audit should inspect unnecessary reversions, repeated failed commands and whether the agent checks its diagnosis before applying another modification. Those are suggested operational checks, not additional claims made by the reported benchmark score.

Failure states offer a curriculum that can evolve with the current policy. The corresponding limitation is that the curriculum inherits the policy's habits. Testing unfamiliar error patterns and new tools remains necessary before recovery competence can be assumed to generalise beyond the mistakes the learner already knows how to make.

References
  1. ReTerm: Recovery Training for Self-Improving Terminal Agents — arXiv preprint

Questions, news tips or corrections? Contact [email protected].

Share this article

Post to XShare on LinkedInShare on WhatsAppEmail