← Latest papers
🤖 machine learning

Training Language Agents to Learn from Experience

This paper introduces the In-context Training (ICT) framework and a reinforcement learning-based pipeline that enables language agents to distill experience from past interactions into reusable system prompts, thereby achieving cross-task self-improvement and generalization to unseen environments without human supervision.

Original authors: Yuval Shalev, Zifeng Ding, Mateja Jamnik

Published 2026-05-21
📖 4 min read☕ Coffee break read

Original authors: Yuval Shalev, Zifeng Ding, Mateja Jamnik

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are teaching a very smart, but slightly naive, robot how to play video games.

The Problem: The "One-and-Done" Amnesia
Currently, these AI robots (called "Language Agents") are good at learning from their mistakes, but only in a very specific way. If they fail a level in a game, they can look back, say, "Oh, I hit the wrong wall," and try again immediately. They get better at that specific level.

However, once they beat that level, they forget everything. If you give them a new level that is slightly different, they act like they've never played the game before. They have to re-learn the lesson from scratch. It's like a student who studies hard for a math test, gets an A, and then walks into a physics class the next day as if they've never seen a number before. They can't "distill" the general lessons (like "always check your surroundings") into a reusable rulebook.

The Solution: The "Coach" and the "Player"
The authors of this paper introduced a new framework called In-context Training (ICT). Think of it as a two-person team:

  1. The Player (The Actor): This is the robot trying to solve the tasks. It plays the game, makes mistakes, and collects a "replay" of what happened.
  2. The Coach (The Reflector): This is a second AI that watches the Player's replays. The Coach's job isn't to play the game; it's to write a new instruction manual (a system prompt) for the Player.

Here is the magic: The Coach doesn't just say, "Don't hit that wall." It looks at a batch of different levels the Player just tried, finds common patterns, and writes a general rule for the Player to use on future, unseen levels.

The Training: Learning to Coach
The big question was: Can we teach the Coach how to write these better manuals?

The researchers didn't use human teachers or pre-written examples. Instead, they used a "trial and error" loop (Reinforcement Learning):

  1. The Coach writes a manual.
  2. The Player tries to solve a batch of new, unseen puzzles using that manual.
  3. If the Player does well, the Coach gets a "good job" signal. If the Player fails, the Coach gets a "try again" signal.
  4. The Coach learns from this feedback to write even better manuals next time.

The Results: From Chess to Cooking
The team tested this on two very different "video games" (simulated environments):

  • ALFWorld: A text-based house where the robot has to find objects, clean them, and put them in specific places (like "cool a potato and put it in the fridge").
  • MiniHack: A grid-world game where the robot has to navigate mazes, eat food, or use magic wands.

What they found:

  • The Coach got smarter: The trained Coaches were much better at writing instruction manuals than untrained ones. They successfully taught the Player how to solve new types of puzzles it had never seen before, just by looking at examples from different types of puzzles.
  • Cross-Game Magic: In a surprising twist, they took a Coach trained only on the grid-world game (MiniHack) and asked it to coach the Player on the house game (ALFWorld). Even though the games were totally different, the Coach still managed to write a manual that helped the Player perform better than a robot with no coaching at all. It learned the skill of learning, not just the specific game rules.
  • More Turns, Better Results: The more the Coach practiced writing manuals (going through more "meta-turns"), the better the Player got, even beyond the number of practice rounds the Coach had seen during training.

The Toolkit: MetaGym
Finally, the authors released a free software tool called MetaGym. Think of this as a "Lego kit" for researchers. It allows anyone to easily build their own "Coach vs. Player" training environments to test if their AI can learn from experience.

In a Nutshell
This paper proves that AI agents can be trained to stop being "amnesiacs." By using a Coach that watches the Player's experiences and writes better rules for the future, the AI can learn general lessons that apply to new, unseen challenges. It's the difference between a robot that memorizes one map and a robot that learns how to read any map.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →