arXiv:2610.23051cs.AIOct 2026

Manuscript Offprint

arXiv:2610.23051

Agentic In-Context Learning: What Algorithms Can Transformers Learn in Closed-Loop Interaction?

Shiguang Wu, Yaqing Wang, Quanming Yao

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

ABSTRACT

The learning algorithm view of in-context learning (ICL) studies how fixed-parameter Transformers learn from supplied examples. Language model agents extend this setting through interaction: their actions determine what evidence enters context next. We call this regime Agentic In-Context Learning (Agentic ICL). Existing studies largely depend on externally supplied contexts or reward-bearing interaction histories, while work on general tool-using agents lacks a learning algorithm view. We represent an interactive learner by its state, update, and decision rule, covering active learning, bandits, and online reinforcement learning (RL). For expressivity, we construct causal Transformers that approximate these algorithms over a finite horizon, and bound the resulting loss in return. For training, we characterize when optimizing process rewards preserves behavior that maximizes the final outcome. Distillation experiments show that Transformers can learn to execute three representative recursions. We then train models from outcome or process rewards without oracle action or state targets, as in RL post-training. Different rewards yield distinct decision policies. Improving the alignment of process supervision with outcome-optimal action preferences shifts learned decisions accordingly. Such behavioral differences persist in a pretrained language model across textual paraphrases.

1 INTRODUCTION

In-context learning (ICL) is a central way in which language models adapt at inference time: information in the prompt changes subsequent predictions while the model parameters remain fixed. This has motivated a learning algorithm view of ICL, which asks what estimator, update rule, or other learning computation a Transformer (Vaswani et al., 2017) implements through its forward passes over an externally supplied prompt (Xie et al., 2022; Garg et al., 2022; Akyürek et al., 2023; von Oswald et al., 2023; Bai et al., 2023; Wu et al., 2025).

Modern language-model agents routinely operate in an analogous but closed-loop regime. An agent can browse the web, call tools, edit code, or run experiments, then use the returned results to choose later actions (Yao et al., 2023; Shinn et al., 2023; Zhao et al., 2024; Lutz et al., 2024). A search query determines which page is read, a code edit determines the next test result, and an experiment determines the next measurement. The agent therefore does not merely learn from a supplied context: through its actions, it helps determine the context from which it will learn next.

We call this execution regime Agentic In-Context Learning (Agentic ICL). Starting from an initial prompt or task description, a fixed-parameter model chooses an action, receives feedback, and incorporates that feedback into its next decision. Its context grows through interaction with the environment. The returned feedback can be a search result, compiler error, measurement, critique, or reward. This motivates extending the learning algorithm view of ICL to interactive computations in which decisions shape subsequent evidence. The central question is:

What interactive algorithms can Transformers learn in context, and how do training objectives shape their behavior?

Figure

Figure 1: Illustrative comparison of Agentic ICL, ICL and ICRL. Agentic ICL studies how agents solve general agentic tasks.

In-context reinforcement learning (ICRL) provides the closest precedent (Laskin et al., 2023; Lee et al., 2023; Lin et al., 2024; Wang et al., 2025; Liang & Lai, 2026), but requires scalar rewards to be included in the interaction history. However, an agent usually receives non-reward feedback: a search result, compiler diagnostic, or measurement can guide the next action. We therefore develop Agentic ICL allowing agents to learn from non-reward feedback. This also separates the evidence used for in-context adaptation from the objective used for training and evaluation. Agentic ICL includes ICRL as a special case. Figure 1 illustrates this relationship.

Task performance alone does not reveal the interactive algorithm. Answering these questions requires both a construction showing what Transformers can execute and experiments examining what they learn under different objectives. Our contributions are fourfold:

• Closed-loop framework (Section 3). We factor an interactive learner into a sufficient state, a feedback update, and a decision rule. The same interface covers active learning, bandits, and online RL.

• Transformer realization (Section 4). We give a constructive proof that compiles regular finite-horizon recursions into causal Transformers. The construction realizes their action choices and yields a bound on autonomous return loss.

• Training objectives and diagnosis (Section 5). We theoretically characterize when process supervision preserves outcome-optimal behavior, then develop behavioral diagnostics for trained Transformers.

• What training learns (Section 6). Supervised distillation tests learned execution of supplied interactive recursions. RL without oracle action shows how outcome and process rewards lead to different decisions, and how those decisions change with controllable reward intervention.

References (100)

Couldn't load all references. Reload the page to try again.