RF-Agent: Automated Reward Function Design via Language Agent Tree Search

Ning Gao, Xiuhui Zhang, Xingyu Jiang, Mukang You, Mohan Zhang, Yue Deng

TL;DR

RF-Agent is a novel framework that automates the design of complex reward functions for reinforcement learning by treating the process as a sequential decision-making task. By integrating Large Language Models (LLMs) with Monte Carlo Tree Search (MCTS), it explores the space of potential reward functions more efficiently than previous greedy or evolutionary methods, outperforming human experts across 17 diverse robotic control tasks.

What Problem Does This Paper Address?

In Reinforcement Learning (RL), the "reward function" is the signal that tells an agent what it’s doing right. While simple goals (like "did the robot reach the door?") are easy to define, they are often too "sparse" for an agent to learn complex motor skills. To solve this, researchers use reward shaping—creating dense, multi-part reward functions that guide the agent step-by-step.

Traditionally, humans hand-craft these functions, which is time-consuming and requires deep expertise. Recent attempts to use LLMs to automate this process (like Eureka) typically rely on greedy iterative refinement or evolutionary algorithms. However, these methods often get stuck in local optima, fail to utilize the full history of failed attempts, and struggle with the vast search space of complex manipulation tasks.

Methods

To overcome these limitations, the authors propose RF-Agent, which frames reward design as a search problem on a tree.

Comparison of reward design methods: Greedy, Evolutionary, and RF-Agent's Tree Search.
  1. LLM as a Language Agent: Instead of just generating code, the LLM acts as an agent that makes decisions about how to improve a reward function based on previous training feedback.
  2. Monte Carlo Tree Search (MCTS): RF-Agent uses MCTS to manage the search process. This allows it to balance exploration (trying radically different reward structures) and exploitation (fine-tuning a promising reward).
  3. Diverse Action Types: During the "Expansion" phase of MCTS, the LLM can choose from several heuristic actions:
  4. Mutation: Local tweaks to parameters or components.
  5. Crossover: Combining successful components from different high-performing reward functions (the "Elite Set").
  6. Path Reasoning: Analyzing the entire history of a specific branch to understand why certain changes worked.
  7. Different Thought: Intentionally generating a structurally different approach to avoid premature convergence.
  8. Self-Verification & Thought Alignment: To mitigate LLM hallucinations, the framework includes a "self-verify" score where the LLM evaluates its own code against the task description. It also uses a "thought alignment" step to ensure the generated Python code actually matches the intended design logic.

Datasets

The researchers evaluated RF-Agent on two major benchmarks for low-level robotic control:

  • IsaacGym: 7 tasks including locomotion (Ant, Humanoid) and manipulation (AllegroHand, ShadowHand).
  • Bi-DexHands: 10 complex dual-arm manipulation tasks, categorized into "Expert-Easy" and "Expert-Hard" (e.g., twisting a bottle cap, rotating a cup, or stacking blocks).
  • OOD Tasks: They also introduced two entirely new "Out-of-Distribution" tasks—Ant Lie Down and Ant Patrol and Return—to test the model's ability to generalize to novel scenarios not found in standard RL benchmarks.

Key Insights and Ideas

  • Search vs. Iteration: The core "aha moment" is that reward design isn't just a linear iterative process; it’s a branching search. By using a tree structure, the agent can "backtrack" from a dead end and try a different path using insights gained from the failure.
  • Global Context Matters: Previous methods only looked at the last reward function. RF-Agent uses "Crossover" and "Path Reasoning" to synthesize information from across the entire search tree, effectively learning from the "global" history of the optimization process.
  • LLMs as Evaluators: The "Self-Verify" score acts as a valuable prior. By asking the LLM to imagine how an expert would solve the task and then compare its generated reward to that vision, the system can prune poor candidates before wasting expensive GPU hours on RL training.

Key Results

RF-Agent demonstrates significant improvements over both human baselines and prior LLM-driven methods.

Performance comparison of RF-Agent against baselines across IsaacGym tasks.
  • SOTA Performance: RF-Agent achieved an average normalized score of 2.68 on IsaacGym tasks (where 1.0 is human expert performance), significantly higher than Eureka (2.00) and Revolve (2.03).
  • Superiority in Complex Tasks: In the "Expert-Hard" tasks of Bi-DexHands, RF-Agent maintained high success rates where previous LLM-based methods often failed to reach even half of human performance.
  • Model Agnostic: While it performs best with GPT-4o, RF-Agent using the much smaller GPT-4o-mini still outperformed human experts and other SOTA methods using larger models (achieving a 1.70 normalized score).
  • Efficiency: It identifies high-performing reward functions with fewer total RL training cycles compared to evolutionary baselines, thanks to its more informed search strategy.

Limitations and Future Work

  • Computational Cost: While more efficient in its search, the framework still requires running full RL training sessions for every node in the tree, which is computationally expensive and time-consuming.
  • Token Consumption: Because RF-Agent feeds historical paths and elite sets back into the prompt, it uses significantly more "prefill" tokens than simpler iterative methods.
  • Future Directions: The authors suggest focusing on reducing the number of required RL training iterations, perhaps by using "proxy" evaluations or world models to predict reward quality without full training.

Summary updated

BibTeX
@inproceedings{gao2025rf,
  author = {Ning Gao and Xiuhui Zhang and Xingyu Jiang and Mukang You and Mohan Zhang and Yue Deng},
  title = {{RF-Agent: Automated Reward Function Design via Language Agent Tree Search}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=dZ94ZS410X},
}
Figure