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
Install: pip install browser-use and playwright install chromium
Import Agent and a LangChain-compatible LLM: from browser_use import Agent; from langchain_anthropic import ChatAnthropic
Instantiate the agent: agent = Agent(task='Find the latest Playwright release notes', llm=ChatAnthropic(model='claude-opus-4-5'))
Run the agent loop: result = await agent.run(max_steps=20)
Access result.final_result() for the output and result.history() for the full action trace
To reuse a browser session across multiple agent runs, pass a pre-configured BrowserContext into the Agent constructor
Known gotchas
Browser Use takes a screenshot at each step and sends it to the LLM; using a vision-capable model is required for reliable element targeting
The default max_steps is unlimited; always set a finite limit to prevent runaway loops consuming LLM credits
Browser Use 0.13+ uses a Rust-backed agent core; the Python API surface changed in that release so check the changelog before upgrading from earlier versions
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?