Manuscript Offprint

arXiv:2610.06651

Considering Context: When World Models Need Context Encoders

Oleg Smirnov, Sofiane Ennadir, John Pertoft, Bjartur Hjaltason, Sara Karimi

Oleg Smirnov

King AI Labs, Microsoft Gaming

oleg.smirnov@microsoft.com

John Pertoft

King AI Labs, Microsoft Gaming

john.pertoft@king.com

Sofiane Ennadir

King AI Labs, Microsoft Gaming

sofiane.ennadir@king.com

Bjartur Hjaltason

King AI Labs, Microsoft Gaming

bjartur.hjaltason@king.com

Sara Karimi

King AI Labs, Microsoft Gaming & KTH Royal Institute of Technology

sara.karimi@king.com

ABSTRACT

Methods for generalization in model-based reinforcement learning typically assume that an agent cannot recover the latent context governing the environment dynamics from its own experience, and therefore supplies it externally. We formalize and test this assumption with predictive sufficiency, which quantifies what access to the context adds to next-step prediction under the visitation distribution an agent induces, and separates that quantity into a history-recoverable part, a residual requiring the true context, and the deficit added by a finite model. We classify context-aware algorithms by the predictive risk their conditioning set can target and demonstrate across environments of increasing identification difficulty that the headroom does not follow the MDP class. The same task under different priors leaves predictive headroom in one setting and nothing distinguishable from zero in another, where the agent's behavior implicitly identifies the context and any benefit of such a mechanism cannot be attributed to missing information. Where headroom persists, the learned state exposes it only partially, and adding the true context still lowers the risk. Our contribution is a practical criterion for matching contextual mechanisms to the information available to them, estimated from the ordinary trained agent without a reference policy.

1 INTRODUCTION

In model-based reinforcement learning (RL), even minor changes in environment dynamics, e.g., the mass of a body or the friction of a floor in robotics, can degrade next-state predictions and, through compounding rollout errors, the policies built upon them (Lee et al., 2020). Settings with such variations are often formalized as contextual MDPs (Hallak et al., 2015) or hidden parameter MDPs (Doshi-Velez & Konidaris, 2016). The latent parameters may be drawn i.i.d. from a shared prior (Benjamins et al., 2023), evolve according to a background process, as in dynamic parameter MDPs (Xie et al., 2021), or vary without structure, folding the problem into a general partially observable MDP. They can also change between episodes, during an episode, or even at every timestep (Dulac-Arnold et al., 2021).

In these settings, a predictor that only sees the current state and action has to average over the contexts that are still plausible at that point, resulting in a model mixture and reduced prediction accuracy. A common solution is to infer the missing information online and provide it to the agent, where existing approaches include supervised system identification, meta-learned adaptation, latent context encoders, or conditioning on ground-truth context (Duan et al., 2016; Nagabandi et al., 2019; Lee et al., 2020; Zintgraf et al., 2020; Evans et al., 2022; Röder et al., 2025; Prasanna et al.,

(a) Marginal kernel averaging

Figure

(b) Implicit identification

Figure

(c) Visitation-dependent sufficiency

Figure

Figure 1: Contextual variation in MiniGrid, where a hidden wind variable probabilistically displaces the agent after each move, and walls block the displacement. (a) A model trained on pooled experiences with different winds learns the averaged kernel, which has no net displacement and inflated spread and governs no individual episode. (b) Under the same policy the trajectories separate mid-episode, so the state alone is consistent with only one wind and identifies it implicitly, rendering contextual mechanisms partially redundant. (c) Under one and the same context, the trajectory of an agent crossing the open grid (blue) bends downwind and betrays the context, while an agent moving along the downwind border (orange) shows no drift at all, since the obstacle blocks it. What remains for context mechanisms to gain depends on what the agent's own trajectories already reveal, and on what they cover.

2024). Those methods aim for improving how a finite model uses experience without adding new observations. However, the agent’s trajectories can contain sufficient evidence about the active context, and a model that uses history already has access to this information. What a contextual mechanism can still add is exactly the one-step advantage that observing the context grants a predictor under the data distribution the agent itself induces.

Figure 1 illustrates these effects. Pooling distinct contexts yields an averaged kernel that governs no particular episode, while trajectories reveal or conceal the context depending on where they lead, identifying the dynamics before any dedicated mechanism infers them.

We formalize this question through predictive sufficiency, quantifying the Bayes one-step advantage of context for memoryless and history-aware predictors. We distinguish prior-averaged structural variation from predictive headroom, the potential improvement in next-state prediction from observing the true context under the agent's observed trajectories. We split headroom into information recoverable from history and a residual requiring context, while separating the learned predictor's finite-model deficit. Reading context-aware methods through the information they access turns the decomposition into class-level predictions: an encoder has no missing information to supply where visitation alone makes the context identifiable, short windows can recover headroom carried by recent evidence, and persistent representations can exploit information spanning episode boundaries.

Our contribution is threefold: i) we analyze visitation-mediated implicit identification, where the agent's behavior concentrates the posterior over the context until nothing is left for another mechanism to supply; ii) we formulate predictive sufficiency, which asks a representation to preserve the transition information the context carries rather than the context itself, and decompose the resulting gap exactly across the inputs a method conditions on; and iii) we propose a principled criterion, confirmed in experiments across MDP classes of increasing identification difficulty, that determines which conditioning sets have predictive information to add and whether linear decoding of a learned state recovers it.

References (42)