Reflective Context Learning: Studying the Optimization Primitives of Context Space
Organizations: Contextual AI
Abstract
Generally capable agents must learn from experience in ways that generalize across tasks and environments. The fundamental problems of learning, including credit assignment, overfitting, forgetting, local optima, and high-variance learning signals, persist whether the learned object lies in parameter space or context space. While these challenges are well understood in classical machine learning optimization, they remain underexplored in context space, leading current methods to be fragmented and ad hoc. We present Reflective Context Learning (RCL), a unified framework for agents that learn through repeated interaction, reflection on behavior and failure modes, and iterative updates to context. In RCL, reflection converts trajectories and current context into a directional update signal analogous to gradients, while mutation applies that signal to improve future behavior in context space. We recast recent context-optimization approaches as instances of this shared learning problem and systematically extend them with classical optimization primitives, including batching, improved credit-assignment signal, auxiliary losses, failure replay, and grouped rollouts for variance reduction. On AppWorld, BrowseComp+, and RewardBench2, these primitives improve over strong baselines, with their relative importance shifting across task regimes. We further analyze robustness to initialization, the effects of batch size, sampling and curriculum strategy, optimizer-state variants, and the impact of allocating stronger or weaker models to different optimization components. Our results suggest that learning through context updates should be treated not as a set of isolated algorithms, but as an optimization problem whose mechanisms can be studied systematically and improved through transferable principles.
Figures & tables
| Classical Concept | RCL Analogue | Prior Work |
|---|---|---|
| Parameters | Context artifact (playbook, memory, tools, guidelines) | All methods below |
| Forward pass | Trajectory | ReAct ( Yao et al., 2023 ) ; Voyager ( Wang et al., 2023 ) |
| Loss | Outcome signal | — |
| Gradient | Reflective diagnostic | ProTeGi ( Pryzant et al., 2023 ) ; TextGrad ( Yuksekgonul et al., 2024 ) |
| Optimizer step | Context update | ACE ( Zhang et al., 2026 ) |
| Minibatch | Trajectory batch per reflection step | ProTeGi ( Pryzant et al., 2023 ) ; TF-GRPO ( Cai et al., 2025 ) |
| Primitive | Stage | Pathology | Prior Work |
|---|---|---|---|
| Batching | Execution | High variance from single samples | ProTeGi; TF-GRPO |
| Grouped Rollouts | Execution | Confounded attribution | TF-GRPO |
| Credit Assignment | Reflection | Sparse terminal reward | TextGrad |
| Auxiliary Losses | Reflection | Surface-level diagnostics | — |
| Failure Replay | Sampling | Forgetting learned tactics | Dyn. Cheatsheet; ExpeL |
| Optimizer State | Mutation | Oscillation from stateless updates | ERM; OPRO |
| AppWorld | BrowseComp+ | RewardBench2 | ||||||
| Normal | Challenge | Test Set | Test Subset | |||||
| Lite | Nano | Lite | Nano | Lite | Nano | Lite | Nano | |
| Baselines | ||||||||
| Seed | 78.0 | 81.5 | 64.3 | 75.8 | 28.9 | 40.7 | 75.9 | 67.2 |
| GEPA | 82.7 +4.7 | 76.2 -5.3 | 62.6 -1.7 | 66.7 -9.1 | 35.3 +6.4 | 48.7 +8.0 | 79.2 +3.3 | 76.5 +9.3 |
| ACE | 83.3 +5.3 | 86.9 +5.4 | 69.1 +4.8 | 80.7 +4.9 | 37.3 +8.4 | 50.0 +9.3 | 79.2 +3.3 | 62.7 -4.5 |
| AppWorld | BrowseComp+ | RewardBench2 | ||||||
|---|---|---|---|---|---|---|---|---|
| Normal | Challenge | Test Set | Test Subset | |||||
| Lite | Nano | Lite | Nano | Lite | Nano | Lite | Nano | |
| RCL (all primitives) | 89.3 | 89.1 | 71.9 | 83.7 | 37.3 | 51.3 | 82.4 | 69.8 |
| Failure Replay | 85.7 -3.6 | 88.5 -0.6 | 71.5 -0.4 | 74.9 -8.8 | 38.7 +1.4 | 33.3 -18.0 | 83.1 +0.7 | 59.4 -10.4 |
| Optimizer State | 89.9 +0.6 | 85.5 -3.6 | 71.2 -0.7 | 82.5 -1.2 | 34.0 -3.3 | 46.7 -4.6 | 74.6 -7.8 | 64.1 -5.7 |
| Credit Assignment | 89.9 +0.6 | 85.0 -4.1 | 73.4 +1.5 | 82.1 -1.6 | 32.7 -4.6 | 41.3 -10.0 | 74.3 -8.1 | 75.1 +5.3 |
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
| Method | Reflector ( ) | Mutator ( ) | State / Memory | Regime |
| Loop development | ||||
| Reflexion ( Shinn et al., 2023 ) | Verbal self-critique | Append to memory | Episodic history | Single-ep. |
| ExpeL ( Zhao et al., 2024 ) | Experience extraction | Insight reuse | Extracted knowledge | Cross-task |
| Agent-Pro ( Zhang et al., 2024 ) | Belief + policy critique | DFS-style search | World model beliefs | Policy |
| Dyn. Cheatsheet ( Suzgun et al., 2026 ) | Failure summarization | Curated append | Persistent cheatsheet | Task learn. |
| ACE ( Zhang et al., 2026 ) | Trajectory critique | Structured delta edits | Playbook history | Policy |
LLM Agent Self-Improvement
Large language model agent self-improvement studies how agents use experience and feedback to improve their behavior, tools, and workflows.
See all 257 papers