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

Manuscript Offprint

arXiv:2608.22631

Learning Generalizable Behaviors for Terminal Agents

Yihang Yao, Bo Pang, Xuan Phi Nguyen, Ding Zhao, Shafiq Joty, Semih Yavuz

ABSTRACT

Terminal agents have emerged as a compelling application of large language models (LLMs), with the potential to integrate deeply into users' daily workflows. Reinforcement learning (RL) has become a key technique for improving their capabilities, making the scalability of training environments a central challenge. Since public real-user interaction data are scarce, synthetic environments provide a practical alternative. However, they often exhibit substantial domain gaps and limited fidelity, resulting in poor generalization. Existing efforts primarily focus on scaling the quantity and diversity of synthetic environments, while the reward signal quality is under-explored and the mechanisms that govern generalization remain poorly understood.

In this work, we study how RL improves terminal agents and propose the agentic compositional generalization hypothesis: rather than teaching the agent new domain-specific skills from scratch, RL primarily shapes high-level decision-making behaviors that compose and route the low-level skills already acquired during pre-training and supervised fine-tuning (SFT). This account is consistent with the evaluation performance we observe. This perspective suggests that verifier quality, which determines which behaviors are reinforced by providing optimization signals in RL, is more important than simply increasing the number or diversity of training environments. Motivated by this insight, we propose RIVER, a simple training recipe that improves the reward signal by filtering low-quality environments and augmenting the outcome reward with process-level behavior regularization. Using this recipe, our RL-trained agent achieves the best performance among evaluated open-source RL-trained 8B models across four terminal-agent benchmarks. Moreover, our approach generalizes across model families, scales, agent harnesses, and RL objectives. Using fewer than 30% of the TMax training environments, RIVER improves RL gains by 106% and 30% on average for models ranging from 2B to 27B on Terminal-Bench-Lite and Terminal-Bench-v2.1, respectively. Our Website: https://terminal-river.github.io/.

1 INTRODUCTION

As large language models (LLMs) continue to advance toward real-world deployment, terminal agents have emerged as one of their most important applications, enabling software engineering, system administration, and other interactive coding tasks (Anthropic, 2025; OpenAI, 2025; Pi et al., 2026; xAI, 2025; Ivison et al., 2026; Wu et al., 2026b). While the capabilities of frontier terminal agents have improved rapidly, the principles underlying the design of their training environments remain largely undisclosed (Pi et al., 2026; Ivison et al., 2026; Zhu et al., 2026). In particular, it remains unclear how post-training for terminal agents generalizes across domains, and what factors matter beyond simply increasing coverage over task categories and targeted skills.

Reinforcement learning (RL) has become the dominant paradigm for post-training reasoning models and agents (OpenAI, 2024; Guo et al., 2025). Unlike single-turn reasoning tasks such as mathematical reasoning (Shao et al., 2024), terminal agents require interacting with executable environments through long-horizon, multi-turn decision making (Gandhi et al., 2026). Consequently, the training environment plays a central role in agentic RL. Since large-scale real-user interaction data are generally unavailable, recent work has increasingly relied on synthetic environments as a scalable alternative (Pi et al., 2026; Li et al., 2026).

Existing work on synthetic terminal environments has primarily focused on scaling coverage: expanding the diversity of tasks, domains, and required skills (Pi et al., 2026; Fan et al., 2026; Zhao et al., 2026). Early efforts generated demonstration trajectories for supervised fine-tuning (SFT), whereas more recent work constructs executable environments for RL. For example, Endless-Terminals (Gandhi et al., 2026) demonstrated that RL over synthetic environments substantially improves terminal agents, and TMax (Ivison et al., 2026) further increased environment diversity and domain coverage. However, coverage alone does not explain generalization. This raises two fundamental questions: (i) What does RL actually learn during terminal-agent training? (ii) What makes one training environment more valuable than another, aside from diversity, for improving generalization beyond the synthetic training-task distribution?

In this work, we study these questions through the lens of the compositional generalization hypothesis (Yuan et al., 2026; Kong et al., 2026), extending it from single-turn reasoning models to multi-turn long-horizon agentic models. We term the resulting account agentic compositional generalization (see Fig. 1 for an overview), and test it in realistic terminal environments rather than purely synthetic ones. Our findings indicate complementary roles of SFT and RL in generalization: SFT (and general model prior imposed by pre-training and mid-training) primarily equips the agent with low-level atomic skills, while RL primarily shapes high-level decision-making behaviors that compose, route, and coordinate these skills across domains. Under this hypothesis, generalization requires both coverage on atomic skills and reusable high-level behaviors.

This perspective suggests a different axis for the design of the training recipe. For skills, since RL is not efficient in learning atomic skills, then SFT should equip the models with diverse atomic skills that are absent from model priors. For behaviors, since RL primarily learns high-level behaviors, then verifiers in synthetic environments, which provide the signal that shapes those behaviors, become critical. Guided by this insight, we propose RIVER, a simple yet effective training recipe that filters out low-quality environments and improves verifier quality through behavior-level regularization. Despite using fewer than 30% of the TMax training environments, RIVER consistently improves RL efficiency and generalization across model families, model scales, agent harnesses, and RL algorithms.

Our contributions are summarized as follows:

(1) Mechanistic interpretation. We propose agentic compositional generalization, which posits that RL improves generalization by shaping reusable high-level behaviors that compose pre-RL domain atomic skills, and we present empirical evidence consistent with its predictions.

(2) A simple and effective training recipe. We introduce RIVER, which improves the quality of reward signal and the training efficiency. Using fewer than 30% of the TMax environments (Ivison et al., 2026), RIVER achieves on average 106% and 30% larger RL gains on Terminal-Bench-Lite and Terminal-Bench-v2.1, respectively, across models ranging from 2B to 27B.

(3) Comprehensive empirical analysis. We provide extensive experiments that test the predictions of our hypothesis and offer new insights into the learning dynamics of RL for terminal agents.

References (80)