MiRL: Error-Targeted Reinforcement Learning for Correcting Terminal Agent Misbehaviors
Organizations: Department of Computer Science, University of North Carolina at Chapel Hill
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.
Figures & tables
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| Parameter | Value |
|---|---|
| RL training (all recipes) | |
| Algorithm | DPPO ( Qi et al., 2026 ) |
| Policy model | Qwen3.5-4B |
| Optimizer | AdamW |
| Learning rate | , constant |
| Group size | 16 (TMax: 32) |
| # | Misbehavior | Steps | Envs. |
|---|---|---|---|
| 1 | Makes false claims about tests | 15.4% | 46.7% |
| 2 | Repeats unnecessary checks | 11.5% | 42.2% |
| 3 | Retries without fixing the cause | 11.2% | 36.5% |
| 4 | Fails to produce runnable commands | 5.1% | 19.4% |
| 5 | Kills processes without checking their identities | 4.7% | 14.0% |
| 6 | Treats guesses as facts | 2.5% | 11.0% |
| # | Long-tail error step | Environment detail |
|---|---|---|
| 1 | Uses a greedy regex that treats an entire log line as one key-value pair. | the format of the audit log |
| 2 | Starts frame counting at 1 instead of 0, shifting every 10-frame bucket. | the bucket rule |
| 3 | Replaces udb inside existing udbuf, producing udbufbuf. | the variable names in the C file |
| 4 | Extracts metric names instead of values with an incorrect awk field index. | the NAME=...VALUE=... line format |
| 5 | Reads little-endian WAV samples as big-endian integers. | the audio file |
| 6 | Rejects version 1.5.0 despite the ^1.4.2 requirement allowing it. | the version rule |
| Model | Input | Cached | Output |
|---|---|---|---|
| Qwen3.5-4B | $0.33 | $0.066 | $1.005 |
| Qwen3.8-27B | ¥3.646 | ¥0.729 | ¥21.875 |
| Gemini 3.8 Flash | $0.75 | $0.075 | $3.75 |
| Claude Opus 5 | $5 | $0.50 | $25 |
| Package | Version | Use |
|---|---|---|
| open-instruct | 7387d2f9 | RL training ( grpo_fast ) |
| DeepSpeed | 0.18.4 | RL training |
| Ray | 2.53.0 | RL training |
| PyTorch | 2.10.0 | RL training |
| Transformers | 5.4.0 | RL training |
| vLLM | 0.19.1 | Inference (bf16) |
RL for LLM Agents
Reinforcement learning for large language model agents trains models to plan, use tools, and adapt through feedback from interactive tasks.
See all 603 papers