WebAgent-R1: Training Web Agents via End-to-End Multi-Turn Reinforcement Learning

Zhepei Wei, Wenlin Yao, Yao Liu, Weizhi Zhang, Qin Lu, Liang Qiu, Changlong Yu, Puyang Xu, Chao Zhang, Bing Yin, Hyokun Yun, Lihong Li

Abstract

While reinforcement learning (RL) has demonstrated remarkable success in enhancing large language models (LLMs), it has primarily focused on single-turn tasks such as solving math problems. Training effective web agents for multi-turn interactions remains challenging due to the complexity of long-horizon decision-making across dynamic web interfaces. In this work, we present WebAgent-R1, a simple yet effective end-to-end multi-turn RL framework for training web agents. It learns directly from online interactions with web environments by asynchronously generating diverse trajectories, entirely guided by binary rewards depending on task success. Experiments on the WebArena-Lite benchmark demonstrate the effectiveness of WebAgent-R1, boosting the task success rate of Qwen-2.5-3B from 6.1% to 33.9% and Llama-3.1-8B from 8.5% to 44.8%, significantly outperforming existing state-of-the-art methods and strong proprietary models such as OpenAI o3. In-depth analyses reveal the effectiveness of the thinking-based prompting strategy and test-time scaling through increased interactions for web tasks. We further investigate different RL initialization policies by introducing two variants, namely WebAgent-R1-Zero and WebAgent-R1-CoT, which highlight the importance of the warm-up training stage (i.e., behavior cloning) and provide insights on incorporating long chain-of-thought (CoT) reasoning in web agents.

The Challenge of Multi-Turn Web Navigation

While large language models (LLMs) have become proficient at single-turn reasoning, they often struggle as "agents" in dynamic, multi-turn environments like the web. Web navigation is a "long-horizon" problem: a single mistake in step one (like clicking the wrong menu) can make the final goal impossible to reach.

Previous approaches relied heavily on Behavior Cloning (BC)—simply imitating human clicks—which fails when the agent encounters a state it hasn't seen before. Existing Reinforcement Learning (RL) methods for agents were often "off-policy," meaning they trained on old data, which is inefficient and prone to errors in rapidly changing web interfaces. Furthermore, keeping track of thousands of tokens of HTML code over multiple turns quickly exhausts a model's memory.

The WebAgent-R1 Framework

WebAgent-R1 addresses these challenges through three primary innovations:

  1. M-GRPO (Multi-turn Group Relative Policy Optimization): An extension of the GRPO algorithm. It allows the model to learn from a "group" of parallel attempts at the same task. By comparing these attempts, the model identifies which sequences of actions lead to success without needing a separate, complex "critic" model to estimate value.
  2. Dynamic Context Compression: To solve the memory bloat of multi-turn HTML processing, the framework keeps the full HTML for the current step but replaces previous steps' HTML with simplified templates. This preserves the history of actions while keeping the total token count manageable.
  3. Thinking-based Prompting: The agent is trained to use a <think> block before generating an action. This "Chain-of-Thought" (CoT) allows the model to decompose high-level goals and reason about the dynamic changes in the web interface before committing to a click or keystroke.
Figure 4: Overview of the WebAgent-R1 framework, including the action space, M-GRPO training loop, and the multi-turn interaction format with thinking processes.

The training follows a two-stage pipeline: a "warm-up" phase using Behavior Cloning on expert data, followed by the end-to-end RL phase. The authors found that unlike math-based RL, web agents require this BC warm-up to avoid producing "ill-formed" actions that never receive positive rewards.

Experimental Setup

The framework was evaluated using the following datasets:

  • WebArena / WebArena-Lite: Realistic, self-hosted websites (Reddit, GitLab, OpenStreetMap, etc.) used for training (647 tasks) and evaluation (165 human-verified tasks).
  • WebVoyager: Used for Out-of-Distribution (OOD) evaluation on domains like Coursera and Amazon to test generalization.
  • Expert Trajectories: A set of 9,460 trajectories used for the initial Behavior Cloning phase.

Performance and Key Insights

WebAgent-R1 achieved massive performance gains, particularly for smaller open-source models. As shown in the results, the 8B WebAgent-R1 model outperformed massive proprietary models like OpenAI o3 and GPT-4o on the WebArena-Lite benchmark.

Figure 1: Success rate comparison across different model sizes. WebAgent-R1 (red stars) significantly outperforms both prompting and fine-tuning baselines, including proprietary models.

Key findings from the analysis include:

  • Thinking Leads to Persistence: "Thinking" doesn't just improve accuracy; it makes the model more persistent. Models using the thinking format engaged in significantly more interaction turns (e.g., 17 turns vs. 6 turns for Qwen-2.5-3B), navigating deeper into complex tasks.
  • Test-Time Scaling: A "scaling law" was discovered for web agents: increasing the maximum allowed interaction turns at inference time consistently improves the success rate across all model types.
  • Generalization: On unseen WebVoyager domains, WebAgent-R1 maintained a 32% average success rate, nearly triple the performance of the SFT-only baseline (12%).

Limitations and Future Work

Despite its success, WebAgent-R1 has several limitations. It is currently text-only, ignoring visual information like layout and images. It relies on rule-based rewards (like URL matching), making it difficult to train on subjective tasks. The action space is fixed, limiting its ability to adapt to new browser interactions. Finally, the authors emphasize the need for strict permission controls when deploying autonomous agents in live environments to prevent accidental destructive actions.

Summary updated

BibTeX
@inproceedings{wei2025webagent,
  author = {Zhepei Wei and Wenlin Yao and Yao Liu and Weizhi Zhang and Qin Lu and Liang Qiu and Changlong Yu and Puyang Xu and Chao Zhang and Bing Yin and Hyokun Yun and Lihong Li},
  title = {{WebAgent-R1: Training Web Agents via End-to-End Multi-Turn Reinforcement Learning}},
  booktitle = {WCUA @ ICML},
  year = {2025},
  url = {https://openreview.net/forum?id=KqrYTALRjH},
}
Figure