TL;DR
This paper introduces Continual In-Context Reinforcement Learning (CICRL), a framework where agents must adapt to unpredictable, shifting environments within a single lifetime without updating their neural network parameters. By benchmarking modern sequence models like Mamba2 and GatedDeltaNet, the authors demonstrate that while standard training fails in dynamic worlds, non-stationary training enables agents to effectively "forget" obsolete information and master new rules on the fly.
What Problem Does This Paper Address?
Traditional Reinforcement Learning (RL) often requires slow, gradient-based updates to adapt to new tasks. In-Context Reinforcement Learning (ICRL) bypassed this by using sequence models (like Transformers) to adapt purely through their input history—essentially "learning" during a single forward pass.
However, ICRL has a major blind spot: it assumes the environment is static. In the real world, rules change—a robot’s joints wear down, or a game’s mechanics are patched. Current ICRL agents struggle with "intra-lifetime" non-stationarity; they tend to treat all historical data as equally valid, leading to contextual interference where outdated information prevents them from adapting to new realities. The authors ask: How can we build agents that not only learn new dynamics rapidly but also know when to discard the old ones?
Methods
The researchers formalize the CICRL framework, modeling an agent's life as a sequence of different environments (POMDPs) encountered without a history reset. They employ a "frozen weights, fluid context" paradigm: the model's parameters are fixed after training, and all adaptation happens via the internal state of the sequence model.
They compared three major sequence architectures:
- Transformer: The standard, using self-attention to look back at all historical tokens.
- Mamba2: A State Space Model (SSM) that uses a compressed recurrent state for efficiency.
- GatedDeltaNet: A hybrid architecture that uses a "delta rule" for precise memory overwriting and a gating mechanism for "hard" forgetting.
The agents were trained using Proximal Policy Optimization (PPO), but with a twist: the training environments were designed to shift their rules mid-run to force the models to develop adaptation and forgetting mechanisms.
Datasets
The authors introduced two new non-stationary benchmarks by modifying existing suites:
- Non-Stationary XLand-Minigrid: A symbolic grid-world where the "laws of physics" (e.g., "blue pyramid + purple square = yellow key") change periodically.
- Non-Stationary Kinetix: A physics-based 2D environment where global constants (gravity, friction, thruster power) and object properties (density, elasticity) drift or shift abruptly.
These benchmarks are unique because they don't reset the agent's memory when the environment changes, forcing the agent to perform online system identification.
Key Insights and Ideas
- The Necessity of Non-Stationary Training: Models trained on static tasks (even with long contexts) fail miserably when rules shift. They suffer from "catastrophic interference," trying to apply old rules to new situations. Only models trained in "chaotic" environments learn to treat context as a temporary, fluid state.
- Architectural Inductive Biases:
- SSMs (Mamba2) excel at discrete, symbolic reasoning (XLand) because they are great at modeling state transitions.
- GatedDeltaNet and Transformers are superior in continuous physics tasks (Kinetix), likely because the delta rule and direct attention allow for the high-precision numerical adjustments needed for physics.
- The Context "Sweet Spot": Contrary to the "more is better" intuition, performance peaked at a context length of 25,600 steps and degraded at 51,200. The authors suggest that extremely long sequences dilute gradients during training, making credit assignment harder for the RL optimizer.
- Mechanistic Forgetting: The paper highlights that for CICRL to work, models must implement forgetting. Transformers do this "softly" by re-weighting attention, while GatedDeltaNet does it "hardly" by using gates to physically flush the recurrent state when a reward shift is detected.
Key Results
- Performance Jump: In XLand-Minigrid, GatedDeltaNet’s average return surged from 0.081 (static training) to 0.211 (non-stationary training), proving that the training paradigm is as important as the architecture.
- Resilience: Non-stationarily trained models showed positive Switch Resilience ($\Delta_{Switch}$), meaning they could effectively ignore outdated information immediately after a rule change, whereas Domain Randomization (DR) baselines saw their performance collapse.
- Scaling: The authors found a clear positive correlation between performance and both the amount of training data (scaling from 1B to 20B steps) and model depth (3 vs 6 layers).
Limitations and Future Work
- Credit Assignment: The degradation of performance at very long context lengths suggests that current RL optimizers (like PPO) struggle to manage the long-term dependencies required for massive context windows.
- Task Difficulty: In the Kinetix environment, even the best models often showed negative "Adaptation Gain," suggesting that high-dimensional, continuous non-stationarity remains an extremely difficult frontier.
- Future Directions: The authors suggest exploring more stable optimization algorithms and investigating how these agents might handle even more complex, open-ended worlds where changes are not just frequent, but structurally novel.
Summary updated