Skip to main content

Overview

Agent Browser supports isolated browser sessions that allow you to:
  • Run multiple browser instances concurrently
  • Keep each instance’s state (cookies, localStorage) separate
  • Persist state across browser restarts
  • Test different user flows in parallel
There are two types of session features:
  1. Session Isolation (--session): Run multiple concurrent browser instances
  2. Session Persistence (--session-name, --profile): Save and restore state

Session Isolation

Multiple Concurrent Sessions

Run multiple isolated browser instances with different session names:
Each session gets its own:
  • Daemon process (separate PID)
  • Browser instance (separate Chromium process)
  • Cookies and storage (isolated state)
  • Navigation history
  • Socket/port (for IPC)

Session Architecture

Sessions are isolated at the OS process level:
On Windows, port files replace .sock files:
Ports are deterministically derived from session names:
This ensures the same session name always gets the same port.

Default Session

If you don’t specify --session, the session name defaults to "default":
You can also set the session via environment variable:

Listing Active Sessions

See which sessions are currently running:
The arrow () indicates the current session (from --session flag or AGENT_BROWSER_SESSION env var). In JSON mode:

Session Naming Rules

Session names must be:
  • Alphanumeric, hyphens, or underscores only: /^[a-zA-Z0-9_-]+$/
  • No path separators (/, \\)
  • No special characters
This prevents path traversal attacks:
Invalid examples:

Closing Sessions

Close a specific session:
This:
  1. Closes the browser for agent1
  2. Shuts down the daemon for agent1
  3. Removes agent1.sock and agent1.pid files
Other sessions continue running unaffected.

Session Persistence

Auto-Persist with --session-name

The --session-name flag automatically saves and restores cookies and localStorage:
State files are stored at:
Where:
  • {session_name} is the value of --session-name
  • {session_id} is the value of --session (or "default")
Example:
This allows different sessions to have separate Twitter logins.

State File Format

State files contain cookies and localStorage in Playwright’s storage state format:

State Encryption

Encrypt state files at rest with AES-256-GCM:
Encrypted state files look like:
The daemon automatically detects encrypted files and decrypts them:
If the key is wrong or missing, the daemon starts with a fresh session and warns:

State Expiration

Old state files are automatically deleted:
Cleanup runs on daemon startup:
You can also manually clean up old states:

Persistent Profiles (--profile)

The --profile flag uses Playwright’s persistent context, which stores all browser data:
Profiles store:
  • Cookies and localStorage
  • IndexedDB databases
  • Service workers
  • Browser cache
  • Extension state (if using --extension)

--profile vs --session-name

When to use --profile:
  • You need full browser state (cache, IndexedDB, etc.)
  • You’re using extensions
  • You want persistence across commands without explicit save
When to use --session-name:
  • You only need cookies and localStorage
  • You want encrypted state files
  • You want explicit control over when state is saved

Manual State Save/Load

You can also manually save and load state:
The state command provides additional features:

Use Cases

Parallel Testing

Test different user flows concurrently:

Multi-Account Management

Manage multiple accounts on the same site:

Agent Swarms

Run multiple AI agents simultaneously:
Each agent has its own browser and doesn’t interfere with others.

State Isolation in CI/CD

Use session names to isolate test runs:
This prevents state pollution between CI runs.

Security Considerations

Socket Permissions

Socket files are created with 0o700 permissions (owner-only):
This prevents other users from:
  • Connecting to your session
  • Reading your traffic
  • Injecting commands

State File Permissions

State files are created with 0o600 permissions (owner read/write only):
This prevents other users from reading cookies and localStorage.

Encryption Key Security

If using encryption, protect your key:
The authentication vault feature auto-generates a key at ~/.agent-browser/.encryption-key if AGENT_BROWSER_ENCRYPTION_KEY is not set.

Performance

Session Overhead

Each session has minimal overhead:
  • Daemon process: ~50-100 MB RAM
  • Browser instance: ~200-500 MB RAM (depends on page)
  • Disk: ~10-50 MB per profile (if using --profile)
You can run 10-20 concurrent sessions on a typical development machine without issues.

State File Size

State files are typically small:
  • Minimal state (few cookies): ~1-5 KB
  • Typical app (10-20 cookies + localStorage): ~10-50 KB
  • Complex app (many cookies + large localStorage): ~100-500 KB
Encryption adds minimal overhead (~5% size increase for the IV and auth tag).

Next Steps