Abstract
In-context reinforcement learning (ICRL) enables agents to adapt to new tasks by processing previous experiences within the Transformer's context window, bypassing the need for gradient updates. However, the quadratic complexity of self-attention mechanisms makes long-horizon tasks computationally expensive. We introduce the In-Context Decision Transformer (IDT), which employs a hierarchical "Chain-of-Thought" architecture. By predicting high-level latent decisions that govern multiple low-level actions, IDT significantly compresses the context sequence. Our results demonstrate that IDT achieves evaluation speeds up to 36× faster than previous state-of-the-art methods while outperforming baselines in long-horizon environments.
Introduction
The promise of ICRL lies in its ability to perform "Algorithm Distillation," where a model learns to improve its policy purely through interaction history. Despite this, standard Transformers struggle with the "context window bottleneck." In reinforcement learning, representing every state, action, and reward over multiple episodes leads to sequence lengths that explode in long-horizon tasks (e.g., 1,000+ timesteps). This scalability issue prevents current ICRL methods from being applied to complex, real-world scenarios. The In-Context Decision Transformer addresses this by introducing temporal abstraction, allowing the model to reason over macro-strategies rather than individual actions.
Methodology
IDT mimics human hierarchical decision-making through a three-module architecture designed to handle temporal abstraction and sequence compression.
The system operates on two distinct levels:
- Making Decisions Module: This high-level controller predicts a latent decision vector $z$ every $c$ timesteps. It attends to a "Chain of Experience"—a history of previous trajectories sorted by reward—to determine a macro-strategy.
- Decisions to Go Module: This low-level controller translates the latent decision $z$ into a sequence of $c$ specific environment actions.
- Reviewing Decisions Module: To enable end-to-end training on raw offline data lacking explicit high-level labels, this module acts as an encoder. It "reviews" action sequences to infer the underlying high-level decisions ($z$) that produced them.
By operating on a compressed history of macro-decisions, the effective sequence length is reduced by a factor of $c$, which drastically lowers the computational burden of the self-attention mechanism.
Experimental Results
The model was rigorously tested on the D4RL benchmark (MuJoCo environments) and a custom Large Grid World suite featuring 40x40 grids and 10x longer horizons than standard variants.
Efficiency and Scalability
The primary advantage of IDT is its efficiency. As shown in the performance metrics, IDT achieved a 36× speedup in online evaluation on D4RL tasks compared to the Agentic Transformer (AT). In the Large Grid World tasks, the speedup was 27×. This efficiency is directly attributable to the hierarchical compression, which allows the model to maintain a much smaller active context window for the high-level controller.
Performance in Long-Horizon Tasks
On the Large Grid World benchmarks, IDT significantly outperformed baselines like Algorithm Distillation (AD) and AT. While standard models struggled to capture goal positions within excessively long sequences, IDT’s hierarchical reasoning allowed it to identify and execute successful strategies more reliably. In D4RL tasks, IDT maintained competitive accuracy, proving that temporal abstraction does not come at the cost of policy quality.
Discussion and Conclusion
The In-Context Decision Transformer demonstrates that hierarchy is a powerful tool for both planning and computational compression. By shifting the Transformer's focus from low-level actions to high-level intentions, IDT overcomes the scalability limits of previous ICRL methods.
Current limitations include the use of a fixed hierarchy ($c$), whereas real-world tasks might benefit from variable-length macro-actions. Future research could explore grounding these high-level decisions in natural language to create a more transparent "Chain-of-Thought" for reinforcement learning. Despite these areas for growth, IDT represents a significant step toward efficient, zero-gradient self-improvement in complex environments.
Summary updated