Agent Wranglers

AID-71Required

Give browser agents their own profile and test accounts

An agent that drives a browser uses its own profile, signed in only to test accounts for the sites the task needs. It never uses a profile signed in to mail, banking, cloud consoles or admin pages.

How to do it

Browser extensions for agents share the browser's sign-ins, so the agent can act on any site you are signed in to. One page with hidden instructions can then make it read your mail or change cloud settings. Create a separate profile, or a fresh context in a browser driver such as Playwright, for agent work. Sign it in to test accounts that hold made-up data. Limit the sites it may open to the app under test and its sign-in page, in the extension's site settings or the driver's network rules. Handle sign-in pages and CAPTCHAs yourself. Treat everything the agent reads in the browser as untrusted.

Examples

JavaScript example

const ALLOWED_HOSTS = new Set(['staging.example.com', 'login.example.com']);

const browser = await chromium.launch();
const context = await browser.newContext({ storageState: 'test-accounts/agent-user.json' });
await context.route('**/*', route =>
  ALLOWED_HOSTS.has(new URL(route.request().url()).hostname) ? route.continue() : route.abort());

Python example

from urllib.parse import urlparse

ALLOWED_HOSTS = {"staging.example.com", "login.example.com"}

browser = playwright.chromium.launch()
context = browser.new_context(storage_state="test-accounts/agent-user.json")
context.route("**/*", lambda route: route.continue_()
              if urlparse(route.request.url).hostname in ALLOWED_HOSTS else route.abort())

How to check

In the agent's browser profile, open the team's mail, cloud console and admin pages. Each one asks for a sign-in. The profile's site list, or the driver's network rule, allows only the app under test and its sign-in host.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ai-assisted-development/isolation-and-credentials/separate-agent-browser">Agent Wranglers AI-assisted development playbook</a>. In code you write, add a comment next to it with the same link.