Leveraging In-Context Learning for Language Model Agents
On the map: LLM agents and tool use → General LLM agent frameworks and benchmarks
Abstract (arXiv)
In-context learning (ICL) with dynamically selected demonstrations combines the flexibility of prompting large language models (LLMs) with the ability to leverage training data to improve performance. While ICL has been highly successful for prediction and generation tasks, leveraging it for agentic tasks that require sequential decision making is challenging -- one must think not only about how to annotate long trajectories at scale and how to select demonstrations, but also what constitutes demonstrations, and when and where to show them. To address this, we first propose an algorithm that leverages an LLM with retries along with demonstrations to automatically and efficiently annotate agentic tasks with solution trajectories. We then show that set-selection of trajectories of similar tasks as demonstrations significantly improves performance, reliability, robustness, and efficiency of LLM agents. However, trajectory demonstrations have a large inference cost overhead. We show that this can be mitigated by using small trajectory snippets at every step instead of an additional trajectory. We find that demonstrations obtained from larger models (in the annotation phase) also improve smaller models, and that ICL agents can even rival costlier trained agents. Thus, our results reveal that ICL, with careful use, can be very powerful for agentic tasks as well.
Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Placed in General LLM agent frameworks and benchmarks, one of 16 directions in LLM agents and tool use. Builds on 33 of its 39 references that are in the map. First posted on arXiv 16 Jun 2025.
Builds on
33 of 39 references.
Closest ancestors · 3
Same direction, newest first
- 2024Agent Q: Advanced Reasoning and Learning for Autonomous AI Agents13 Aug
- 2024TRAD: Enhancing LLM Agents with Step-Wise Thought Retrieval and Aligned Decision10 Mar
- 2023Describe, Explain, Plan and Select: Interactive Planning with Large Language Models Enables Open-World Multi-Task Agents3 Feb
Other references · 30
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2017Proximal Policy Optimization Algorithmscited by 15,215
- 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 9,379
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,695
- 2019BERTScore: Evaluating Text Generation with BERTcited by 5,512
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,455
- 2023WebArena: A Realistic Web Environment for Building Autonomous Agentscited by 2,006
- 2023ToolLLM: Facilitating Large Language Models to Master 16000+ Real-world APIscited by 1,947
- 2021WebGPT: Browser-assisted question-answering with human feedbackcited by 1,745
- 2021Calibrate Before Use: Improving Few-Shot Performance of Language Modelscited by 1,392
- 2022WebShop: Towards Scalable Real-World Web Interaction with Grounded Language Agentscited by 1,251
- 2023Mind2Web: Towards a Generalist Agent for the Webcited by 1,242
18 more
- 2020ALFWorld: Aligning Text and Embodied Environments for Interactive Learningcited by 1,205
- 2021Learning To Retrieve Prompts for In-Context Learningcited by 648
- 2024AppWorld: A Controllable World of Apps and People for Benchmarking Interactive Coding Agentscited by 401
- 2023Language Models can Solve Computer Taskscited by 372
- 2024WorkArena: How Capable Are Web Agents at Solving Common Knowledge Work Tasks?cited by 363
- 2017Thinking Fast and Slow with Deep Learning and Tree Searchcited by 252
- 2022Selective Annotation Makes Language Models Better Few-Shot Learnerscited by 243
- 2023InterCode: Standardizing and Benchmarking Interactive Coding with Execution Feedbackcited by 238
- 2023Synapse: Trajectory-as-Exemplar Prompting with Memory for Computer Controlcited by 187
- 2022In-context Examples Selection for Machine Translationcited by 172
- 2022Diverse Demonstrations Improve In-context Compositional Generalizationcited by 139
- 2025Reinforcement Learning for Long-Horizon Interactive LLM Agentscited by 108
- 2024AgentInstruct: Toward Generative Teaching with Agentic Flowscited by 89
- 2022Complementary Explanations for Effective In-Context Learningcited by 71
- 2023PEARL: Prompting Large Language Models to Plan and Execute Actions Over Long Documentscited by 61
- 2023Coverage-based Example Selection for In-Context Learningcited by 59
- 2024SUPER: Evaluating Agents on Setting Up and Executing Tasks from Research Repositoriescited by 52
- 2023GistScore: Learning Better Representations for In-Context Example Selection with Gist Bottleneckscited by 6
Built on by
Citing papers per year: 2025: 2; 2026: 2.
4 papers.
- 2026On the Reliability of Computer Use Agentscited by 10
- 2025Watch and Learn: Learning to Use Computers from Online Videoscited by 9
- 2026Not All Skills Help: Measuring and Repairing Agent Knowledgecited by 6
- 2025From Benchmarks to Business Impact: Deploying IBM Generalist Agent in Enterprise Productioncited by 5
- 2026Not All Skills Help: Measuring and Repairing Agent Knowledge13 Jun 2026
- 2026On the Reliability of Computer Use Agents20 Apr 2026
- 2025From Benchmarks to Business Impact: Deploying IBM Generalist Agent in Enterprise Production27 Oct 2025
- 2025Watch and Learn: Learning to Use Computers from Online Videos6 Oct 2025
Similar, not cited
Close in wording, no citation either way
- 2025DICE: Dynamic In-Context Example Selection in LLM Agents via Efficient Knowledge Transfer
- 2025Self-Generated In-Context Examples Improve LLM Agents for Sequential Decision-Making Tasks
- 2024Does In-Context Learning Really Learn? Rethinking How Large Language Models Respond and Solve Tasks via In-Context Learning
- 2026CB-Agent: Concept-Based In-Context Learning for Sequential Action Selection
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?
- 2024LLMs Are In-Context Bandit Reinforcement Learners
- 2024Large Language Models Know What Makes Exemplary Contexts
- 2026Spinning Straw into Gold: Relabeling LLM Agent Trajectories in Hindsight for Successful Demonstrations