Sample-Efficient Learning from Agent Experience

Chenhui Gou, Haoqin Tu, Yunhao Fang, Jianfei Cai, Hamid RezatofighiarXiv 2026

TL;DR

This paper introduces Experience Distillation, a highly sample-efficient framework that permanently bakes an agent's temporary trial-and-error in-context learning gains into its model weights. By utilizing a model-free, one-step branch rollout strategy, the method achieves performance competitive with traditional reinforcement learning baselines while requiring up to $57\times$ fewer environment interactions.

What Problem Does This Paper Address?

Training autonomous language agents using traditional Reinforcement Learning (RL) algorithms (like PPO or GRPO) is notoriously sample-inefficient. It often requires thousands of costly, time-consuming environment interactions—such as executing code, running software tests, or receiving human feedback.

In-Context Learning (ICL) offers a shortcut: an agent can instantly improve its behavior by simply conditioning on its own history of mistakes and successes within its prompt context. However, these gains are fleeting; as soon as the interaction history is removed from the context window, the agent reverts to its baseline performance. While context distillation can theoretically internalize this contextual knowledge into model parameters, standard approaches require running the teacher model through the environment all over again or relying on highly inaccurate, error-prone world models.

The authors tackle this dilemma by asking: How can we permanently consolidate an agent's in-context experience into its weights without incurring any additional environment costs?

Methods

The authors propose Experience Distillation (EPD), a trajectory-level context distillation technique that requires zero extra environment samples and completely bypasses the need for a world model.

Instead of simulating long, speculative future trajectories where errors compound exponentially, EPD uses a 1-Step Branch Rollout. The algorithm samples real history points directly from previously collected agent trajectories. An experience-conditioned "teacher" model is then asked to predict only the very next action at that specific history point.

To turn this concept into a practical training pipeline, the authors introduce three key engineering components:

  1. Experience Preprocessing: Raw agent histories are often long and noisy. The framework rewrites, abstracts, or summarizes these trajectories to concentrate task-relevant information before feeding them to the teacher.
  2. Enhanced Teacher Reasoning: The teacher is explicitly prompted to generate thorough, multi-token chains of thought before outputting its final action, which significantly improves the quality of the distilled targets.
  3. Branch Packing: Rather than treating every single history point as an isolated training sequence (which is computationally redundant), successive branch points from the same trajectory are packed into a single training sequence to maximize training throughput.

Datasets

The authors evaluated EPD across two challenging, long-horizon domains:

  • 749 Curated Software-Engineering (SWE) Tasks: A benchmark requiring the agent to inspect code repositories, execute terminal commands, run tests, and iteratively refine code patches based on real compiler and verifier feedback.
  • TaleSuiteJericho: A suite of six text-adventure games (Balances, Detective, Enter, Inhumane, Library, and Reverb) that demand natural language understanding, state tracking, and strategic planning.
  • Out-of-Distribution (OOD) SWE Tasks: A separate evaluation set of 494 unseen software engineering tasks (split into cross-repository and within-repository shifts) to test the agent's generalization capabilities.

Key Insights and Ideas

  • Direct Supervised Fine-Tuning (SFT) Fails: Simply training a model to mimic successful trajectories via standard SFT yields virtually no improvement (recovering only 3.8% of ICL gains on SWE tasks). SFT forces the model to memorize actions without understanding the context that made them correct. EPD succeeds because the student learns from a teacher that has access to the full trial-and-error history.
  • The Power of One Step: Bypassing a world model entirely and limiting rollouts to a single step prevents error propagation. This model-free simplification makes distillation robust and highly effective for text-based agents.
  • Weights as Permanent Knowledge Accumulators: The authors show that Experience Distillation can operate in a continual loop. An agent can practice a task in-context, distill that experience into its weights, clear its context window, and repeat. Baseline performance climbs steadily across cycles, proving that model weights can successfully accumulate experiential knowledge over time.

Key Results

  • Matching RL with a Fraction of the Data: On software engineering tasks, ICL followed by EPD matched the performance of a PPO baseline while using 9.6$\times$ fewer environment samples. On text-adventure games, it matched a GRPO baseline using 57.2$\times$ fewer samples.
Figure 1: Environment-sample efficiency of ICL followed by Experience Distillation (ICL + EPD) and RL baselines. Left: average pass@1 on 749 curated SWE tasks; right: average normalized score on six TaleSuite tasks, both versus average environment samples per task. RL points pair the best observed performance with the complete run budget. Arrows show gains from zeroshot, and brackets compare the ICL + EPD and RL sample budgets. The x-axis uses a log(1 + x) transform, with tick labels in the original sample counts.
  • Retaining In-Context Gains: EPD successfully retained 64.8% of the performance gains achieved by full in-context learning on the SWE benchmark, and an impressive 93.4% on TaleSuite games.
  • Strong OOD Generalization: When tested on the 494 unseen OOD software engineering tasks, the EPD-trained model nearly doubled the zero-shot pass@1 rate (from 4.62% to 8.84%), proving that it distilled generalized problem-solving capabilities rather than just memorizing specific solutions.
  • Successful Continual Learning: Over 5 sequential collect-and-distill cycles on TaleSuite, the agent's mean score progressively increased from 7.1% to 47.0%, demonstrating successful knowledge accumulation.
Figure 2: Continual Experience Distillation on six TaleSuite tasks. Cycle 0 is the initial checkpoint; each subsequent cycle collects four repeated trials per task and performs one distillation update.

Limitations and Future Work

  • Teacher Generation Cost: While EPD drastically cuts down on environment samples, it shifts the bottleneck to inference compute. Generating high-quality teacher targets with long reasoning chains across millions of tokens is computationally expensive.
  • The Distillation Gap: EPD does not fully recover 100% of the in-context learning performance on the more complex software engineering tasks (~65% retention). Closing this remaining gap is a key area for future research.
  • Future Directions: The authors suggest exploring more efficient teacher target generation methods and integrating EPD into lifelong learning autonomous agent loops.

Summary updated

BibTeX
@misc{gou2026sample,
  author = {Chenhui Gou and Haoqin Tu and Yunhao Fang and Jianfei Cai and Hamid Rezatofighi},
  title = {{Sample-Efficient Learning from Agent Experience}},
  year = {2026},
  eprint = {2607.21051},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.21051},
}
Figure