browserbase/stagehand

The SDK For Browser Agents

What it solves

Stagehand provides a specialized SDK for building browser agents that overcomes the limitations of traditional testing tools like Playwright. It addresses the fragility of web automation by enabling agents to interact with websites using natural language, reducing the need for rigid, hard-coded selectors that break when a site's layout changes.

How it works

Stagehand combines Playwright-style APIs with AI-driven primitives. It uses a hybrid accessibility tree trimming technique to provide LLMs with a token-efficient representation of the page context. It operates as a browser extension to reduce latency. The SDK provides three core natural language functions:

  • act(): Executes individual actions on the page using natural language commands.
  • observe(): Identifies actionable elements on the page.
  • extract(): Retrieves structured data from the page based on a provided schema.

Who it’s for

Developers building AI agents that need to navigate the web, interact with complex DOM structures (like nested iframes and Shadow DOMs), and require production-grade reliability and observability.

Highlights

  • Self-healing actions: Automatically detects and refreshes how actions are performed when website layouts change.
  • Token efficiency: Trims the accessibility tree to reduce LLM token usage.
  • Harnesses Playwright: Maintains familiar APIs (goto, click, locator) for deterministic control.
  • Multi-language support: Available as a complete browser driver for TypeScript, Python, and Go.
  • Agent-specific features: Includes WebMCP, clipboard support, and OTel support.

Related

  • Project
  • Project
  • Project
  • Project
  • Project