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
- Session Isolation (
--session): Run multiple concurrent browser instances - Session Persistence (
--session-name,--profile): Save and restore state
Session Isolation
Multiple Concurrent Sessions
Run multiple isolated browser instances with different session names:- 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:.sock files:
Default Session
If you don’t specify--session, the session name defaults to "default":
Listing Active Sessions
See which sessions are currently running:→) 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
Closing Sessions
Close a specific session:- Closes the browser for
agent1 - Shuts down the daemon for
agent1 - Removes
agent1.sockandagent1.pidfiles
Session Persistence
Auto-Persist with --session-name
The --session-name flag automatically saves and restores cookies and localStorage:
{session_name}is the value of--session-name{session_id}is the value of--session(or"default")
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:State Expiration
Old state files are automatically deleted:Persistent Profiles (--profile)
The --profile flag uses Playwright’s persistent context, which stores all browser data:
- Cookies and localStorage
- IndexedDB databases
- Service workers
- Browser cache
- Extension state (if using
--extension)
--profile vs --session-name
| Feature | --profile | --session-name |
|---|---|---|
| Cookies | ✓ | ✓ |
| localStorage | ✓ | ✓ |
| IndexedDB | ✓ | ✗ |
| Service workers | ✓ | ✗ |
| Browser cache | ✓ | ✗ |
| Extensions | ✓ | ✗ |
| Encryption | ✗ | ✓ (optional) |
| Auto-save | Always | On close |
| Use case | Full browser state | Lightweight auth |
--profile:
- You need full browser state (cache, IndexedDB, etc.)
- You’re using extensions
- You want persistence across commands without explicit save
--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: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:State Isolation in CI/CD
Use session names to isolate test runs:Security Considerations
Socket Permissions
Socket files are created with0o700 permissions (owner-only):
- Connecting to your session
- Reading your traffic
- Injecting commands
State File Permissions
State files are created with0o600 permissions (owner read/write only):
Encryption Key Security
If using encryption, protect your key:~/.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)
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
Next Steps
- Architecture - Understand the Rust CLI + Node.js daemon design
- Snapshot Refs - Learn about accessibility tree snapshots
- Selectors - Master element selection strategies