TL;DR
This paper tackles the bottleneck of scaling In-Context Reinforcement Learning (ICRL) by introducing AnyMDP, a procedurally generated environment that creates millions of diverse, unbiased Markov Decision Process tasks. By training a sequence model (OmniRL) on these tasks using a novel "Decoupled Policy Distillation" method, the authors achieve impressive zero-shot generalization to entirely unseen RL environments. This proves that massive task diversity and long-context modeling are the keys to unlocking general-purpose ICRL agents.
The Bottleneck in Scaling ICRL
In-Context Learning (ICL) has revolutionized natural language processing, allowing large models to adapt to new tasks on the fly without updating their weights. In-Context Reinforcement Learning (ICRL) attempts to bring this magic to decision-making: an agent interacts with an environment, accumulates a history of states, actions, and rewards in its context window, and improves its policy dynamically across episodes.
However, scaling ICRL is currently bottlenecked by a lack of good training data. To learn how to learn, an ICRL model needs to be meta-trained across a massive variety of tasks. Existing RL benchmarks are either too simple (like multi-armed bandits) or suffer from superficial randomization (e.g., changing the wall colors of a maze while the core physics remain the same). If a model is trained on narrow, structurally biased tasks, it simply memorizes the environment dynamics rather than learning a generalizable adaptation strategy. The authors set out to create a truly scalable, mathematically rigorous task generator and a highly efficient training pipeline to match it.
Methods: AnyMDP and Decoupled Policy Distillation
To solve the data bottleneck, the authors introduce two major innovations:
- AnyMDP (Procedural Task Generation): Instead of tweaking existing games, AnyMDP generates raw, tabular Markov Decision Processes (MDPs) from scratch. To ensure these random tasks are actually solvable but non-trivial, the authors use "banded transition matrices" and "composite rewards." This mathematically guarantees that the environments are ergodic (navigable) and that high-value states are exponentially harder to reach by pure random chance, forcing the agent to learn systematic exploration.
- Decoupled Policy Distillation (DPD): Training ICRL via standard reinforcement learning (the "outer loop") is computationally brutal. Instead, the authors treat it as a sequence modeling problem. They decouple the behavior policy from the reference policy:
- Behavior Policy: They use a diverse mix of agents (random, Q-learning, imperfect oracles) to generate highly varied trajectory data.
- Reference Policy: They label every step in those trajectories with the optimal action an oracle would have taken.
- Prior Information: They inject metadata into the sequence to tell the model which behavior policy generated the current action, helping the model make sense of heterogeneous data.
They train a linear-attention sequence model (like RWKV-7) on these sequences using chunkwise training to handle massive context lengths efficiently. The resulting model is named OmniRL.
Key Insights and Ideas
- The "Memorization vs. Adaptation" Boundary: The authors found a fascinating threshold. If you train on too few tasks (under 10,000), the model uses its weights to simply memorize the tasks (In-Weight Learning). It adapts quickly to seen tasks but fails on new ones. Only when pushed beyond 10,000+ unique tasks does the model abandon memorization and develop true In-Context Learning capabilities, allowing it to generalize to unseen environments.
- The "Long Context Tax": True generalization comes at a cost. Highly generalized ICRL learners actually take longer to adapt (requiring more steps in the context window) than models overfit to a narrow domain. The authors argue the field needs to stop evaluating ICRL on short-term, few-shot metrics and instead focus on asymptotic performance over long contexts.
- Emergent Exploration: By simply imitating an oracle policy over long contexts, OmniRL automatically learns to balance exploration and exploitation. It starts by assigning equal probabilities to actions (exploring) and gradually sharpens its predictions as it gathers environmental feedback (exploiting).
Key Results
The model was trained exclusively on AnyMDP, generating datasets with up to 128,000 unique tasks, context lengths up to 512K steps, and a total of 6 billion training steps.
- Zero-Shot Generalization: Despite being trained only on abstract AnyMDP math problems, OmniRL successfully generalized to human-designed Gymnasium tasks it had never seen. For example, it achieved 100% normalized performance on CliffWalking and 99.8% on non-slippery FrozenLake.
- Sample Efficiency: On unseen tasks, OmniRL frequently matched or exceeded the sample efficiency of classic algorithms like Proximal Policy Optimization (PPO) and Tabular Q-Learning.
- Emergent Multi-Agent Capability: Though trained strictly on single-agent tasks, OmniRL successfully adapted to a multi-agent environment (Switch2) simply by formatting the observation space, demonstrating deep algorithmic flexibility.
Limitations and Future Work
The most significant limitation is that AnyMDP and the current OmniRL architecture are restricted to discrete state and action spaces (tabular MDPs). For environments with continuous states (like Pendulum), the authors had to manually discretize the space.
The authors note that extending this procedural generation framework to continuous state-action spaces is the next major frontier. Doing so will require carefully balancing task complexity, diversity, and data integrity without making the environments mathematically unsolvable.
Summary updated