arXiv:2611.09625cs.LGNov 2026

Manuscript Offprint

arXiv:2611.09625

Encoding Memory in World Models with Test-Time Model-Based Reinforcement Learning

Maxime Burchi, Fayaz Ali Dharejo, Radu Timofte

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Model-based reinforcement learning (MBRL) approaches have demonstrated strong performance across diverse domains in recent years, learning accurate world models from agent trajectories. However, despite this progress, current approaches still struggle to surpass human performance on tasks that require long-term memory and planning. In this work, we address the problem of long-term memory in MBRL by moving beyond the commonly studied paradigm of architecture design. We introduce Test-Time Model-Based Reinforcement Learning (TT-MBRL), using gradient descent at test time to encode the memory of episode observations into world model parameters. This enables the agent to learn a distinct world model for each episode, improving memory capabilities compared to traditional approaches that solely rely on contextual memory. We first establish a proof of concept on a simplified two-dimensional variant of the Memory Maze environment, which we refer to as Memory Maze 2D, showing consistent improvements across different world model architectures. We then demonstrate the effectiveness of TT-MBRL in the 3D domain, achieving new state-of-the-art results on the Memory Maze benchmark. Finally, we show that TT-MBRL maintains strong performance on non-memory benchmarks such as DeepMind Control and Atari 100k. We will release our code at https://github.com/burchim/TT-MBRL.

1 INTRODUCTION

Model-based reinforcement learning has gained increasing research attention in recent years (Kaiser et al., 2020; Schrittwieser et al., 2020; Hafner et al., 2020; 2021; 2023; 2025; Hansen et al., 2022; 2024; 2026; Micheli et al., 2024; Alonso et al., 2024), driven in part by advances in hardware computing capabilities. These improvements have enabled the training of world models from high-dimensional observations using deep neural networks as function approximators (Hafner et al., 2019). World models (Sutton, 1991; Ha & Schmidhuber, 2018) capture an agent's experience into a predictive function that can be used in place of the real environment to learn complex behaviors. By leveraging a model of the environment, agents can simulate multiple possible future trajectories in parallel, leading to improved generalization, greater sample efficiency, and more effective decision-making via planning.

Among these approaches, the Dreamer algorithm (Hafner et al., 2020; 2021; 2023) has demonstrated strong performance across diverse environments by learning a world model capable of generating accurate trajectories in latent space. However, despite making realistic predictions for fully observable settings, Dreamer struggles to maintain temporal coherence in partially observable environments like Memory Maze (Figure 2). World model prediction error accumulates over time, leading to long-horizon trajectories that become increasingly inconsistent with past observations.

Figure

Figure 1: Performance improvements brought by TT-MBRL on Memory Maze 2D and Memory Maze.

To remedy this problem, recent approaches have proposed architectural improvements to better handle past context information and enhance the memory capabilities of world models. Pašukonis et al. (2023) proposed to augment Dreamer with Truncated Backpropagation Through Time (TBTT), conditioning training sequences on previous context representations. TransDreamer (Chen et al., 2021) proposed a Transformer-based world model to bypass the limitations of recurrent neural networks and process long context with self-attention (Vaswani et al., 2017). Building on this direction, TWISTER (Burchi & Timofte, 2025) further improved Transformer-based world models by incorporating a contrastive predictive coding objective to enhance temporal representation learning. Following the success of State Space Models (SSMs) in capturing dependencies across long sequences (Gu et al., 2022; Nguyen et al., 2022; Smith et al., 2023), several works have also explored SSM-based world models. Recall to Imagine (R2I) (Samsami et al., 2024) improved training efficiency and long-term memory using a modification of the S4 model (Gu et al., 2022), outperforming previous approaches on the Memory Maze benchmark (Pašukonis et al., 2023). Concurrently, Deng et al. (2023) proposed S4WM, further demonstrating that SSM-based architectures outperform Transformer-based world models in terms of long-term memory.

However, despite this progress, existing approaches still encounter difficulties surpassing human performance on tasks requiring long-term memory and planning (Samsami et al., 2024). Most prior works focus on architecture design, assuming that improved world model architectures can effectively exploit past context to capture long-term dependencies. These approaches rely on learning a single world model that generalizes across episodes, requiring it to extract common patterns and adapt to the unique structure of each new episode through contextual representations. While shared patterns can be learned effectively, modeling episode-specific information through context alone remains challenging, particularly in partially observable settings like Memory Maze. In contrast, biological systems are believed to encode long-term memory through persistent modifications of synaptic strengths, a process often associated with Long-Term Potentiation (LTP) in neural circuits (Bliss & Collingridge, 1993). Motivated by this perspective, and by the observation that Test-Time Training (TTT) can improve predictive

models when training and test data come from different distributions (Sun et al., 2020), we propose a learning strategy that encodes episode-specific memory directly into the model parameters via gradient-based updates at test time. This approach enables the agent to capture episode-specific information by adapting its world model online, rather than relying solely on contextual memory.

In this work, we address the challenge of long-term memory in MBRL by moving beyond the commonly studied paradigm of architecture design. Inspired by test-time training methods that adapt model parameters at inference time (Sun et al., 2020; Gandelsman et al., 2022; Wang et al., 2025), we introduce Test-Time Model-Based Reinforcement Learning (TT-MBRL), using gradient descent at test time to encode the memory of episode-specific information into world model parameters. This enables the agent to learn a distinct world model for each episode, improving memory capabilities compared to traditional approaches that solely rely on contextual memory. We first establish a proof of concept on a simplified two-dimensional variant of the Memory Maze environment, which we refer to as Memory Maze 2D, showing consistent improvements across different world model architectures. We then demonstrate the effectiveness of TT-MBRL in the 3D domain, achieving new state-of-the-art results on the Memory Maze benchmark (Pašukonis et al., 2023). We find that the effectiveness of TT-MBRL scales proportionally to the number of environment steps collected at test-time, increasing the amount of rewards obtained per step by 53.7% for R2I after 4000 environment steps on Memory Maze 15×15 (Figure 5c). Finally, we show that TT-MBRL maintains strong performance on non-memory benchmarks such as DeepMind Control and Atari 100k. Figure 1 summarizes the results obtained on memory benchmarks.

Figure

Figure 2: DreamerV3 failure case where the world model predicts an incoherent future after returning to the original position in Memory Maze.

References (60)