Docs/SDK/Domain Policies

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

  1. Allowed vs prohibited domains
  2. Keep-alive sessions
  3. Examples

Allowed vs prohibited domains

Domain policies apply to navigation APIs (e.g., goto) and are intended as guardrails.

SettingEffect
allowed_domains / allowedDomainsOnly allow navigation to these domains (subdomains typically included).
prohibited_domains / prohibitedDomainsExplicitly 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.