In-Context Reinforcement Learning for Variable Action Spaces
Viacheslav Sinii, Alexander Nikulin, Vladislav Kurenkov, Ilya Zisman, Sergey Kolesnikov
TL;DR
This work tackles the challenge of in-context reinforcement learning under variable discrete action spaces by removing the conventional output head and employing random action embeddings; actions are inferred from context via a contrastive objective, enabling zero-shot generalization to unseen actions. Headless-AD demonstrates robust generalization to action spaces up to $5\times$ larger than those seen during training and often outperforms specially trained baselines across Bernoulli and contextual bandits as well as a Darkroom-style MDP. Key contributions include the elimination of action-space dependence through embedding prompts and the use of InfoNCE loss to train a policy-improvement operator that operates over variable action sets. The approach advances foundational RL models toward versatility across diverse and evolving action spaces, with implications for scalable, pretrainable agents in real-world settings.
Abstract
Recently, it has been shown that transformers pre-trained on diverse datasets with multi-episode contexts can generalize to new reinforcement learning tasks in-context. A key limitation of previously proposed models is their reliance on a predefined action space size and structure. The introduction of a new action space often requires data re-collection and model re-training, which can be costly for some applications. In our work, we show that it is possible to mitigate this issue by proposing the Headless-AD model that, despite being trained only once, is capable of generalizing to discrete action spaces of variable size, semantic content and order. By experimenting with Bernoulli and contextual bandits, as well as a gridworld environment, we show that Headless-AD exhibits significant capability to generalize to action spaces it has never encountered, even outperforming specialized models trained for a specific set of actions on several environment configurations. Implementation is available at: https://github.com/corl-team/headless-ad.
