NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Convergence and Emergence of In-Context Reinforcement Learning with Chain of Thought

Zixuan Xie, Xinyu Liu, Rohan Chandra, Shangtong ZhangarXiv 2026

TL;DR

This paper provides the first theoretical framework explaining how Chain-of-Thought (CoT) token generation amplifies In-Context Reinforcement Learning (ICRL). The authors prove that a single-layer linear Transformer using CoT autoregressive generation is mathematically equivalent to repeatedly executing batch Temporal Difference (TD) learning updates at inference time. Furthermore, they demonstrate that these algorithmic parameters naturally emerge as global minimizers during reinforcement pretraining.

What Problem Does This Paper Address?

In-Context Reinforcement Learning (ICRL) allows a neural network to adapt to new tasks at inference time without any parameter updates, simply by conditioning on past interaction history (context). While empirical studies show that prompting models to generate a "Chain of Thought" (CoT) significantly boosts this in-context learning capability, we haven't historically understood why from a mathematical standpoint.

Prior theoretical work showed that deep Transformers could mimic reinforcement learning algorithms through their layer-by-layer forward pass (using depth to simulate algorithmic steps). However, those models failed to explain the role of autoregressive CoT generation—where a model uses time and token generation rather than network depth to think. This paper bridges that gap by analyzing how CoT generation interacts with ICRL in a policy evaluation setting.

Methods

The authors analyze a single-layer linear Transformer (a common theoretical proxy where the softmax nonlinearity is replaced by an identity map) tasked with linear value function approximation.

Key components of their approach include:

  1. Structured Prompt Design: The initial prompt matrix ($Z_0$) is organized into distinct blocks containing the context trajectory (states, features, rewards) and an initialized weight vector ($w_0$).
  2. Autoregressive CoT Loop: At each generation step, the model reads the prompt, generates a new token representing the updated value function weight vector ($w_k$), appends it to the prompt, and repeats.
  3. Finite-Sample Convergence Analysis: To make the theory realistic, the authors analyze performance under unknown dynamics using a single Markovian trajectory. They employ advanced statistical techniques (like Berbee's coupling and blocking arguments) to handle data dependence.
  4. Optimization Proofs: They define an Empirical Update Norm (EUN) pretraining loss and prove that the exact parameter matrices required to execute TD learning are global minimizers of this loss.

Datasets

The paper validates its theoretical findings using synthetic data generated from Boyan’s chain, a canonical benchmark environment specifically designed for evaluating reinforcement learning policy evaluation algorithms. The model was pretrained on 5,000 randomly sampled Markov Reward Processes (MRPs) based on this topology.

Key Insights and Ideas

  • CoT Replaces Depth: Instead of requiring a deep, multi-layered network to perform multi-step algorithmic reasoning, a single Transformer layer can implement an iterative algorithm by leveraging the autoregressive CoT generation loop. Time effectively substitutes for depth.
  • The "Statistical Floor": Under unknown environment dynamics, generating more CoT tokens drives the policy evaluation error down geometrically. However, it doesn't hit zero; it eventually saturates at a "statistical floor" dictated entirely by the length of the context trajectory ($n$). More context lowers the floor; more CoT steps get you closer to it.
  • Natural Emergence: The specific block-sparse parameter structures required to run TD learning do not need to be hardcoded. They are the global minimizers of a standard TD-based pretraining objective, explaining why these mechanisms spontaneously appear when training sequence models on RL data.

Key Results

  • Algorithmic Equivalence (Theorem 1): The authors constructively prove that with specific weight matrices ($P, Q$), the token generated at step $k$ matches the $k$-th iterate of an offline batch TD update.
  • Geometric Convergence (Theorem 2): In environments with unknown dynamics, the Mean-Squared Projected Bellman Error (MSPBE) decreases at a geometric rate of $(1 - \frac{\alpha\mu}{2})^k$ plus a statistical error term $\epsilon(\delta)^2$ that vanishes as context length $n \to \infty$.
  • Empirical Validation: Controlled experiments on Boyan's chain confirm that during training, the Transformer's parameter matrices naturally converge to the exact block-sparse structure predicted by the authors' theoretical construction.

Limitations and Future Work

  • Linear Attention Only: The theoretical proofs rely on linear self-attention. Extending this analysis to standard softmax attention remains an open challenge due to the mathematical complexities of the softmax nonlinearity.
  • Policy Evaluation vs. Control: The paper focuses strictly on policy evaluation (estimating how good a policy is). It does not address control problems (searching for and optimizing the best policy), which is the ultimate goal of full ICRL.
  • Scale: The empirical validation is restricted to a small-scale, synthetic environment (Boyan's chain). Testing whether these exact theoretical bounds hold in large-scale language models or complex environments is left for future research.

Summary updated

BibTeX
@misc{xie2026convergence,
  author = {Zixuan Xie and Xinyu Liu and Rohan Chandra and Shangtong Zhang},
  title = {{Convergence and Emergence of In-Context Reinforcement Learning with Chain of Thought}},
  year = {2026},
  eprint = {2605.07123},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.07123},
}
Figure