NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Reflective Context Learning: Studying the Optimization Primitives of Context Space

Nikita Vassilyev, William Berrios, Ruowang Zhang, Bo Han, Douwe Kiela, Shikib Mehri

TL;DR

Reflective Context Learning (RCL) formalizes the process of teaching LLM agents through experience by mapping classical machine learning optimization principles—like batching, momentum, and experience replay—directly into "context space." By treating prompt and playbook updates as a systematic optimization problem rather than ad-hoc engineering, RCL achieves significant performance gains across complex coding and research benchmarks.

What Problem Does This Paper Address?

Building generally capable AI agents requires them to learn from their mistakes. While we traditionally update a model's weights to improve performance, this is expensive, prone to "catastrophic forgetting," and produces "black-box" changes. An increasingly popular alternative is context-space optimization: iteratively updating the agent’s prompts, playbooks, or memories.

However, context optimization has historically been fragmented and ad-hoc. The authors argue that the fundamental challenges of learning—such as high-variance signals, local optima, and credit assignment—don't disappear just because you're updating text instead of numbers. This paper seeks to unify these efforts into a single, principled framework that applies the hard-won lessons of classical ML optimization to the world of LLM contexts.

Methods

The authors introduce Reflective Context Learning (RCL), which structures the agent's learning loop into three stages analogous to gradient descent:

  1. Forward Pass (Execution): The agent performs a task, generating a trajectory and a reward signal.
  2. Backward Pass (Reflection): A "reflector" model analyzes the trajectory to produce a diagnostic signal ($\Delta$)—the textual equivalent of a gradient.
  3. Optimizer Step (Mutation): A "mutator" model applies these diagnostics to update the context artifact (e.g., a structured playbook).

To make this loop robust, they adapt six classical optimization primitives:

  • Batching & Grouped Rollouts: Sampling multiple tasks or running the same task multiple times to reduce noise and provide contrastive signals (comparing a "pass" to a "fail").
  • Improved Credit Assignment: A "dual-trace" system where the agent tags its own reasoning, helping the reflector identify exactly which playbook rule led to a failure.
  • Auxiliary Losses: Forcing the reflector to categorize failures (e.g., "actionable gap" vs. "intractable"), which prevents the model from just retweeting the problem without solving it.
  • Failure Replay: Maintaining a buffer of difficult tasks to ensure the agent doesn't forget how to solve old problems while learning new ones.
  • Optimizer State: A rolling document that tracks the history of edits and hypotheses, acting like momentum to stabilize the learning trajectory.
Figure 1: The RCL optimization loop with primitives mapped to stages. A batch of B tasks is sampled from D (with replay, §3.4), each executed G times (§3.1). Failed traces, with dual-trace annotations (§3.2), go to a multi-head reflector (§3.3) producing per-trace diagnostics ∆i; the mutator f turns these into structured edits to entries ei, conditioned on a rolling optimization state document (§3.5).

Datasets

The framework was evaluated on three benchmarks representing different task regimes:

  • AppWorld: A high-stakes interactive coding environment requiring precise procedural rules.
  • BrowseComp+: A web research benchmark where agents must discover general search strategies.
  • RewardBench2: A response-ranking task used to calibrate the agent's judgment.

Key Insights and Ideas

  • Functional Correspondence: The most striking "aha moment" is that concepts like Adam's momentum or sparsity regularization have direct, functional analogues in natural language. For example, structured playbook edits act as a form of structural regularization, preventing the model from making "holistic rewrites" that overfit to a single failure.
  • Precision Over Volume: The authors found that "reflection-quality" primitives (like auxiliary losses and optimizer state) often provide better returns than simply running more tasks. Diagnostic precision is the primary bottleneck, not raw execution data.
  • Non-Additivity: Primitives don't always play nice together. A technique that helps when added to a simple baseline might actually hurt when the full optimizer is already active. This suggests that "compositional roles" are more important than standalone marginal gains.
  • Regime Sensitivity: The "seed-to-ceiling gap" determines which primitives matter. In tasks where the agent is already decent (narrow gap), batching and state are crucial for fine-tuning. In tasks where the agent is lost (wide gap), strategy-focused updates and failure replay become the dominant drivers of progress.

Key Results

RCL consistently outperformed strong baselines (like ACE and GEPA) across all tested conditions.

Table 2: Main results. Each primitive is added individually to the ACE baseline. AppWorld: TGC; BrowseComp+/RewardBench2: accuracy. Lite = Gemini 3.1 Flash Lite, Nano = GPT- 5.4 Nano. All runs use Claude Opus; 30 training iterations. Deltas vs. Seed. Best result per column is in bold.
  • AppWorld: RCL achieved a +11.3 point gain in Task Goal Completion (TGC) over the unoptimized seed.
  • BrowseComp+: The framework saw gains of up to +15.7 points in accuracy.
  • Stability: The "Optimizer State" primitive proved highly effective at preventing "active instability"—where an agent solves a task in one iteration only to fail it in the next due to a conflicting prompt update.
  • Contrastive Power: On RewardBench2, "Grouped Rollouts" provided a massive +15.1 point boost over the baseline by allowing the reflector to see exactly what distinguished a correct ranking from an incorrect one under the same playbook.

Limitations and Future Work

  • Hyperparameter Sensitivity: The study held hyperparameters (like batch size and replay ratio) fixed to ensure a fair compute-matched comparison. Future work could explore adaptive hyperparameter tuning.
  • Compute Cost: Some primitives, particularly grouped rollouts, significantly increase the number of LLM calls required during the training phase.
  • Single-Seed Evaluations: Due to the extreme cost of running long-horizon agentic rollouts, the results are based on single-seed runs, though the authors attempted to mitigate this through extensive cross-benchmark analysis.
  • Continual Learning: The current work focuses on a fixed training phase; extending RCL to "always-on" learning during deployment remains an open challenge.

Summary updated

BibTeX
@inproceedings{vassilyev2026reflective,
  author = {Nikita Vassilyev and William Berrios and RUOWANG ZHANG and Bo Han and Douwe Kiela and Shikib Mehri},
  title = {{Reflective Context Learning: Studying the Optimization Primitives of Context Space}},
  booktitle = {COLM},
  year = {2026},
  url = {https://openreview.net/forum?id=ThSs8T7hid},
}
Figure