Stagehand: The AI-Driven Browser Automation Framework Browserbase released Stagehand, an open-source browser automation SDK that uses AI to resolve plain-English instructions into real page elements at runtime, while deterministic code performs the clicks. The framework, with over 23,000 GitHub stars, offers four verbs—act, extract, observe, and a fourth—to split browser actions into an AI half that absorbs page changes and a code half that keeps behavior exact and replayable. Stagehand: Inside the AI-Driven Browser Automation Framework Hardcoded selectors break the moment a page changes; fully autonomous agents are quick to write but hard to trust. Stagehand, the open-source browser-automation SDK from Browserbase, takes a third path - you write plain-English instructions, an AI resolves them to real elements at runtime, and deterministic code does the clicking. Explore how its four verbs work, why it caches the AI's answers, and what it gave up to leave Playwright behind. Your scraper ran flawlessly for eight months. Then, one Tuesday night, a frontend developer at the site you automate renamed a CSS class - .btn--buy became .purchase-cta - and your pipeline died without a sound. Nothing crashed loudly. The script looked for a button that no longer existed, timed out, retried, timed out again. You found out Thursday, from a stakeholder asking where the data went. This is the standing bargain of traditional browser automation. Tools like Playwright, Selenium, and Puppeteer are exact: you tell them precisely which element to click, and they click it fast, deterministically, for free. But that exactness is also the failure mode. A hardcoded selector is a bet that the page will never change, and the page always changes. Every automation you write is quietly accruing a maintenance debt that comes due at the least convenient time. At the other extreme sits the fully autonomous AI agent. You hand it a goal - "buy the headphones" - and it looks at the page, reasons about it, and figures out the clicks on its own. Redesigns don't faze it. But now you have a different problem: the agent might take a different path every run, it's hard to debug when it wanders, and every step burns model tokens. You've traded brittle for black box. Stagehand https://github.com/browserbase/stagehand is an open-source framework from Browserbase https://www.browserbase.com/stagehand the company that sells headless browser infrastructure built on a wager: the right unit of automation is neither the selector nor the goal, but the instruction . MIT-licensed, with over 23,000 GitHub stars, it bills itself as "the SDK for browser agents." You write act "click the buy button" , and an AI resolves that sentence at runtime to whatever the buy button happens to be today - then ordinary, deterministic browser code performs the click. Developers use Stagehand to reliably automate the web. Stagehand documentationTo feel the difference, try breaking something. The figure below shows the same tiny storefront automated two ways: a hardcoded selector on the left, a Stagehand-style instruction on the right. Run both, then ship a redesign and run them again - watch which one survives. The key insight: Stagehand splits every browser action into two halves. An AI decides what to interact with; deterministic code performs the interaction. The AI half absorbs page changes, and the code half keeps the behavior exact and replayable. Four Verbs for a Browser A stagehand, in the theater, is the person in the wings who moves the props so the show can go on. The framework earns its name with a deliberately small API: four verbs that cover everything you'd ask of a browser. The first three are the precision tools. act executes exactly one step; the docs are emphatic about keeping instructions atomic - "click the login button", not "log in and go to settings". extract turns scraping into a typed function call: you hand it a Zod schema and get back an object that actually conforms to it see the box below if Zod is new to you . observe is reconnaissance - it tells you what's actionable on the page before anything irreversible happens. js // The precision tools await stagehand.act "click the login button" ; const price = await stagehand.extract "extract the price", z.number ; const actions = await stagehand.observe "find submit buttons" ; Zod is a TypeScript library for describing the shape of data. You spell out each field and its type once; Stagehand shows that description to the model as the thing to fill in, then checks the model's answer against it before handing the object back. A page that returns the wrong shape raises an error instead of a silently-wrong result. js import { z } from "zod"; // Describe the shape you expect const Product = z.object { name: z.string , price: z.number , } ; // extract returns an object guaranteed to match it const product = await stagehand.extract "get the product name and price", Product ; The fourth verb changes who's driving. agent takes a goal and loops - observing, deciding, acting - until the goal is met. You can back it with a regular LLM or a dedicated computer-use model: js // The autonomy tool const agent = stagehand.agent { mode: "cua", model: "google/gemini-2.5-computer-use-preview-10-2025", } ; await agent.execute "apply for this job" ; One more detail worth knowing early: instructions are sent to a model provider, so Stagehand gives you placeholder variables for anything sensitive. You write act "type %password% into the password field", { variables: { password: ... } } and the secret is substituted locally - the LLM only ever sees the placeholder. The tension between the two modes is the interesting part. The precision verbs are predictable and debuggable but need you to write the route; the agent finds the route but is only as predictable as its model. Stagehand's own docs describe how most teams square it: use the agent for exploration, and pin the critical paths down with individual primitives. The figure below puts all four verbs on the same page - literally. Switch tabs and watch what each one does to the same little store. From Instruction to Click So what actually happens inside act "click the buy button" ? It can feel like magic, but each stage turns out to be a piece of understandable engineering - a short pipeline you can follow from end to end. First, Stagehand needs to show the model the page, and it does not send a screenshot or a raw HTML dump by default. It reads the page's accessibility tree - the semantic outline the browser already maintains for screen readers, where a