Internalizing Agency from Reflective Experience

Rui Ge, Yichao Fu, Yuyang Qian, Junda Su, Yiming Zhao, Peng Zhao, Hao ZhangarXiv 2026

TL;DR

Prevailing post-training methods for LLM agents make them better at reproducing a narrow set of already-successful behaviors, but fail to teach them how to recover from mistakes. To fix this, the authors introduce LEAFE, a framework that generates a tree of "rollback and correct" trajectories during training and distills these corrections directly into the model's weights. This allows the agent to intrinsically internalize error-recovery agency without needing expensive test-time search or explicit reflection prompts.

What Problem Does This Paper Address?

When Large Language Models (LLMs) act as autonomous agents—navigating webs, writing code, or solving multi-step puzzles—they rarely get everything right on the first try. Success requires agency: the ability to execute a sequence of actions, observe environment feedback (like compiler errors or invalid moves), and correct course.

Currently, the standard way to fine-tune these agents is via outcome-based Reinforcement Learning with Verifiable Rewards (RLVR), such as GRPO. However, RLVR only optimizes for a final scalar success/failure signal. This ignores the rich, structured feedback provided by the environment during the task and leads to distribution sharpening—the model gets highly optimized at exploiting a narrow set of paths it already knows how to solve (boosting Pass@1), but its overall problem-solving capacity boundary (Pass@k) plateaus.

Methods

The authors propose LEAFE (Learning Feedback-Grounded Agency from Reflective Experience), a two-stage framework designed to turn environment feedback into actionable, internalized weight updates.

Figure 2. Illustration of the LEAFE framework. Stage 1: During experience collection, the assistant periodically reviews the current trajectory and identifies a suboptimal round (denoted as red-colored τ). It then produces the actionable experience e, which is concatenated with the restored history to facilitate subsequent attempts. Stage 2: During experience distillation, the model optimizes a joint loss using two datasets: randomly sampled rehearsal pairs to maintain capabilities, and counterfactual pairs (original prompts paired with experience- improved actions) to internalize diverse exploration. For simplicity, we depict one branching event from the rollback exploration tree.
  1. Stage 1: Tree-Based Experience Generation with Rollback During exploration, the agent interacts with the environment. Periodically, or upon failure, it pauses to reflect on its history, identifies a specific suboptimal decision point ($\tau$), and generates a natural language diagnosis and fix instruction ($e$). The environment is then rolled back to step $\tau$, and the agent attempts a revised action guided by $e$. This iterative process forms a "rollback tree" of alternative, corrected paths.

  2. Stage 2: Experience Distillation To avoid relying on heavy natural language prompting or explicit reflection at test time, LEAFE distills this trial-and-error experience directly into the model parameters using a dual-loss objective:

  3. Experience-to-Policy Distillation ($\mathcal{L}_{cf}$): This is the core innovation. The model is trained to predict the corrected action ($a'_\tau$) given only the original history ($h_\tau$), completely omitting the explicit natural language experience prompt ($e$). This forces the model to internalize the recovery mechanism.

  4. Behavior Rehearsal ($\mathcal{L}_{reh}$): Standard supervised fine-tuning (SFT) on successful trajectories to ensure the model maintains its baseline task-solving competence and avoids catastrophic forgetting.

Datasets

LEAFE was evaluated across five diverse, long-horizon benchmarks requiring strategic interaction and mistake recovery:

  • WebShop: Online shopping navigation involving multi-hop search and attribute matching.
  • ALFWorld: Text-based embodied household tasks requiring common-sense reasoning.
  • ScienceWorld: Multi-step text-based scientific experimentation.
  • Sokoban: A planning-intensive grid puzzle where pushing a box into a corner requires rolling back.
  • CodeContests: Competitive programming with execution-based test-case verification.
  • MBPP (Mostly Basic Python Problems): Used exclusively as a held-out dataset to evaluate Out-of-Distribution (OOD) generalization.

Key Insights and Ideas

  • Internalizing the Prompt: Traditional methods like Reflexion or Tree of Thoughts rely on heavy test-time prompting or external search algorithms to fix mistakes, which increases latency and deployment complexity. LEAFE proves that this error-correction capability can be compiled directly into the model's weights.
  • Expanding the Capability Boundary: While outcome-driven RL (like GRPO) effectively sharpens greedy precision (Pass@1), it fails to expand the model's fundamental capability ceiling. LEAFE explicitly exposes the model to its failures and teaches it how to repair them, significantly lifting the Pass@k scaling curve.
  • True Agency Generalizes Better: Because LEAFE teaches a fundamental behavioral trait (reflecting and correcting) rather than just memorizing successful trajectories, it avoids overfitting to dataset-specific shortcuts.

Key Results

  • Substantial Pass@k Gains: LEAFE consistently achieved higher performance ceilings at large sample budgets ($k$). Most notably, on CodeContests, LEAFE improved Pass@128 by up to 14% over the base model, significantly outperforming GRPO.
Scaling results (Pass@k) across different benchmarks
  • Superior Out-of-Distribution (OOD) Robustness: When models trained on CodeContests were evaluated on the held-out MBPP benchmark, GRPO suffered a severe performance drop (up to -4.2%). In contrast, LEAFE mitigated this degradation and actually surpassed the base model's performance (+1.3% to +1.8%), proving it learns generalized troubleshooting skills.

Limitations and Future Work

  • Dependence on Rich Feedback: LEAFE is most effective when the environment provides clear, diagnostic feedback (e.g., compiler errors or explicit state changes). Its benefits may diminish in environments where feedback is weak, ambiguous, or heavily delayed.
  • The Environment Reset Assumption: The framework assumes that the environment can be reliably and deterministically reset to a specific rollback point. This is straightforward in code execution or simulated games, but presents a major challenge for non-deterministic, stateful, or real-world physical deployments.

Summary updated

BibTeX
@misc{ge2026internalizing,
  author = {Rui Ge and Yichao Fu and Yuyang Qian and Junda Su and Yiming Zhao and Peng Zhao and Hao Zhang},
  title = {{Internalizing Agency from Reflective Experience}},
  year = {2026},
  eprint = {2603.16843},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.16843},
}
Figure