Stagehand is a browser automation SDK designed for AI agents that exposes Playwright-style APIs (goto, click, locator, screenshot) across TypeScript, Python, and Go. It instruments a real browser session and provides higher-level primitives - observe (returns real selectors so secrets never reach models), act (self-healing actions that adapt to site changes), and extract (schema-validated data via zod/Pydantic/Go types). Example flows show persistent browser profiles (cookies in ./browser-data), programmatic login using environment credentials, navigation, and extraction of invoices into typed structures. Built-in features for agents include WebMCP, clipboard support, batch commands, deep locators for nested iframes and closed Shadow DOMs, and OpenTelemetry traces.
Performance and cost arguments center on two engineering changes: running Stagehand as an extension alongside the browser to eliminate round-trip latency, and hybrid accessibility-tree trimming to send only the page context an agent needs. Those techniques are claimed to yield about 2x faster execution than equivalent Playwright cloud browsers and ~80% token efficiency improvements. When paired with Browserbase, a Model Gateway can auto-select cheaper models and server-side caching can return identical calls without spending tokens, further reducing latency and API spend. The SDK is installable via npm/pip/go and requires a local Chrome for local runs.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.