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:
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.”
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 / keepAlive keeps the browser process alive across close() calls.
Use cases:
from predicate import PredicateBrowser
browser = PredicateBrowser(
allowed_domains=["example.com", "news.ycombinator.com"],
prohibited_domains=["doubleclick.net"],
keep_alive=True,
)
browser.start()
browser.goto("https://news.ycombinator.com")