LangChain says the right browser tool can cut costs fourfold

LangChain compared seven browser-control tools for autonomous agents and chose Browserbase's Stagehand solution. The company says code-based operation, compact page descriptions and fewer browser connections can significantly reduce costs and execution time.
- LangChain compared seven browser tools on autonomous agents.
- Stagehand completed 90 percent of WebVoyager tasks at a total cost of $1.98.
- Playwright MCP achieved a 78 percent result at a cost of $26.71.
- Stagehand's code-based operation reduces the number of model turns and the amount of returned content.
- snapshot gives the agent a compact view of interactive elements with identifiers.
Browser use is becoming increasingly important for agents
According to a November 3 post from LangChain, browser use is an important capability for agents that work autonomously. These systems can perform tasks on websites that do not have a public API. The company cites personal agents from Instinct and Meta Muse as examples. They plan routes for cross-country trips, cancel subscriptions that are no longer needed and list cars for sale.
Citing DataDome data, LangChain says the number of browser requests from agents alone increased 4.7-fold in September. Another important use of browser control is end-to-end testing of web applications created by coding agents.
To do this, an agent needs tools for opening, reading and interacting with pages, as well as a browser. LangChain's Managed Deep Agents service allows users to create and deploy agents in LangSmith without running their own infrastructure. The browser can be provided by a hosted service such as Browserbase, which, according to the announcement, also handles CAPTCHAs, bot blocking and running large numbers of browsers.
Stagehand was selected from seven tools
LangChain evaluated the tools across three task sets run on live websites. WebVoyager contained 100 everyday tasks on popular sites such as Allrecipes, Amazon and Google Flights. The tests were run with Claude Sonnet 5.5, and evaluated by a Jev judge.
HardBench consisted of 102 more difficult tasks compiled by Browserbase, mostly using Claude Opus 5.5. WebTailBench contained Microsoft's so-called tail cases from real-world usage, 150 of which were run in the Stagehand evaluations. Every test harness returned a structured response in JSON format, so a one-line answer instead of a table, for example, did not separately lower the browsing performance score.
The seven tools completed between 78 and 90 percent of the WebVoyager tasks, but costs and speed varied significantly. Stagehand achieved a 90 percent result at a total cost of $1.98, with a median time of 17.4 seconds per task. Playwright MCP achieved 78 percent at a cost of $26.71, which LangChain calculated as approximately 13 times more expensive, while the tasks took three times as long.
On 38 core tasks from the more difficult HardBench, Deep Agents using Stagehand's code-based run tool completed 30 tasks. Using Browserbase's command-line browse CLI, 21 tasks succeeded, at three times the cost per task.
Code-based operation reduces context load
According to LangChain, browser tasks create two particular challenges. They are lengthy and therefore require many consecutive tool calls, while web pages return large amounts of content, of which only a small portion is often relevant. A WebVoyager task with Playwright MCP required an average of 26 model turns. On Browserbase's hosted MCP server, a navigation had a median size of approximately 17,000 characters.
Stagehand offers three main tools. snapshot extracts the page's accessibility tree and assigns identifiers to interactive elements. run performs actions, either bundling multiple clicks and field entries into a single operation or using Playwright-style JavaScript code. screenshot captures the rendered page.
With code-based operation, an agent can describe the entire sequence of steps in a single code block, such as opening a page, filling in a field, clicking and checking the result. Intermediate data remains in variables, and only the content returned by the agent is brought back into the context. In an earlier comparison by LangChain, using Browserbase MCP tools through code and an interpreter reduced the cost from $17.87 to $4.52.
Stagehand's run tool handles this workflow natively. It used an average of 10 steps per task, compared with 26 for Playwright MCP, while a navigation returned a median of 117 characters, compared with approximately 17,000 characters from Browserbase's navigation tool. When LangChain tested Stagehand's native API, the result was 5.3 percentage points worse, while the cost per successful task increased by 19 percent.
Compact page descriptions and fewer connections also matter
Instead of returning the page's full HTML or a screenshot, snapshot provides the part of the accessibility tree the agent needs. Interactive elements receive identifiers, allowing the agent to refer to them directly, for example in a click operation. Browserbase says Stagehand v4 achieves approximately 80 percent more efficient token usage than Playwright.
In LangChain's WebTailBench runs, a screenshot had a median size of 89 kilobytes. Based on the company's experience, truncating the result afterward to 8000 characters did not reduce costs because the agents simply requested the page again. This suggests that the necessary content must be selected at the source.
The number of connections between the browser and the agent also affects performance. LangChain's example shows that a single Playwright click requires five Chrome DevTools Protocol calls because the tool first makes the element visible, retrieves its position, and then performs separate move, press and release actions. Stagehand v4 operates as an extension running in the browser, sending a batch of actions over a single connection. According to Browserbase's own benchmarks, v4 is twice as fast as Playwright.
LangChain concluded that the design of tools has a significant effect on agents' browsing performance. Developers examined the traces in LangSmith to identify where the system was wasting steps or tokens, then verified every change through further evaluations.
LangChain: How We Optimized Browser Use for Deep Agents


