OmniRL: In-Context Reinforcement Learning by Large-Scale Meta-Training in Randomized Worlds

Fan Wang, Pengtao Shao, Yiming Zhang, Bo Yu, Shaoshan Liu, Ning Ding, Yang Cao, Yu Kang, Haifeng Wang · DOI

Introduction

Reinforcement Learning (RL) agents typically rely on "In-Weight Learning" (IWL), updating parameters over millions of trials. In contrast, In-Context Reinforcement Learning (ICRL) seeks to emulate biological learning: an agent that adapts to new tasks through interaction alone, using its history as context in a single forward pass. However, ICRL has been limited by data diversity; agents trained on narrow tasks like mazes often fail to generalize, merely memorizing specific environments rather than learning "how to learn."

Methods: AnyMDP and Decoupled Policy Distillation

OmniRL addresses this bottleneck through two primary innovations: AnyMDP and Decoupled Policy Distillation (DPD).

AnyMDP: A Universe of Randomized Worlds

AnyMDP is a task generator that creates hundreds of thousands of unique Markov Decision Processes (MDPs). Unlike traditional generators that vary superficial features, AnyMDP randomizes fundamental transition dynamics and reward functions. It employs banded transition matrices to ensure that high-value states are exponentially difficult to reach. This "high-hanging fruit" structure forces agents to develop sophisticated exploration strategies rather than relying on random success.

State probability distributions in AnyMDP versus Garnet MDPs. The red bars (AnyMDP) show a steeper decay, illustrating the "high-hanging fruit" property where most states are difficult to reach.

Decoupled Policy Distillation (DPD)

To bridge the gap between expert training data and noisy deployment interactions, the authors introduce DPD. This framework decouples the behavior policy—which explores the environment using diverse strategies like Q-learning or random walks—from the reference policy, the optimal "oracle" actions the model aims to predict.

The Decoupled Policy Training (DPT) framework separates exploration from the target reference policy to improve distillation efficiency.

Architecture and Scaling

OmniRL utilizes long-context linear attention models (e.g., RWKV-7, Mamba-2) to process up to 512K interaction steps. During training, the model is provided with "tags" identifying the policy behind specific actions, helping it interpret its own history more effectively.

Key Insights

  • The 10K Phase Transition: Emergent "learning-to-learn" capabilities appear only after training diversity exceeds 10,000 unique tasks. Below this threshold, models tend to memorize specific environments.
  • The Generalization Tax: There is an inherent trade-off between immediate few-shot speed and long-term robustness. While specialized agents may "warm up" faster, OmniRL's broad training allows it to eventually achieve superior performance across a wider variety of unseen environments.
  • System 1 Adaptation: Unlike LLMs that excel at "System 2" reasoning (solving tasks via explicit instructions), OmniRL focuses on "System 1" trial-and-error adaptation, mirroring biological interaction.

Results and Evaluation

OmniRL, trained exclusively on AnyMDP, demonstrates remarkable zero-shot generalization to classic Gymnasium tasks like FrozenLake, CliffWalking, and Pendulum-v1.

  • Sample Efficiency: In FrozenLake, OmniRL achieves near-optimal performance in thousands of steps, significantly outperforming traditional RL algorithms like PPO that require millions.
  • Multi-Agent Cooperation: Despite single-agent training, OmniRL successfully cooperates in the Switch2 task by treating other agents as dynamic environmental elements.
  • Scaling Laws: Performance on unseen tasks scales consistently with the number of training tasks and context length.

Limitations and Future Work

Currently, OmniRL is optimized for discrete (tabular) state and action spaces. While it can handle continuous tasks through discretization, native continuous-space support is a key area for future research. Additionally, while AnyMDP is structurally diverse, incorporating "natural" biases or hierarchical structures could further enhance its applicability to complex real-world robotics.

Summary updated

BibTeX
@inproceedings{wang2025omnirl,
  author = {Fan Wang and Pengtao Shao and Yiming Zhang and Bo Yu and Shaoshan Liu and Ning Ding and Yang Cao and Yu Kang and Haifeng Wang},
  title = {{OmniRL: In-Context Reinforcement Learning by Large-Scale Meta-Training in Randomized Worlds}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=b6ASJBXtgP},
}
Figure