← Latest papers
🤖 AI

AgentHER: Hindsight Experience Replay for LLM Agent Trajectory Relabeling

AgentHER is a framework that adapts Hindsight Experience Replay to relabel failed LLM agent trajectories as valid demonstrations for alternative goals, significantly boosting training efficiency and performance across various model families by converting discarded failures into high-quality supervised and preference learning data.

Original authors: Liang Ding

Published 2026-03-24
📖 4 min read☕ Coffee break read

Original authors: Liang Ding

Original paper dedicated to the public domain under CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.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 robot butler how to cook dinner.

The Old Way (Standard Training):
You tell the robot, "Make me a steak."

  • Scenario A: The robot successfully cooks a perfect steak. You say, "Great job!" and save that video as a lesson.
  • Scenario B: The robot burns the steak because it set the heat too high. You say, "Fail!" and immediately delete the video, throwing it in the trash.

You do this 100 times. You keep the 20 "perfect steak" videos and throw away the 80 "burnt steak" videos. You think you are learning from your mistakes, but you are actually throwing away 80% of your experience. The burnt steak videos actually contain useful information: "The robot knows how to chop the onions," "It knows how to turn on the stove," and "It knows the pan gets hot." It just failed at the final temperature check.

The New Way (AgentHER):
This paper introduces a system called AgentHER (Hindsight Experience Replay for Agents). It changes the rule: Don't throw away the burnt steak. Just change the recipe.

Instead of saying, "This video is useless because it didn't make a steak," AgentHER looks at the video and asks: "What did this robot actually succeed at?"

Maybe the robot successfully found a steak, chopped the onions, and heated the pan, but then burned it. AgentHER rewrites the goal of that video from "Make a perfect steak" to "Prepare a steak up to the point of burning" or "Find a steak and chop onions."

Suddenly, that "failed" video becomes a perfect example of a new, achievable task. You now have 80 extra lessons instead of throwing them away.

The Four-Step "Kitchen" Process

The authors built a four-stage pipeline to automate this "rewriting the recipe" process:

  1. The Detective (Failure Detector):
    The system looks at the burnt steak video and asks, "Is this a total disaster, or just a small mistake?"

    • If the robot set the stove on fire (a catastrophic error), the video is trash.
    • If the robot just burned the meat (a recoverable error), the video is saved for the next step.
  2. The Summarizer (Outcome Extractor):
    The system watches the video and writes a list of what actually happened.

    • Result: "Found steak," "Chopped onions," "Heated pan to 400°F."
    • This ensures the system doesn't make things up (hallucinate) when rewriting the goal.
  3. The Editor (Prompt Relabeler):
    This is the magic step. An AI editor looks at the list of achievements and writes a new goal that matches the video perfectly.

    • Old Goal: "Cook a medium-rare steak." (Failed)
    • New Goal: "Prepare a steak and chop onions." (Success!)
    • Safety Check: Two independent editors (judges) must agree that the new goal is fair before the video is saved. This prevents the system from lying about what the robot did.
  4. The Teacher (Data Augmenter):
    The system packages this new "New Goal + Video" pair into a training lesson. It teaches the robot: "Hey, if you want to chop onions, this is how you do it!"

Why This is a Big Deal

  • Double the Lessons: By using the "failed" videos, the robot learns twice as fast. The paper shows that using AgentHER, a robot can learn as well with 50% fewer successful examples than before.
  • Better for Smaller Brains: Smaller AI models (like a 7-billion parameter model) benefit the most. They are often "smart enough" to do the steps but "dumb enough" to miss the final goal. AgentHER gives them the specific practice they need.
  • Real-World Proof: They tested this on two difficult real-world tasks:
    • WebArena: Navigating websites to buy things or find info.
    • ToolBench: Using APIs and software tools.
    • Result: The robots got significantly better at their jobs (improving success rates by 7% to 11%), which is a huge jump in the AI world.

The "Hindsight" Metaphor

Think of it like a sports coach.

  • Old Coach: "You missed the shot! Go home, we only study the videos where you scored."
  • AgentHER Coach: "You missed the shot, but you ran a perfect play, passed the ball perfectly, and got into the right position. Let's watch that video and say, 'Great job on the pass and positioning!' Next time, we just work on the final shot."

The Bottom Line

AgentHER teaches us that in the world of AI, failure is not the opposite of success; it is just success with the wrong label. By simply changing the label (the goal) to match what actually happened, we can turn a mountain of wasted failures into a goldmine of training data, making AI agents smarter, faster, and more efficient.

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 →