In-Context Environment Learning (ICEL)
- In-Context Environment Learning (ICEL) is a framework where models leverage contextual cues about the environment to adapt without updating their parameters.
- ICEL employs mechanisms such as Environment Recognition (ER) and Environment Learning (EL) to infer latent task structures and adjust predictions dynamically.
- ICEL demonstrates enhanced sample efficiency and robustness across tasks like regression, bandits, reinforcement learning, and multimodal applications.
Searching arXiv for recent and foundational papers on In-context Environment Learning and adjacent formulations. arXiv search query: "In-Context Environment Learning context is environment meta-in-context learning" In-context Environment Learning (ICEL) denotes a broader paradigm in which in-context data contains information about the environment or task structure, allowing a model to adapt to the statistics or characteristics of the current environment through context rather than through parameter updates. In world-model terms, ICEL is a model’s ability to adapt to new or unseen environments solely through information contained in the context of observed states and actions, without updating model weights or explicit offline retraining; in LLMs, meta-in-context learning provides a concrete, experimentally demonstrated instance in which priors and in-context strategies are reshaped across related tasks presented in a single prompt (Coda-Forno et al., 2023, Wang et al., 26 Sep 2025).
1. Conceptual scope and relation to adjacent notions
Standard in-context learning usually concerns improvement on a single task after a model is given demonstrations. ICEL is broader: the context carries information about the environment itself, including task descriptors, specifiers, structured context, or repeated experience from a shared task distribution. In this sense, the environment is not merely background metadata but part of the effective input that conditions prediction and action selection (Lin et al., 27 Feb 2025, Gupta et al., 2023).
Several nearby formulations occupy different points in this design space. Meta-in-context learning is described as a specific mechanism within ICEL: an LLM exposed to multiple tasks sampled from an environment can reshape both its priors and its in-context learning strategies without any change to model parameters or weight updates (Coda-Forno et al., 2023). In-context Learning with Hypothesis-Class Guidance (ICL-HCG) offers a controlled synthetic instantiation in which the environment is made literal through an explicit hypothesis-class prefix, allowing the effect of side-information to be studied directly (Lin et al., 27 Feb 2025). Context-enhanced learning is a gradient-based analog of usual in-context learning: the context is enhanced with additional data on which no auto-regressive gradients are computed, so the model learns from targets while conditioning on privileged curriculum-text (Zhu et al., 3 Mar 2025).
This suggests that ICEL is best understood not as a single algorithm but as a family of mechanisms for test-time or prompt-level environmental adaptation. What unifies the family is the use of context as an operational carrier of environment statistics, latent task structure, or stateful interaction history.
2. Core mechanisms of environmental adaptation
A central empirical finding is that contextual adaptation can alter both beliefs and algorithms. In the 1D regression and two-armed bandit domains used to study meta-in-context learning, exposure to multiple related tasks shifts GPT-3’s prior predictions toward the environment’s true statistics and also changes its in-context decision strategy. In the bandit setting, after meta-in-context learning the model uses more greedy strategies, increases reliance on UCB-based directed exploration, and reduces unwarranted uncertainty aversion (Coda-Forno et al., 2023). This is stronger than mere memorization of demonstrations: the learning dynamics themselves are modified by context.
The world-model formulation separates two mechanisms. The first is Environment Recognition (ER, or ICER), in which the model uses context to identify which previously seen environment is active and then applies an environment-specific predictive model. The second is Environment Learning (EL, or ICEL proper), in which the model infers dynamics directly from current context rather than recalling a previously stored environment identity (Wang et al., 26 Sep 2025). The distinction is formalized by different predictors:
whereas EL uses an empirical conditional estimate from context,
The paper formalizes ICEL itself by monotonic error reduction with longer context:
A common misconception is to equate any context sensitivity with ICEL proper. The ER/EL distinction shows that some apparent adaptation can be explained by improved recognition among memorized environments, whereas true ICEL in the stronger sense requires learning unseen dynamics from contextual evidence.
3. Formal accounts and theoretical foundations
The most explicit bridge from domain generalization to ICEL is the claim that context is environment. In-Context Risk Minimization (ICRM) reframes out-of-distribution generalization as contextual prediction from sequences of unlabeled examples drawn from the test environment. Training optimizes
and two limiting behaviors are emphasized: with no context, ICRM reduces to ERM, while with long in-context sequences from one environment it converges to the environment risk minimizer, the paper’s “zoom-in effect” (Gupta et al., 2023). This matters for ICEL because it gives a supervised-learning formalism in which environmental adaptation is not an auxiliary heuristic but the object of optimization itself.
A complementary information-theoretic account argues that in-context learning arises predictably from standard self-supervised next-token pretraining, especially on non-ergodic sources. The framework describes in-context loss reduction through the myopic entropy rates of the data-generating process and argues that a model’s in-context performance on any task is mathematically coupled to the ensemble of tasks seen in pretraining (Riechers et al., 23 May 2025). This suggests that ICEL need not be treated as an exotic emergent property; it can be a direct consequence of optimizing prediction on structured sequential data.
A more explicit quantification of pretraining–context interaction is given by a Bayesian-inference framework in which properly constructed context can shift the output distribution toward the query task distribution when pre-train and query distributions differ. The paper derives a precise relationship between ICL performance, context length, and the KL divergence between pre-train and query task distribution, and shows that sufficiently informative context can suppress non-target hypotheses exponentially in context length (Song et al., 26 Oct 2025). In parallel, analysis of supportive pretraining data finds that continued pretraining on a small selected subset can improve ICL ability by up to 18%, and that supportive data are characterized not by higher domain relevance but by heavier long-tail token mass and more challenging long-range context usage (Han et al., 2023).
Taken together, these results place ICEL at the intersection of test-time Bayesian updating, domain-conditioned risk minimization, and distributional properties of pretraining corpora.
4. Controlled synthetic settings and prompt-structured adaptation
Meta-in-context learning was first demonstrated in two idealized domains and one real-world benchmark. In 1D regression, each task is a linear function with input-target pairs, and prompts can include up to $5$ tasks. In the two-armed bandit setting, each task is a casino with two slot machines and $10$ trials, again with up to $5$ tasks included in context. The real-world benchmark uses $60$ regression datasets, filtered to 0, with 1 random input-output pairs per task and 2 numerical features. Across these settings, both trial number and task number significantly reduce error or regret, and on real-world regression GPT-3 after meta-in-context learning matches Bayesian Linear Regression and comes close to Random Forests (Coda-Forno et al., 2023).
ICL-HCG sharpens the role of explicit instructions. The model receives a literal encoding of a finite hypothesis class 3 followed by 4 pairs from a hidden 5. Under this setup, the paper defines four generalization scopes—ID Class, OOD Class, ID Size, and OOD Size—and reports that Transformers can master ICL-HCG and generalize across all four settings, while Mamba can sometimes outperform Transformers on OOD and conventional LSTM/GRU models perform at chance. Compared with ICL without instruction, ICL-HCG achieves significantly higher accuracy, demonstrating the role of instructions (Lin et al., 27 Feb 2025).
Context-enhanced learning extends the idea into gradient-based training. On the multi-level translation task, the paper proves in a simplified setting that context-enhanced learning can be exponentially more sample-efficient than standard learning when the model is capable of ICL, and attributes the gain to a more accurate gradient learning signal. The same work reports that it appears hard to detect or recover learning materials that were used in the context during training, which the authors note may have implications for data security as well as copyright (Zhu et al., 3 Mar 2025).
These controlled settings make explicit a general principle: when the prompt contains structured information about the hypothesis space or latent environment, the model’s in-context adaptation becomes more sample-efficient, more robust to distribution shift, and more amenable to mechanistic study.
5. Sequential decision-making and interactive agents
In reinforcement learning, ICEL appears as in-context policy adaptation from interaction histories. ICEE trains Transformers on multiple-episode trajectories and performs the exploration-exploitation trade-off directly in-context at inference time, without explicit Bayesian inference. On grid world environments, the paper reports that ICEE can learn to solve new RL tasks using only tens of episodes, a substantial improvement over the hundreds of episodes needed by the previous in-context learning method (Dai et al., 2024).
DICP addresses the limitation that prior in-context RL models merely imitate source RL algorithms and inherit their suboptimal behaviors. It trains a Transformer jointly as a policy model and a dynamics model with
6
then performs in-context model-based planning at test time by rolling out candidate actions inside the learned dynamics model. Across Darkroom variants and Meta-World, DICP achieves state-of-the-art performance while requiring significantly fewer environment interactions than baselines (Son et al., 26 Feb 2025).
SICQL combines dynamic programming and world modeling for in-context Q-learning. It uses a prompt-based multi-head transformer that predicts policy, value, and Q-functions conditioned on a compact prompt built by a pretrained world model; policy extraction is carried out with advantage-weighted regression,
7
The reported gains are especially pronounced when learning from suboptimal data (Liu et al., 2 Jun 2025).
Interactive theorem proving provides another stateful environment. COPRA repeatedly queries GPT-4 for tactic proposals inside a backtracking search over Lean or Coq proof states, serializing current state, past steps, error messages, failed tactics, and retrieved lemmas into the prompt. On miniF2F for Lean and CompCert tasks for Coq, COPRA significantly outperforms few-shot invocations of GPT-4 and compares favorably against finetuning-based approaches, outperforming ReProver on pass@1 for Lean (Thakur et al., 2023).
These systems emphasize that ICEL is not limited to passive prediction. It extends naturally to settings where the context is an action-conditioned trajectory, proof state, or online search history.
6. Multimodal and structured in-context environments
Multimodal ICEL introduces additional issues of formatting bias and cross-modal interference. Multimodal Contrastive In-Context Learning interprets ICL through key-value representational distance, proposes a linear mixed effects model to disentangle semantic and formatting effects, and introduces Anchored-by-Text ICL for resource-constrained hateful meme detection. The paper reports that semantic similarity can still drive helpful representational shifts even under unseen formats, and that Anchored-by-Text ICL improves F1 beyond zero-shot while representation analysis yields 8 (Miyanishi et al., 2024).
Prompt engineering over the label space is another multimodal route. “Manipulating the Label Space for In-Context Classification” proposes Label Distribution Enhancement and Visual Descriptions Enhancement so that fewer in-context examples convey denser information. On ImageNet, accuracy rises from 9 in a 4-shot setting to 0 with just 2 shots, surpassing CLIP by 1; on CUB-200, 1-shot accuracy rises from 2 to 3, 4 higher than CLIP (Chen et al., 2023).
UniICL systematizes unified multimodal in-context learning through a six-level capability-oriented taxonomy—Perception, Imitation, Conception, Deduction, Analogy, and Discernment—together with UniICL-760K, containing 5 curated 8-shot episodes across 15 subtasks, UniICL-Bench with 6 benchmark episodes, and the Context-Adaptive Prototype Modulator (CAPM). The paper argues that in unified multimodal models few-shot behavior is often non-monotonic and highly task-dependent, and presents CAPM as a plug-and-play architectural intervention to stabilize adaptation (Xu et al., 25 Mar 2026).
Structured In-context Environments (SIEs) push the notion of environment into RL finetuning for reasoning. Built automatically from large-scale structured data such as knowledge graphs, SIEs are presented as scalable, generalizable, and verifiable environments. The paper reports substantial improvements in in-domain structured reasoning and effective transfer to out-of-domain mathematical and logical reasoning tasks, and further finds that in partial SIEs LLMs can infer missing information through exploring the environment (Yu et al., 27 Sep 2025).
Across these multimodal and structured formulations, ICEL increasingly becomes a problem of selecting, encoding, and routing heterogeneous contextual evidence rather than merely appending more examples.
7. Design constraints, limitations, and open directions
A recurring limitation is context sensitivity itself. Multimodal and unified models remain highly sensitive to example selection and formatting, and the effect of more demonstrations can be non-monotonic (Miyanishi et al., 2024, Xu et al., 25 Mar 2026). In world models, both theory and experiment identify long context and diverse environments as the key conditions for the emergence of environment learning rather than mere environment recognition; architectures unable to process very long contexts plateau early and fail to realize EL-mode behavior (Wang et al., 26 Sep 2025).
Finite context windows are a direct bottleneck. Meta-in-context learning is explicitly described as limited by the LLM’s finite context window, with the suggestion that longer contexts and lower inference costs could operationalize context-only adaptation on much larger and more complex datasets (Coda-Forno et al., 2023). This suggests that some current failures of ICEL are capacity failures rather than conceptual failures.
Another open direction is test-time calibration of the prompt itself. Self-Improving In-Context Learning proposes optimizing continuous embeddings of a fixed few-shot prompt at test time using a self-supervised confidence proxy computed from teacher-forced log-probabilities on demonstration outputs. The method requires no finetuning, no token generation, no predefined label set, and no external data, and it consistently matches or improves upon the base model while showing statistically significant correlation between proxy improvement and downstream accuracy gain (Saglam et al., 22 May 2026). A plausible implication is that future ICEL systems may combine environmental context acquisition with online context optimization.
Finally, ICEL raises a methodological issue about what exactly has been learned. Context-enhanced learning shows that training can benefit from privileged context while making those contextual materials hard to detect or recover after training (Zhu et al., 3 Mar 2025). This does not negate ICEL’s utility, but it complicates attribution, auditing, and mechanistic interpretation.
ICEL therefore sits at a productive but unsettled intersection of prompting, meta-learning, world modeling, and test-time adaptation. The literature converges on a consistent picture: context can function as an environment, but realizing strong environmental adaptation depends on explicit structure, sufficient diversity, long effective memory, and mechanisms that let models use context to alter not only predictions but the procedures by which predictions are formed.