Abstract
Autonomous web agents need to operate under externally imposed or human-specified policies while generating long-horizon trajectories. However, little work has examined whether these trajectories comply with such policies, or whether policy violations persist across different contexts such as domains (e.g., shopping or coding websites) and subdomains (e.g., product search and order management in shopping). To address this gap, we introduce PolicyGuardBench, a benchmark of about 60k examples for detecting policy violations in agent trajectories. From diverse agent runs, we generate a broad set of policies and create both within subdomain and cross subdomain pairings with violation labels. In addition to full-trajectory evaluation, PolicyGuardBench also includes a prefix-based violation detection task where models must anticipate policy violations from truncated trajectory prefixes rather than complete sequences. Using this dataset, we train PolicyGuard-4B, a lightweight guardrail model that delivers strong detection accuracy across all tasks while keeping inference efficient. Notably, PolicyGuard-4B generalizes across domains and preserves high accuracy on unseen settings. Together, PolicyGuardBench and PolicyGuard-4B provide the first comprehensive framework for studying policy compliance in web agent trajectories, and show that accurate and generalizable guardrails are feasible at small scales.
Introduction
As autonomous web agents transition from research environments to real-world applications—performing tasks such as booking travel, managing cloud infrastructure, or navigating complex shopping platforms—the focus has shifted from mere capability to reliability and compliance. While agents are increasingly capable of completing complex tasks, ensuring they adhere to specific organizational or user-defined policies remains a significant challenge. Current safety guardrails are primarily designed to prevent catastrophic risks (e.g., hate speech or dangerous instructions) but often fail to detect subtle, domain-specific policy violations.
The Compliance Gap: Safety vs. Policy
A fundamental distinction exists between "safety" and "compliance." Safety-oriented models like LlamaGuard are trained to identify universally harmful content. In contrast, policy compliance is context-dependent and often involves cumulative actions over a long trajectory. For instance, an agent tasked with ordering office supplies might violate a budget constraint or a "no alcohol" policy. These actions are not inherently "unsafe" in a general sense, but they constitute a failure of the agent's mission.
As shown in Figure 1, a traditional guardrail might detect no safety risks in an order containing champagne and multiple cakes, whereas a policy-aware guardrail correctly identifies violations regarding alcohol, cake quantity, and budget.
PolicyGuardBench: A New Benchmark for Compliance
To systematically study this problem, we introduce PolicyGuardBench, a large-scale benchmark designed for policy violation detection. The dataset comprises approximately 60,000 annotated trajectory-policy pairs across five distinct domains: Reddit, Map, GitLab, Shopping, and Shopping-Admin.
The construction of PolicyGuardBench involved:
- Trajectory Standardization: Converting raw browser logs from the WebArena environment into structured textual trajectories.
- Policy Synthesis: Utilizing GPT-4o to generate 2,195 curated policies covering obligations, prohibitions, and ordering constraints.
- Violation Labeling: Pairing trajectories with policies from both matching and differing subdomains to create a robust set of positive and negative violation examples.
- Prefix-based Detection: A novel task requiring models to predict violations from truncated trajectory prefixes, enabling early-warning capabilities.
PolicyGuard-4B: Efficient and Accurate Guardrails
Leveraging PolicyGuardBench, we developed PolicyGuard-4B, a specialized guardrail model fine-tuned from a Qwen3-4B-Instruct backbone. The goal was to create a model that is small enough for real-time deployment alongside an agent while maintaining high reasoning accuracy.
Experimental Results
Our evaluation demonstrates that specialized, smaller models can outperform much larger frontier models in the niche task of policy detection. PolicyGuard-4B achieved an accuracy of 90.1% and an F1 score of 87.6%, surpassing models like Claude-3.5-Sonnet and Gemini-1.5-Pro.
As detailed in Figure 5, PolicyGuard-4B provides a significant advantage in latency, operating at 22.5 ms per example—nearly 55 times faster than Claude-Sonnet-4. This efficiency is critical for integrating guardrails into the active planning loops of autonomous agents.
Key Insights
- Generalization: PolicyGuard-4B exhibits strong zero-shot generalization to unseen domains. In "Leave-One-Domain-Out" experiments, the model maintained over 90% accuracy, suggesting it learns the underlying logic of policy compliance rather than domain-specific patterns.
- Efficiency-Accuracy Trade-off: The model achieves an "Efficiency-Adjusted F1" score of 38.9, more than double that of the next best open-source foundation model (Gemma-3-12B-IT).
- Early Detection Challenges: While the model is effective at full-trajectory evaluation, prefix-based detection remains a harder task, with performance varying based on the length and noise of the trajectory prefix.
Conclusion and Future Work
PolicyGuardBench and PolicyGuard-4B represent a significant step toward building trustworthy autonomous agents. We have shown that efficient, small-scale models can serve as highly effective "hall monitors" for complex web agents. Future work will focus on moving from detection to prevention by integrating these guardrails directly into agent planning loops and expanding the benchmark to include more diverse enterprise and physical environments.
Summary updated