Output will stream here when you run the agent.
Summary
The Browser Agent completes tasks on the live web by driving a real Chromium browser. It uses Playwright-based tools with accessibility-tree ref ids for stable element targeting, web search as a fallback, and persists state to Turso (libSQL). Reach for it to automate flows, scrape interactive pages, or test UIs.
Installation
$ pnpm dlx shadcn@latest add @agentcn/mastra/browser-agent
Composition
├── config.ts # Agent config with browser, model, and web_search tool
├── instructions.md # Comprehensive browser operation instructions
└── memory.ts # Memory with last 10 messagesEnvironment Variables
BROWSER_HEADLESS= # Optional: Set to "false" for visible browser (default: true)
BROWSER_CDP_URL= # Optional: CDP endpoint for remote browser
TURSO_DATABASE_URL= # Required: Turso libSQL URL for storage
TURSO_AUTH_TOKEN= # Optional: Turso auth tokenHow It Works
- Navigate - Call
browser_gotowith the target URL - Snapshot - Call
browser_snapshotto get the accessibility tree with ref ids - Interact - Use ref ids from snapshot for
browser_click,browser_type, etc. - Re-snapshot - Take new snapshot after actions to see updated state
- Verify - Take final snapshot to confirm results before reporting
- Fallback - Use
web_searchfor quick factual questions
Customization
- Remote browser. Set
BROWSER_CDP_URLto connect to a remote CDP endpoint like Bright Data Browser API. - Headless mode. Set
BROWSER_HEADLESS=falsefor visible browser during development. - Swap models. Edit the
modelfield inconfig.ts. - Adjust steps. Modify
maxStepsinconfig.ts(default: 100).