Table of Contents
Fetching ...

Prune4Web: DOM Tree Pruning Programming for Web Agent

Jiayuan Zhang, Kaiquan Chen, Zhihao Lu, Enshen Zhou, Qian Yu, Jing Zhang

TL;DR

Prune4Web introduces a DOM Tree Pruning Programming paradigm to tackle the information overload of large DOMs in LLM-based web agents. By shifting element localization from direct DOM comprehension to generating lightweight Python scoring programs, the framework dramatically reduces candidate elements (by 25–50x) and enables precise grounding, guided by a planning stage and a downstream grounding stage. A data synthesis pipeline and a two-turn dialogue training strategy jointly optimize planning, filtering, and grounding, achieving state-of-the-art grounding accuracy (88.28%) on low-level sub-tasks and strong overall performance on standard benchmarks. The approach demonstrates substantial practical impact by enabling scalable, accurate web automation on real-world, complex webpages and by showing plug-and-play compatibility with existing agents.

Abstract

Web automation employs intelligent agents to execute high-level tasks by mimicking human interactions with web interfaces. Despite the capabilities of recent Large Language Model (LLM)-based web agents, navigating complex, real-world webpages efficiently remains a significant hurdle due to the prohibitively large size of Document Object Model (DOM) structures, often ranging from 10,000 to 100,000 tokens. Existing strategies typically rely on crude DOM truncation -- risking the loss of critical information -- or employ inefficient heuristics and separate ranking models, failing to achieve an optimal balance between precision and scalability. To address these challenges, we introduce Prune4Web, a novel paradigm that shifts DOM processing from resource-intensive LLM reading to efficient programmatic pruning. Central to our approach is DOM Tree Pruning Programming, where an LLM generates executable Python scoring scripts to dynamically filter DOM elements based on semantic cues from decomposed sub-tasks. This mechanism eliminates the need for LLMs to ingest raw, massive DOMs, instead delegating traversal and scoring to lightweight, interpretable programs. This methodology achieves a 25x to 50x reduction in candidate elements for grounding, thereby facilitating precise action localization while mitigating attention dilution. Furthermore, we propose a specialized data annotation pipeline and a two-turn dialogue training strategy that jointly optimizes the Planner, Programmatic Filter, and Grounder within a unified framework. Extensive experiments demonstrate state-of-the-art performance. Notably, on our low-level grounding task, Prune4Web dramatically improves accuracy from 46.8% to 88.28%, underscoring its efficacy in real-world web automation.

Prune4Web: DOM Tree Pruning Programming for Web Agent

TL;DR

Prune4Web introduces a DOM Tree Pruning Programming paradigm to tackle the information overload of large DOMs in LLM-based web agents. By shifting element localization from direct DOM comprehension to generating lightweight Python scoring programs, the framework dramatically reduces candidate elements (by 25–50x) and enables precise grounding, guided by a planning stage and a downstream grounding stage. A data synthesis pipeline and a two-turn dialogue training strategy jointly optimize planning, filtering, and grounding, achieving state-of-the-art grounding accuracy (88.28%) on low-level sub-tasks and strong overall performance on standard benchmarks. The approach demonstrates substantial practical impact by enabling scalable, accurate web automation on real-world, complex webpages and by showing plug-and-play compatibility with existing agents.

Abstract

Web automation employs intelligent agents to execute high-level tasks by mimicking human interactions with web interfaces. Despite the capabilities of recent Large Language Model (LLM)-based web agents, navigating complex, real-world webpages efficiently remains a significant hurdle due to the prohibitively large size of Document Object Model (DOM) structures, often ranging from 10,000 to 100,000 tokens. Existing strategies typically rely on crude DOM truncation -- risking the loss of critical information -- or employ inefficient heuristics and separate ranking models, failing to achieve an optimal balance between precision and scalability. To address these challenges, we introduce Prune4Web, a novel paradigm that shifts DOM processing from resource-intensive LLM reading to efficient programmatic pruning. Central to our approach is DOM Tree Pruning Programming, where an LLM generates executable Python scoring scripts to dynamically filter DOM elements based on semantic cues from decomposed sub-tasks. This mechanism eliminates the need for LLMs to ingest raw, massive DOMs, instead delegating traversal and scoring to lightweight, interpretable programs. This methodology achieves a 25x to 50x reduction in candidate elements for grounding, thereby facilitating precise action localization while mitigating attention dilution. Furthermore, we propose a specialized data annotation pipeline and a two-turn dialogue training strategy that jointly optimizes the Planner, Programmatic Filter, and Grounder within a unified framework. Extensive experiments demonstrate state-of-the-art performance. Notably, on our low-level grounding task, Prune4Web dramatically improves accuracy from 46.8% to 88.28%, underscoring its efficacy in real-world web automation.

Paper Structure

This paper contains 39 sections, 1 equation, 9 figures, 17 tables, 1 algorithm.

Figures (9)

  • Figure 1: Comparison between existing multi-modal web agents and our Prune4Web paradim. Compared to existing multi-modal web agent paradigms, we propose a programmatic pruning strategy that efficiently removes redundant DOM elements. Our Prune4Web approach relaxes the token limits of LLMs and increases accuracy on low-level sub-task grounding from 46.80% to 88.28%.
  • Figure 2: The Prune4Web framework pipeline. (A) The input observations include high-level task, history, screenshot, and DOM tree. (B) The Planner generates low-level subtasks based on user instruction, history, and screenshot. (C) Guided by the plan, the Programmatic Element Filter produces a scoring program that is applied to the DOM tree elements to yield a pruned DOM tree. (D) This pruned DOM forms the refined input for the Action Grounder, which then selects an executable action.
  • Figure 3: Recall@N performance of our programmatic filtering stage with different backbone models. The y-axis represents the percentage of times the ground-truth element was successfully included in the Top-N candidates.
  • Figure 4: A detailed, step-by-step execution trace of the Prune4Web framework on an e-commerce gift card purchasing task. The figure highlights how programmatic pruning drastically reduces the candidate space at each step.
  • Figure 5: Partial task trajectory for finding a protection plan on Amazon. Our Programmatic DOM Pruning method filters a large number of irrelevant elements, leaving only a few highly relevant options and simplifying the agent's decision process.
  • ...and 4 more figures