arXiv:2610.35697cs.LGOct 2026

Manuscript Offprint

arXiv:2610.35697

MiRL: Error-Targeted Reinforcement Learning for Correcting Terminal Agent Misbehaviors

Runchu Tian, Zaid Khan, Zun Wang, Justin Chih-Yao Chen, Mohit Bansal

Abstract

Error-targeted learning gives a legible way to improve a model: identify specific weaknesses of the model, train the model to fix these weaknesses, and check whether the weaknesses are fixed. We study how to apply error-targeted learning to terminal agents, which solve long-horizon tasks specified in natural language by interacting with a command shell. Existing error-targeted methods are designed for single-turn tasks, and existing analyses of agent failures are used to evaluate and debug agents rather than to train them. We propose Misbehavior-driven RL (MiRL), which first profiles the errors of a policy to find generalizable misbehaviors: kinds of wrong steps that recur across many environments. MiRL then trains the policy with RL, starting rollouts at the steps where these misbehaviors occur and rewarding a rollout only if it passes the tests and avoids the misbehavior. On Qwen3.5-4B, eight misbehaviors account for 52.1% of wrong steps. After training with MiRL, the policy repeats the measured misbehaviors 43% to 57% less often on average on unseen prefixes. MiRL outperforms TMax-4B on Terminal-Bench Lite (51.8% vs. 47.4%) and matches it on Terminal-Bench 2.1 (21.3% vs. 20.6%), while using 35% of its rollouts. These results show that error-targeted learning can be applied to realistic, long-horizon terminal tasks. 1^{1}

1 Introduction

Error-targeted learning finds the errors a model makes and trains the model to stop making those errors (Khan et al., 2025; Lee et al., 2024). This approach is desirable because it makes model improvement easy to understand, as each training example is tied to some named error, and after training we can check whether that error becomes less frequent. For LLM agents, prior work has built taxonomies of agent errors (Cemri et al., 2025; Zhu

(a) A few error types dominate the distribution

Figure

(b) MiRL: a misbehavior-driven RL recipe

Figure

(c) Empirical results: data-efficient terminal agent training

Figure

Figure 1: Overview of MiRL. (a) A few generalizable misbehaviors account for a large share of error steps. (b) MiRL starts rollouts from misbehavior prefixes and rewards rollouts that pass the tests and avoid the misbehavior. (c) MiRL matches or outperforms TMax-4B using 35% of its rollouts. TB-Lite and TB-2.1 denote Terminal-Bench Lite (OpenThoughts-Agent team et al., 2026) and Terminal-Bench 2.1 (Merrill et al., 2026).

et al., 2026b) and methods that locate the step at which an agent fails (Zhang et al., 2025, 2026b). These analyses are mostly used to evaluate and debug agents, not to decide what the agent trains on. Terminal agents (Bin et al., 2026; Liu et al., 2026) are typically instead trained by scaling the number of training environments (Pi et al., 2026; Gandhi et al., 2026; Wu et al., 2026; Ivison et al., 2026); for example, one TMax training run samples from 14.6K environments and takes two to three days on eight H100 nodes (Ivison et al., 2026). To our knowledge, error-targeted learning has not been applied to terminal agents.

Applying error-targeted learning to terminal

1^{1}Project page: github.com/runchu-tian/MiRL agents is not straightforward. Existing error-targeted methods work on and are designed for single-turn problems: when the model answers a problem incorrectly, these methods generate similar problems for training. A terminal agent takes dozens of steps per task, and a failed task is often caused by one or two wrong steps, such as reporting that the tests pass without running them. This creates two difficulties. First, many wrong steps are specific to one task, so fixing them one at a time does not help on other tasks; training should instead target generalizable misbehaviors, kinds of wrong steps that recur across many tasks. Second, training from the start of a task spends most rollouts on steps the agent already performs correctly, and the agent may never reach the state where the misbehavior occurred. We therefore ask: (1) how can we identify the generalizable misbehaviors of a terminal agent, and (2) how can we train the agent directly at the steps where they occur?

We answer these questions by connecting two tools: step-level error analysis of agent trajectories and RL from intermediate states. To answer the first question, we run error analysis on the policy we are about to train, which we call error profiling (Figure 1(a)). We roll out the policy on 2,017 environments from TMax's environment set (Ivison et al., 2026); an error localizer flags wrong steps, a teacher model corrects each flagged step so that the rollout can continue and reveal later errors, and an annotator model groups the wrong steps into error types. Eight error types, such as “Makes false claims about tests” and “Fails to produce runnable commands”, cover 52.1% of all wrong steps and appear in 75.4% of the environments; we treat these as the generalizable misbehaviors to target. To answer the second question, we introduce MiRL, a misbehavior-driven RL recipe (Figure 1(b)). MiRL builds on two known techniques, starting rollouts from intermediate states (Xi et al., 2024; Yi et al., 2026) and providing reward signals beyond the binary verifier outcome (Lightman et al., 2024; Gunjal et al., 2026), each guided by the error profiling outputs. Each group of rollouts starts at a misbehavior prefix, the part of a trajectory just before a misbehavior step, and a rollout receives reward only if it passes the tests and a behavior judge confirms that it avoids the misbehavior of that prefix. To start from a prefix, MiRL restores the container by rerunning the prefix’s commands in a fresh container and keeps the prefix only if every command returns the recorded output.

We train Qwen3.5-4B (Qwen Team, 2026a) with MiRL using TMax's RL recipe and evaluate on Terminal-Bench Lite (OpenThoughts-Agent team et al., 2026) and Terminal-Bench 2.1 (Merrill et al., 2026). On held-out prefixes, MiRL reduces the rate of the measured misbehaviors by 43% to 57% on average, measured by two behavior judges. MiRL also improves task performance: with the same number of training environments (189), MiRL outperforms TMax-189 (the TMax recipe trained on the same number of environments), PivotRL (Yi et al., 2026), and a form of RaR (Gunjal et al., 2026) enhanced with outcome rewards (RaR+), by at least 4.2 points on Terminal-Bench Lite and 2.2 points on Terminal-Bench 2.1. MiRL also outperforms TMax-4B, the released checkpoint trained with the full TMax recipe, which samples from 14.6K environments, on Terminal-Bench Lite (51.8% vs. 47.4%) and matches it on Terminal-Bench 2.1 (21.3% vs. 20.6%), while using 35% of its rollouts. Ablations show that starting from misbehavior prefixes and adding the behavior reward each contribute (7.9 and 6.5 points on Terminal-Bench Lite). These results show that error-targeted learning applies to terminal agents when training targets generalizable misbehaviors directly at the steps where they occur.