Prune4Web: DOM Tree Pruning Programming for Web Agent

Jiayuan Zhang, Kaiquan Chen, Zhihao Lu, Enshen Zhou, Qian Yu, Jing ZhangarXiv 2025 · DOI

Abstract

Modern web agents struggle with the massive scale of Document Object Model (DOM) trees, often leading to token truncation and attention dilution. Prune4Web introduces DOM Tree Pruning Programming (DTPP), a paradigm where the agent generates task-specific Python scoring programs to filter irrelevant elements. This approach reduces candidate elements by 25–50 times and boosts grounding accuracy from 46.8% to over 88%, enabling small open-source models to outperform large proprietary ones.

The DOM Scalability Bottleneck

Modern webpages are a nightmare for Large Language Models (LLMs). A single page can contain between 10,000 and 100,000 DOM tokens—far exceeding the effective context window of most models. When an agent tries to find a specific button in this "haystack," it faces two main issues:

  1. Token Truncation: Vital information is simply cut off to fit the model's limit.
  2. Attention Dilution: Even if the HTML fits, the model gets "distracted" by thousands of irrelevant tags, leading to poor localization.

Existing solutions usually rely on rigid, hand-coded heuristics or separate ranking models, which are often computationally expensive or fail on complex sites.

Methodology: DOM Tree Pruning Programming (DTPP)

The core innovation of Prune4Web is offloading the search process to a programmatic filter. Instead of the LLM acting as a search engine, it acts as a programmer.

Comparison of the existing Multi-Modal WebAgent paradigm vs. the Prune4Web paradigm.

The Three-Stage Pipeline

  1. Planner: Takes a high-level goal and a screenshot to generate a specific low-level sub-task (e.g., "Find the destination field").
  2. Programmatic Element Filter: The LLM generates a task-specific Python scoring program based on the sub-task. This program runs outside the LLM, traversing the full DOM to score elements based on visible text, aria-labels, and metadata.
  3. Action Grounder: Receives a "pruned" list of the top ~20 candidates and selects the final element to interact with.

To optimize this, the authors utilize Reinforcement Fine-Tuning (RFT) with a hierarchical reward system that penalizes the model if its generated program fails to include the "ground-truth" element in the final candidate list.

Key Results and Evaluation

The system was evaluated on the Multimodal-Mind2Web (MM2W) benchmark and a custom grounding benchmark. Prune4Web reduces the number of candidate elements by 25–50 times, typically narrowing hundreds of elements down to fewer than 20.

Model Recall Rate Comparison showing Prune4Web variants significantly outperforming GPT-4o baselines.

As shown in the recall comparison, the Prune4Web variants (based on Qwen) significantly outperform proprietary models like GPT-4o. On the grounding benchmark, accuracy skyrocketed from a baseline of 46.8% to 88.28%. The system achieved State-of-the-Art (SOTA) results across Cross-Task, Cross-Website, and Cross-Domain tests, demonstrating that semantic keyword extraction is a highly effective way to bypass LLM context limits.

Limitations and Future Work

While highly effective, the system's success depends heavily on the Planner. If the Planner generates a flawed sub-task, the downstream Filter and Grounder cannot recover the mission. Additionally, non-standard HTML (e.g., buttons without semantic tags) can still pose challenges for keyword-based matching. Future directions include exploring more powerful exploration mechanisms like Monte Carlo Tree Search (MCTS) to improve high-level planning reliability.

Summary updated

BibTeX
@misc{zhang2025prune,
  author = {Jiayuan Zhang and Kaiquan Chen and Zhihao Lu and Enshen Zhou and Qian Yu and Jing Zhang},
  title = {{Prune4Web: DOM Tree Pruning Programming for Web Agent}},
  year = {2025},
  eprint = {2511.21398},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.21398},
}
Figure