FocusAgent: Simple Yet Effective Ways of Trimming the Large Context of Web Agents
cs.CL
Submitted: 2025-10-03
Updated: 2026-08-29
Comments: TMLR 08/2026
Code: https://github.com/ServiceNow/AgentLab
License: http://creativecommons.org/licenses/by/4.0/
The gist: Web agents powered by large language models (LLMs) must process lengthy web page observations to complete user goals; these pages often exceed tens of thousands of tokens.
Terminology
Abstract
Web agents powered by large language models (LLMs) must process lengthy web page observations to complete user goals; these pages often exceed tens of thousands of tokens. This saturates context limits and increases computational cost processing; moreover, processing full pages exposes agents to security risks such as prompt injection. Existing pruning strategies either discard relevant content or retain irrelevant context, leading to suboptimal action prediction. We introduce FocusAgent, a simple yet effective approach that leverages a lightweight LLM retriever to extract the most relevant lines from accessibility tree (AxTree) observations, guided by task goals. By pruning noisy and irrelevant content, FocusAgent enables efficient reasoning while reducing vulnerability to injection attacks. Experiments on WorkArena and WebArena benchmarks show that FocusAgent matches the performance of strong baselines, while reducing observation size by over 50%. Furthermore, a variant of FocusAgent significantly reduces the success rate of prompt-injection attacks, including banner and pop-up attacks, while maintaining task success performance in attack-free settings. Our results highlight that targeted LLM-based retrieval is a practical and robust strategy for building web agents that are efficient, effective, and secure.
Sources
- AgentHarm: A Benchmark for Measuring Harmfulness of LLM Agents
- WASP: Benchmarking Web Agent Security Against Prompt Injection Attacks
- Refusal-Trained LLMs Are Easily Jailbroken As Browser Agents
- RedTeamCUA: Realistic Adversarial Testing of Computer-Use Agents in Hybrid Web-OS Environments
- EIA: Environmental Injection Attack on Generalist Web Agents for Privacy Leakage
- SafeArena: Evaluating the Safety of Autonomous Web Agents
- Adaptive Attacks Break Defenses Against Indirect Prompt Injection Attacks on LLM Agents
- Attacking Vision-Language Computer Agents via Pop-ups
- AgentDAM: Privacy Leakage Evaluation for Autonomous Web Agents
Related papers
- Exploring Solution Divergence and Its Effect on Large Language Model Problem Solving
- Ishigaki-IDS-Bench: A Benchmark for Generating Information Delivery Specification from BIM Information Requirements
- Subliminal Steering: Stronger Encoding of Hidden Signals
- MedStruct-S: A Benchmark for Key Discovery, Key-Conditioned QA and Semi-Structured Extraction from OCR Clinical Reports
- The End of Transformers? On Challenging Attention and the Rise of Sub-Quadratic Architectures
- Untangling the Mechanisms of Misleading Context in Medical Question Answering