Run Browser Use agent loop with a custom LLM to automate web tasks via Playwright

domain: github.com/browser-use/browser-use · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install: pip install browser-use and playwright install chromium
  2. Import Agent and a LangChain-compatible LLM: from browser_use import Agent; from langchain_anthropic import ChatAnthropic
  3. Instantiate the agent: agent = Agent(task='Find the latest Playwright release notes', llm=ChatAnthropic(model='claude-opus-4-5'))
  4. Run the agent loop: result = await agent.run(max_steps=20)
  5. Access result.final_result() for the output and result.history() for the full action trace
  6. To reuse a browser session across multiple agent runs, pass a pre-configured BrowserContext into the Agent constructor

Known gotchas

Related routes

Configure the Microsoft Playwright MCP server to expose browser automation tools to an LLM agent
github.com/microsoft/playwright-mcp · 6 steps · unrated
Feed Playwright page.ariaSnapshot() output to an LLM agent loop as a token-efficient page observation
playwright.dev · 6 steps · unrated
Automate interactions inside nested iframes and open shadow DOM in Playwright
playwright.dev · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans