Offline RL for Language Agent Training From Logged Trajectories

Offline RL trains language agents from logged data without costly live interactions.

Cover illustration for “Offline RL for Language Agent Training From Logged Trajectories”
Written by
Anjali RaghunathanSenior Staff Writer
Published
October 18, 2026
Reading time
8 min read
Sources cited
8 sources ↓

Offline RL for language agents uses logged trajectories as training data without the need for fresh environment interactions. It separates data collection from policy optimization. With the right data and objectives, keeping these activities separate makes it possible to train agents where live rollouts cost too much, are unstable, or are unavailable.

Why online RL is expensive and unstable for language agents

Every online RL training step requires LLM inference and environment interaction. For a code agent, that means generating a program, executing it, and verifying the result before the experience can inform an update. Multi-turn tasks add to this cost because credit has to be assigned across many interaction steps. Generating fresh rollouts for each update makes the expense grow with the length of the trajectory.

Execution time also affects what the agent learns. Yang et al. describe ML engineering agents whose action execution times vary enormously across solutions within the same task. Those differences create asynchronous gradient update problems that bias the policy toward faster but suboptimal solutions. The FPA paper identifies further instability, including reward collapse and divergence, while simultaneous inference and training create a substantial computational bottleneck.

ArCHer's 2024 results show that existing on-policy methods for multi-turn tasks need about 100x more samples than off-policy methods do. This gap matters when interactions are hard to get, as with historical tool-use records and embodied agent trajectories collected in the field. Those records may still be on hand when the environment cannot support live training.

What offline RL for language agents actually does

Offline RL starts with a static dataset of experiences collected before training begins. For language agents, these experiences hold prompts, generated actions or programs, and the rewards that go with them. The policy is optimized entirely from that data, without further interaction with the environment.

The logged material can take several forms, including tool calls, dialogue turns, reasoning chains, code submissions, and embodied action sequences. What connects them is a trajectory with an outcome signal that can guide learning. Training uses those records to improve decisions. Yang et al.'s modularized RL survey places offline methods within a much wider menu of algorithms than the PPO/GRPO methods that dominate current LLM pipelines.

The defining constraint is that offline policy updates stay close to the behavioral distribution represented in the data. Online methods can explore and gather evidence about new behavior, but offline methods have to use the evidence they already have. Supervised fine-tuning on successful trajectories is the degenerate offline case because it discards reward structure and imitates the selected examples. Offline RL instead preserves the reward signal to distinguish better from worse behavior within the fixed dataset. That distinction allows learning from more than demonstrations of success.

Four algorithmic approaches and what each one solves

Assigning credit is difficult when a long trajectory receives only a final reward. DPO and preference-tuning methods treat tokens uniformly, which limits their effectiveness when only some steps determine the outcome. OREO, or Offline REasoning Optimization, uses the soft Bellman equation to learn a policy and a value function at the same time. This lets it assign credit across steps without the need for pairwise preference data. OREO at ACL 2025 reports results on GSM8K, MATH, and ALFWorld that surpass existing offline learning methods, with up to a 17.9% relative improvement over greedy decoding on MATH.

Even with better credit assignment, updating a large language model still has a cost. Retrospex avoids that cost by keeping the LLM frozen and adding a critic trained offline. It combines the LLM's action likelihood with action values from a recurrent Q-network trained through Implicit Q-Learning on collected trajectories. The critic adds no extra context tokens, so incorporating experience does not require placing more of it in the prompt. The Retrospex paper reports success-rate gains over the imitation-learned base of 9 points in ScienceWorld, 3.5 points in ALFWorld, and up to 5 points in Webshop.

A separate critic is not the only way to make offline learning more practical. When the reward signal is relatively clean, reward-weighted fine-tuning addresses the statistical inefficiency of standard policy gradient with a simpler formulation. It recasts RL as a form of SFT using standardized rewards and can use the same training tools. It needs little infrastructure and avoids the need for a more elaborate value-learning architecture. This makes it a useful lower bound for comparison, especially when high-quality data already makes it clear which behavior is good and which is bad.

Clean rewards alone do not solve the problem of shared tokens in long reasoning chains. Correct and incorrect solutions can overlap substantially, so penalizing a wrong trajectory can also suppress tokens needed by a correct one. Future Policy Approximation, or FPA, addresses this gradient entanglement by weighting gradients with an estimate of the future policy. It computes that estimate through logit-space extrapolation, acting before over-penalization has already occurred.

The FPA paper evaluates three models from the Qwen and Llama families across seven math benchmarks and three code-generation benchmarks. It reports consistent improvements over DPO, RPO, KTO, and vanilla offline RL, with accuracy comparable to GRPO and DAPO at a fraction of the GPU hours. Together, the four approaches form a coherent toolkit whose choice depends on the failure mode in the task and data. No single method resolves all of them.

Diagram: Four Offline RL Approaches: What Each One Solves. Visualizes: Show four named offline RL methods arranged by the specific failure mode each addresses.

Why dataset quality determines what offline RL can achieve

Algorithms determine how the policy learns, but the fixed dataset bounds what it can learn from. Expert data can make behavior cloning a sufficient baseline because the desired behavior is already well represented. Mixed or low-quality data calls for methods that can stitch useful behavior together across trajectories. Random or biased data can actively mislead the policy, regardless of how much training it receives. Reward fidelity, trajectory coverage, and the composition of the logs are therefore central constraints.

Practitioners often lack knowledge of a dataset's provenance or skill composition before training. That makes it hard to predict whether imitation will suffice or whether reward-aware learning must separate useful behavior from poor examples. Bellman-Wasserstein Distance, or BWD, provides a diagnostic signal by quantifying the behavioral policy's deviation from random actions. Using BWD as a regularization term during training has also been shown to improve policy outcomes. BWD allows dataset quality to be examined before policy optimization.

Most logged agent runs fail, and pipelines that retain only successes discard the majority of available trajectories. AgentHER (2026) applies hindsight experience replay to recover signal from those failures by relabeling them with achievable hindsight goals. It produces SFT/DPO/ShareGPT datasets without additional environment interactions, substantially expanding the effective training corpus.

CoREN on VirtualHome uses an adaptive ensemble of spatio-temporally consistent rewards to derive domain-grounded rewards from training datasets. It achieves performance comparable to LLM-based agents with far larger parameter counts using a policy network of only 117M parameters. In this case, a better reward signal can substitute for model scale. Together, CoREN and AgentHER show that the central data question concerns both what behavior the logs cover and how faithfully their rewards describe useful outcomes.

The model degradation risk that naive offline training introduces

Poor offline training can do more than leave performance unchanged. Prolonged training under standard objectives can degrade a language model's capabilities, with damage that remains quiet until an abrupt collapse. Even when an outcome label is correct, a token-level update can push the model in the wrong direction.

Gradient entanglement explains how that reversal can occur. When correct and incorrect trajectories share tokens, updates that penalize incorrect trajectories can lower the log-probabilities of both groups together. With extended training, the log-probability of correct trajectories can eventually fall below that of incorrect ones. The FPA paper documents this failure on Llama-3.2-3B-Instruct, where naive offline RL for mathematical reasoning produces an abrupt accuracy collapse mid-training. FPA maintains stable training throughout the same reported setting.

Any long-horizon trajectory with token overlap between good and bad outcomes is susceptible to this risk. Online RL has an analogous instability in reward collapse, but it can recover by generating new on-distribution data. Offline training cannot replenish its evidence that way because its dataset is fixed. Consequently, careful monitoring and early stopping help prevent accuracy collapse, and the objective function affects training safety. FPA, OREO, and reward-weighted variants tackle weaknesses that make naive optimization unsafe at scale, but each does so in a different way.

This warning does not argue against offline RL. More passes over logged data alone cannot be counted on to make an agent better. A suitable objective must account for how reward information affects the policy.

Where offline RL fits in a training pipeline and where it does not

Offline RL fits most reliably when the model already has a strong behavioral foundation or when live environment access is genuinely unavailable. After SFT, it can sharpen reward-aligned behavior without requiring rollouts. Historical enterprise interactions, including customer service, code review, and tool use, offer another fit when outcomes are known but the interactions cannot be regenerated. Physical robotics and clinical decision support also make the cost or danger of live rollouts central to the placement decision.

Diverse logged data can support multi-task transfer as well. The CodeNet offline code RL experiments evaluate the resulting policy on unseen benchmarks, illustrating the value of training across tasks. Offline RL cannot iteratively discover increasingly complex reasoning paths through fresh exploration, so it cannot reproduce the self-improvement dynamic associated with online RLVR and emergent reasoning in online-trained models.

Meta/FAIR's 2025 study finds that online and semi-online variants strongly outperform offline methods across verifiable math and non-verifiable instruction following. It also reports substantially higher AlpacaEval LC winrate and ArenaHard score for online DPO than for standard DPO. Online methods have the advantage when environment interaction is cheap and stable, while offline RL matters most when that condition fails.

The two approaches can also be sequenced. A*-PO (Brantley et al., 2025) first estimates the optimal value function offline, then uses a simple regression loss for on-policy updates requiring only a single generation per prompt. ArCHer takes a related approach to multi-turn tasks by training a high-level off-policy value function over utterances at the same time as a low-level token-by-token policy. This links off-policy value estimation with online policy improvement and uses samples far more efficiently than on-policy methods do.

The sequence can run in the opposite direction too. ALIGN-GAP at ICLR 2025 uses scarce offline behavior data to align a well-trained online agent to human preferences, while curriculum-based preference learning keeps it from unlearning what it knows about the environment. Offline RL earns its place not by matching online methods in general, but by enabling training that would otherwise not happen at all.

Methodology & sources

  1. Published as a conference paper at ICLR 2025

    Provided the basis for the ALIGN-GAP method described at the end of the article, which uses offline behavior data to align a well-trained online agent to human preferences.

  2. Modularized Reinforcement Learning on LLMs: From MDP Creation to Exploration and Learning

    Provided the framing of offline methods within a broader menu of RL algorithms beyond PPO/GRPO for LLM pipelines.

  3. ArCHer: Training Language Model Agents via Hierarchical Multi-Turn RL

    Supplied the statistic that on-policy methods for multi-turn tasks need about 100x more samples than off-policy methods, and described ArCHer's hierarchical approach combining off-policy value estimation with online policy improvement.

  4. Future Policy Approximation for Offline Reinforcement Learning in LLM Reasoning

    Provided details on Future Policy Approximation, including its gradient entanglement problem, logit-space extrapolation fix, evaluation across math and code benchmarks, and the documented accuracy collapse on Llama-3.2-3B-Instruct.

  5. Offline Reinforcement Learning for LLM Multi-step Reasoning

    Provided the OREO results on GSM8K, MATH, and ALFWorld benchmarks, including the reported 17.9% relative improvement over greedy decoding.

  6. [2411.17135] LLM-Based Offline Learning for Embodied Agents via Consistency-Guided Reward Ensemble

    Provided the CoREN result on VirtualHome showing that a 117M parameter policy with better reward signals can match LLM-based agents with far larger parameter counts.

  7. AgentHER: Hindsight Experience Replay for LLM Agent Trajectory Relabeling

    Described AgentHER's application of hindsight experience replay to recover signal from failed trajectories by relabeling them with achievable hindsight goals.

  8. Reinforcement Learning for Machine Learning Engineering Agents

    Supplied the observation about ML engineering agents whose action execution times vary enormously, creating asynchronous gradient update problems that bias the policy toward faster but suboptimal solutions.

Anjali Raghunathan

Senior Staff Writer

Anjali spent six years as an infrastructure engineer on a large-scale RL training team, where she built the rollout schedulers and sandboxed execution harnesses that kept thousands of concurrent environment instances alive. She now writes about the systems layer of agent post-training, with particular attention to the gap between a training run that completes and one that actually taught the policy something.