Tree Search for Language Model Agents

Jing Yu Koh, Stephen Marcus McAleer, Daniel Fried, Ruslan Salakhutdinov

Abstract

Autonomous agents powered by language models (LMs) have demonstrated promise in their ability to perform decision-making tasks such as web automation. However, a key limitation remains: LMs, primarily optimized for natural language understanding and generation, struggle with multi-step reasoning, planning, and using environmental feedback when attempting to solve realistic computer tasks. Towards addressing this, we propose an inference-time search algorithm for LM agents to explicitly perform exploration and multi-step planning in interactive web environments. Our approach is a form of best-first tree search that operates within the actual environment space, and is complementary with most existing state-of-the-art agents. It is the first tree search algorithm for LM agents that shows effectiveness on realistic web tasks. On the challenging VisualWebArena benchmark, applying our search algorithm on top of a GPT-4o agent yields a 39.7% relative increase in success rate compared to the same baseline without search, setting a state-of-the-art success rate of 26.4%. On WebArena, search also yields a 28.0% relative improvement over a baseline agent, setting a competitive success rate of 19.2%. Our experiments showcase the effectiveness of search for web agents, and we demonstrate that performance scales with increased test-time compute.

Introduction: The Compounding Error Problem

While Large Language Models (LLMs) have become remarkably proficient at following instructions, they often falter when acting as autonomous agents in complex, multi-step environments like the web. Most current agents operate "greedily," taking one action at a time without foresight or the ability to correct mistakes. In a web browser, the action space is vast—every link, button, and text box represents a potential move. If an agent clicks the wrong link or enters a loop, it typically has no recovery mechanism. This "compounding error" problem is a significant bottleneck. This paper argues that agents require the same capabilities that drove AI success in games like Chess and Go: the ability to search through possible future states and backtrack when a path proves unproductive.

The proposed search procedure is grounded in the actual environment space and consists of three primary components:

  1. Agent Backbone: Off-the-shelf LLMs (e.g., GPT-4o or Llama-3) propose candidate actions. Instead of selecting only the most likely action, the system samples multiple plausible "branches" at each step.
  2. Value Function ($f_v$): A multimodal LLM evaluates the task instruction and current screenshot to estimate the probability of success. To enhance reliability, self-consistency is employed: the model generates 20 reasoning chains, and the final score is the average.
  3. Best-First Search Algorithm: Inspired by A* search, the agent maintains a "frontier" of possible states, always expanding the state with the highest value score. If a path's value drops, the agent backtracks by resetting the environment and attempting a different branch from the frontier.
Comparison between a greedy GPT-4o agent and one utilizing tree search. The search-enabled agent successfully backtracks from low-value states to find a successful path.

Experimental Evaluation

The method was evaluated on two primary benchmarks for web-based agents:

  • WebArena (WA): A suite of 812 tasks across five realistic, self-hosted websites (e.g., GitLab, Reddit, and a shopping site).
  • VisualWebArena (VWA): A multimodal extension of WebArena with 910 tasks that require the agent to process visual information (like finding a specific item based on an image).

Key Results and Insights

The addition of tree search provided a substantial performance boost across all evaluated models and benchmarks. Qualitative analysis revealed that search effectively solves common failure modes, such as "undoing" correct actions or getting stuck in loops, by allowing the agent to "teleport" back to successful intermediate states.

Performance comparison across WebArena (WA) and VisualWebArena (VWA) benchmarks. Tree search significantly improves success rates for both GPT-4o and Llama-3 models.

Key findings include:

  • State-of-the-Art Performance: A GPT-4o agent with search reached a 26.4% success rate on VWA, a 39.7% relative increase over the baseline (18.9%). On WebArena, the agent achieved a 19.2% success rate, a 28.0% relative improvement.
  • Scaling with Compute: Performance improves as the search budget (number of node expansions) increases, demonstrating that agents benefit from additional test-time compute.
  • Model Agnostic Benefits: Search significantly aided smaller models; a Llama-3-70B agent saw its success rate on VWA jump from 7.6% to 16.7% (a 119% relative increase).
  • Complexity Handling: The most significant gains occurred in "medium" difficulty tasks (4–9 actions), where success rates improved by 75%.

Limitations and Future Outlook

Despite its effectiveness, search introduces challenges in latency and cost, as a search budget of 20 may require 20x more LLM calls. Furthermore, "destructive" actions (e.g., making a purchase or deleting an account) cannot be easily undone, necessitating future "safety classifiers" to prune such branches. Current backtracking also requires inefficient environment resets, highlighting the need for better "save state" mechanisms in web environments that do not natively support them.

Summary updated

BibTeX
@article{koh2025tree,
  author = {Jing Yu Koh and Stephen Marcus McAleer and Daniel Fried and Ruslan Salakhutdinov},
  title = {{Tree Search for Language Model Agents}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=QF0N3x2XVm},
}
Figure