Skip to main content
Back to timeline
langchain.comSource publication:

LangChain swaps in Stagehand for Deep Agents' browser: 90% task pass at $1.98, about one-thirteenth the cost of Playwright MCP

Synopsis

LangChain gave the agents in Managed Deep Agents a browser, chose Browserbase's Stagehand from seven toolsets, and then reworked it using LangSmith traces and evals. With the model and tasks fixed and only the toolset changed, Stagehand passed 90% of tasks for $1.98 in total at a median 17.4 s per task, while Playwright MCP passed 78% for $26.71, about 13 times the cost, and took roughly three times as long per task. The main changes let the agent write code that drives many browser steps at once, read compact page snapshots instead of screenshots, and end fixed sleeps once the page has been quiet for 500 ms.

Source-provided article image: How We Optimized Browser Use for Deep Agents
langchain.com

Interpretation

With the same model and the same tasks, which browser toolset an agent uses changes both success rate and cost, making tool design itself a tunable performance variable. Earlier browser tooling reused testing SDKs such as Playwright, and agents called one action at a time, waiting on a model decision between calls. Across seven toolsets on live-website tasks, pass rates fell between 78% and 90%, but cost and speed varied widely: Stagehand passed 90% for $1.98 in total at a median 17.4 s per task, while Playwright MCP passed 78% for $26.71 and took about three times as long per task.

Stagehand gives the agent three tools: snapshot reads the page's accessibility tree and labels interactive elements with IDs, run executes a batch of actions or Playwright-style code, and screenshot captures the rendered page. In code mode the agent writes the whole chain of operations at once, intermediate results stay in code variables, and only the final return value enters context. run averaged 10 steps per task against 26 for Playwright MCP, and a navigation returned a median 117 characters against about 17,000 from Browserbase's hosted navigate tool. Calling Browserbase's MCP tools from code in an interpreter instead of one at a time cut their cost from $17.87 to $4.52.

How the agent waits for pages to load was also rewritten: run ends each fixed sleep once the page has been quiet for 500 ms, and never later than the time the agent asked for. Traces showed agents writing fixed sleeps such as page.waitForTimeout(8000), while most pages were ready long before the timer ran out, so runs spent much of their time idle. In one measurement an 8-second sleep returned in 0.6 s; on HardBench, together with structured answers and a model-call timeout, it cut median agent time from 182 s to 124 s, with accuracy within noise.

Perspective

The demonstrated scope is the browser tooling inside Managed Deep Agents, evaluated on WebVoyager's 100 everyday tasks, HardBench's 102 harder tasks and 150 real-world tail tasks from WebTailBench, all run on live websites. Open-source Deep Agents can attach the same tools through StagehandMiddleware, and agents browsing the open web at scale launch the browser on Browserbase instead.

WebVoyager is described as fairly saturated, so it mainly compares context use, cost and speed; HardBench's core subset has 38 tasks, of which Deep Agents passed 30 with Stagehand's code-writing run tool and 21 with Browserbase's command-style browse CLI, the latter at about three times the cost per task. Capping snapshots at 8,000 characters after the fact did not lower cost, because agents simply fetched the page again.