// changelog

Introducing Stagehand 4.4: browser.disconnect(), crash-safe sessions, and more

Stagehand 4.4 adds browser.disconnect() for reattaching to running browsers, an extension watchdog that cleans up after crashed clients, working keepAlive on local browsers, and LangChain Deep Agents browser tools built on Stagehand.

Stagehand team3 min read
changelog
Pixelated orange and green hillside landscape under pale sky
++

We’re excited to announce Stagehand 4.4!

This release is about long-lived browsers. You can now let go of a browser without closing it, come back to it later, and trust Stagehand to clean up when your process dies. Here are the highlights:

Disconnect from a browser and reattach later#

browser.disconnect() closes Stagehand's connection without closing the browser or releasing its Browserbase session. Tabs, cookies, and signed-in profiles stay where they are. Connect again with localBrowser.connect({ cdpUrl }) or browserbase.connect({ sessionId }), create a new Stagehand instance, and pick up where you left off. Available in TypeScript and Python.

const browser = await browserbase.launch({
  apiKey: process.env.BROWSERBASE_API_KEY,
  keepAlive: true,
});
const stagehand = await Stagehand.create({ browser });
const sessionId = browser.sessionId!;

// Let go: Stagehand closes, the session keeps running
await browser.disconnect();

// Later, from any process
const again = await browserbase.connect({
  apiKey: process.env.BROWSERBASE_API_KEY,
  sessionId,
});
const stagehand2 = await Stagehand.create({ browser: again });

The same works for a local Chrome you started yourself:

let browser = await localBrowser.connect({ cdpUrl: "http://127.0.0.1:9222" });
let stagehand = await Stagehand.create({ browser });

await browser.disconnect(); // Chrome and its tabs keep running

browser = await localBrowser.connect({ cdpUrl: "http://127.0.0.1:9222" });
stagehand = await Stagehand.create({ browser });

On Browserbase, keepAlive decides whether the session survives the disconnect, so launch with keepAlive: true. Calling close() on a handle after you disconnect it throws, so you never close a browser you meant to keep. Read the docs.

Crash-safe sessions#

If your SDK process crashes or gets killed, the Stagehand extension now notices from inside the browser, without heartbeats or timers, and cleans up. A local Chrome that Stagehand launched without keepAlive shuts down instead of being orphaned. A keepAlive browser or Browserbase session is released so a new client can attach right away. The watchdog needs Chrome 137 or later.

That also means keepAlive actually works on local browsers now: launch with localBrowser.launch({ keepAlive: true }) and Chrome outlives your script, ready for you to reconnect.

Built on Stagehand: browser use in LangChain Deep Agents#

LangChain is giving Deep Agents a browser, and the tools are built on Stagehand. Managed Deep Agents now runs a browser for your agent, with browser_snapshot, browser_run, browser_screenshot, and browser_handoff tools. In LangChain's tests on 100 WebVoyager tasks, the Stagehand-based tools passed 90% for $1.98 in total, the highest pass rate of the seven toolsets they tested. The runner-up passed 89% at 9x the cost.

For open source agents, LangChain now ships langchain-stagehand on PyPI. StagehandMiddleware gives any LangChain or Deep Agents agent Stagehand's run, snapshot, and screenshot tools over one persistent browser, local Chrome or Browserbase, with no MCP server needed.

from deepagents import create_deep_agent
from langchain_stagehand import StagehandMiddleware
from stagehand import Stagehand, browserbase

browser = await browserbase.launch(api_key=os.environ["BROWSERBASE_API_KEY"])
stagehand = await Stagehand.create(browser=browser)

agent = create_deep_agent(
    "anthropic:claude-sonnet-4-6",
    middleware=[StagehandMiddleware(stagehand=stagehand)],
)

Read Sydney Runkle's post, Browser Use in Managed Deep Agents, or get started with the browser use guide.

Here's what else is new#

  • Cross-origin iframes are more reliable: iframes that were already loaded when Stagehand attached (for example after a reconnect), or that are nested inside another cross-origin iframe, are now picked up, so snapshots and actions can reach them (#3339). act() also no longer stops cross-origin iframes from loading (#3388).
  • Know when a connection is gone: browser handles expose connected, which reports whether the handle still has a live connection, and cdpUrl (cdp_url in Python) for local browsers, so you always know where to reconnect.
  • Claude Opus 5.5 fixes: act(), observe(), and extract() now work correctly with Claude Opus 5.5 (#3340).
  • Tighter domain policies: closed ways around domain allow and block lists through URLs with credentials, background requests, and speculative page loads (#3387).

Give it a try and tell us what you build!

++