Where Should LLM Agents Adapt at Test Time? In Context, in Weights, or Both
Parsa Mirtaheri, Mohammadreza Armandpour, Keivan Alizadeh, Iman Mirzadeh, Parshin Shojaee, Aryo Lotfi, David Harrison, Mehrdad Farajtabar
Abstract
LLM agents operating repeatedly in the same environment, such as a code repository, a database, or an application suite, encounter tasks that share latent structure. Experience can reveal this structure, allowing agents to reuse environment knowledge and learn from environmental feedback. Agents can adapt at test-time using this experience through two channels: retaining it in context and updating their weights. These channels are usually studied separately, leaving unclear what each contributes and when they complement each other. We compare in-context learning (ICL), reinforcement learning with verifiable rewards using GRPO, and self-distillation using SDPO, alone and in combination, using a shared online protocol and modular framework. Agents encounter matched task streams, are evaluated on each task before adapting to it, and learn only from their own attempts and environment feedback. We evaluate 14 adaptation mechanisms and a stateless baseline with Qwen3.5-9B on 109 tasks from four environments drawn from SWE-bench Verified, AppWorld, ScienceWorld, and BIRD-Critic-SQLite, using five task orders per environment. ICL provides the largest standalone gain: its best policy raises mean success across environments from 28.8% to 49.4%. Adding GRPO to this policy achieves the highest mean success, 51.6%. While adding GRPO improves the overall mean under every ICL policy, SDPO has mixed effects. Trace analyses show fewer lookups and shorter attempts under ICL, consistent with reusing knowledge of the shared structure. However, ICL also frequently skips inspection and verification for the current task. Adding GRPO to ICL helps restore these behaviors while preserving its reduced environment lookups. These observations suggest that reinforcement learning with verifiable rewards can refine how agents use retained experience, motivating the joint study of context management and weight updates.
Create a lesson
Metadata
- Categories
- cs.LG, cs.AI, cs.CL
Related papers
Bridging the Gap between Continual Learning and Test-Time Adaptation with Domain Preview
Shared title terminologycs.LGFrédéric Li Combeau, Nicolas Michel, Toshihiko Yamasaki
Anytime-Valid PAC-Bayes Certificates for Adaptive Test-Time Scaling
Shared title terminologycs.LGXiaoyu Li, Jiangxuan Long
Severe but Harmless: Stress-Testing Shift Severity for Frozen Time-Series Forecasters
Shared title terminologycs.LGKorede R. Bishi, Dominic Okonkwo, Adetayo Okunoye
The Price of Choosing Examples: Context Overfitting in Adaptive In-Context Learning
Shared title terminologycs.LGXiaoyu Li, Jiangxuan Long
Microfitting: Continual Learning via Cached Test-Time Training
Shared title terminologycs.LGNick Ryan, Peter A. Devine, Ben Sirb et al.
Test-Time Constraint-Aware Diffusion Predictive Control
Shared title terminologycs.LGBraghadeesh Lakshminarayanan, Ojas Phadake, Qi Chen et al.