Domain Policies
Restrict navigation with allow/deny lists so agents don’t drift out of scope, and optionally keep the browser alive across sessions when you need reuse.
This guide covers:
- Allow / deny lists for navigation safety
- How domain matching works (host + subdomains)
- Keeping a browser alive for long-lived sessions
Treat navigation scope as a safety boundary.
Domain policies prevent agents from wandering into ads, trackers, or unrelated sites—without relying on the LLM to “remember the rules.”
Table of Contents
Allowed vs prohibited domains
Domain policies apply to navigation APIs (e.g., goto) and are intended as guardrails.
| Setting | Effect |
|---|---|
allowed_domains / allowedDomains | Only allow navigation to these domains (subdomains typically included). |
prohibited_domains / prohibitedDomains | Explicitly deny navigation to these domains (useful for ad/tracker domains). |
Keep-alive sessions
keep_alive / keepAlive keeps the browser process alive across close() calls.
Use cases:
- persistent login sessions
- long-lived development sessions
- rapid iteration where browser startup dominates runtime
Examples
from predicate import PredicateBrowser
browser = PredicateBrowser(
allowed_domains=["example.com", "news.ycombinator.com"],
prohibited_domains=["doubleclick.net"],
keep_alive=True,
)
browser.Related topics
- Browser Setup — context configuration
- Permissions — avoid non-DOM permission prompts
- Agent Runtime — verification loop