arXiv:2610.28977stat.MLOct 2026

Manuscript Offprint

arXiv:2610.28977

Is In-Context Reinforcement Learning A Posterior Sampler? An Empirical Study

Weiqin Chen, Xinlong Du, Gesualdo Scutari, Harsha Honnappa

ABSTRACT

In-context reinforcement learning (ICRL) exploits the impressive in-context learning ability of large language models to zero-shot generalize to new, unseen tasks at inference time without any parameter updates. Among many approaches, the Decision-Pretrained Transformer (DPT) is particularly appealing for its theoretical grounding: under idealized assumptions such as a sufficiently expressive model and infinite pretraining data, DPT can perform Bayesian posterior sampling. Whether this characterization survives in practice remains open. Therefore, we ask: is ICRL, specifically DPT and our proposed DPT variants, a Bayesian posterior sampler in practice? To approach this question, we establish two necessary conditions that a Bayesian posterior sampler must satisfy: sufficient-statistic invariance and the martingale property. We then construct statistical hypothesis tests to statistically assess if practically-trained ICRL models satisfy these conditions. Applying these tests in Gaussian, Bernoulli, and linear bandit settings, we find that both conditions are consistently violated, suggesting that ICRL may not behave as Bayesian posterior samplers in practice. Beyond this negative result, our tests provide a principled toolkit for testing the Bayesian behavior of ICRL.

1 INTRODUCTION

Reinforcement learning (RL) has demonstrated remarkable performance in a wide range of applications, such as strategy games (Mnih et al., 2013; 2015), robotics (Levine et al., 2016; Duan et al., 2016), and recommender systems (Afsar et al., 2023; Lin et al., 2024b). However, a fundamental challenge in RL is the limited capability to few-shot or zero-shot generalize to new unseen tasks, as traditional RL methods learn a policy for a single task through an ocean of environment interactions and extensive trials-and-errors, and thus typically requires retraining a policy from scratch for each new task. In-context RL (ICRL) offers a compelling alternative attributed to the impressive capability of in-context learning by large language models (LLMs) (Dong et al., 2024; Li et al., 2023; Wei et al., 2023). Specifically, a transformer (Vaswani et al., 2017) pretrained on a diverse set of tasks/environments can adapt to and reinforcement learn in new, unseen tasks at test time, purely by conditioning on interactions with the new, unseen tasks (a.k.a. context) without any parameter updates. Several ICRL frameworks have been proposed to realize this vision. Algorithm Distillation (AD) pretrains a transformer on the complete learning histories of an RL algorithm (e.g., PPO (Schulman et al., 2017) or SAC (Haarnoja et al., 2018)), where the context consists of a sequence of episodes exhibiting progressive improvement and dynamics (Laskin et al., 2023). The transformer learns to extrapolate this improvement operator, effectively distilling the source RL algorithm's learning dynamics into its in-context behavior. Decision-Pretrained Transformer (DPT) adopts a fundamentally different approach (Lee et al., 2023). Rather than imitating an evolving algorithm, DPT pretrains a transformer via supervised learning to predict optimal actions conditioned on contexts of varying lengths. Moreover, DPT can employ arbitrary context data, such as interactions collected under a random policy (Chen & Paternain, 2025), by leveraging the optimal action labels.

Notably, a central theoretical grounding underpins DPT's appeal. Prior works (Lee et al., 2023; Lin et al., 2024a) establish a theoretical understanding that “DPT is an efficient imple-

∗^{*}Equal contribution mentation of Bayesian posterior sampling” that achieves rate-optimal Bayesian regret (Russo & Van Roy, 2016). This, however, relies on strong assumptions such as a sufficiently expressive model and infinite pretraining data to exactly match or closely approximate the pretraining data distribution (Lee et al., 2023; Lin et al., 2024a), which may not hold in practice. In addition, an empirical gap between DPT and a Bayesian posterior sampler (PS) is observed from experiments (see Figure 1), where we compare the default setting of DPT as in (Lee et al., 2023) and Thompson sampling (Thompson, 1933) (a Bayesian posterior sampler in multi-armed bandits) in Gaussian (multi-armed) bandits. Accordingly, this paper aims to explore and answer the following research question:

Is ICRL, including DPT and our proposed DPT variants, a Bayesian posterior sampler in practice?

Figure

(a) Cumulative regret

Figure

(b) TV distance

Furthermore, it is worth highlighting that the re-search question above is also motivated by an

Figure 1: DPT versus Thompson Sampling in Gaussian bandits: cumulative regret and total variation (TV) distance between action distributions.

empirical study (Falck et al., 2024), where in-context learning of common LLMs like GPT-3.5 (OpenAI, n.d.), GPT-4 (OpenAI, 2023), Llama-2 (Touvron et al., 2023), and Mistral (Jiang et al., 2023) is demonstrated non-Bayesian from a martingale perspective (a necessary condition for Bayesian systems). Inspired by (Falck et al., 2024), we take a statistical hypothesis testing approach to the research question above. Our main contributions are as follows.

• Necessary conditions. We provide a behavioral characterization of a transformer as a Bayesian posterior sampler in terms of its action distribution, and derive two necessary conditions from it, namely sufficient-statistic invariance and the martingale property, which we instantiate for Gaussian, Bernoulli, and linear bandits.

• Testing framework and DPT variants. We turn each condition into a hypothesis test on action probabilities. Since DPT predicts only actions, we propose DPT' and GDPT, which augment DPT with a reward head so that the martingale property becomes testable.

• Empirical findings. Across all bandit settings, deployment modes, context transformations, and context lengths, DPT, DPT', and GDPT consistently violate sufficient-statistic invariance, and DPT' and GDPT additionally violate the martingale property, even when their decision performance closely tracks Thompson Sampling. Ablation studies that enforce permutation invariance do not remove the violations. Beyond this negative result, our statistical tests provide a principled toolkit for auditing Bayesian claims about ICRL.

A more detailed discussion of related work is provided in Appendix A.

References (41)