- Delegated control, where
web agent, SDKweb.agent(), or MCPrun_web_agentchooses the browser steps. - Deterministic control, where your app or coding-agent host runs focused Playwright snippets.
Agent control
web model setup, or pass a route, model, and provider credential flags for a single run.
Deterministic control
page already in scope. Return values explicitly when another step needs the result.
Execution result anatomy
Ask for capture when the next step needs browser status, page observation, or artifacts.result.result for your returned value. Use result.page, result.status, and result.observation to decide the next step or to preserve evidence.
Write Playwright for agents
When a coding agent or app writes snippets, keep them small and inspectable:- Use the provided
pageinstead of redeclaring it. - Prefer
page.getByRole,page.getByLabel, andpage.getByTextover coordinates. - Return structured values from each snippet.
- Use bounded waits and explicit checks.
- Avoid infinite polling loops.
- Clean up browsers your application creates.
Handle missing page state
MCP control
MCP hosts usemanage_browsers for lifecycle and execute_playwright_code for deterministic page work. The runtime surface returns the code result plus bounded observation, status, logs, and artifacts so the host can decide the next snippet.