GuideUpdated · by Kunj Shah

Stagehand evals and testing. Find out why a run failed, then keep it as a test.

Short answer: Stagehand runs your browser agent; it does not decide why a run went wrong or promise that a fix holds. Walkcast Lab is the testing half. It records a Stagehand run in a real browser, classifies the cause from the browser's own trace (not from an LLM judge), saves the failure as a fixture, and replays that fixture against the next version of your agent, offline, from the recorded model calls. It is free and MIT licensed.

Where Stagehand evals stop

An eval answers one question: did the agent complete this task? When the answer is no, you are left with the question that costs the time: why. An agent that fails usually cannot explain itself, and a pass rate over a handful of runs cannot tell a real improvement from a lucky one. Those are the two gaps Lab fills.

Steps

  1. 1. Run your Stagehand agent through Lab

    Lab drives the agent against a real browser and a sample app with an injected fault, and records everything it does: the pages, the elements, the requests and Stagehand's own model calls.

  2. 2. Read the cause, not the log

    A failed run is classified from the browser's own trace into a symptom and a cause with the step and request that show it. A failure the rules cannot explain is marked unexplained instead of being guessed.

  3. 3. Keep the failure as a fixture

    The failed run is saved with its task, starting state and recorded model calls, so it can be replayed without a provider key or a network connection.

  4. 4. Replay it against the next version

    Replay the fixture several times against your changed agent. A fix is confirmed by repeated passes, not by one lucky run.

  5. 5. Compare versions in CI

    Run compare over all your fixtures. It exits non-zero when the candidate still fails, so a regression stops the release instead of reaching users.

The commands

# Run a Stagehand-based agent against a sample app with an injected fault.
# A failed run saves a fixture (and a report.md with the cause and the evidence).
npm run lab -- run --agent sh-p0 --fault silent-owner-drop

# Replay that fixture three times against the same or another agent version.
npm run lab -- replay fixtures/<fixture> --agent sh-p1 --trials 3

# Compare agent versions over every fixture. Non-zero exit if the last one fails: a CI gate.
npm run lab -- compare fixtures --agents sh-p0,sh-p1 --trials 3

sh-p0 and sh-p1 are the two Stagehand agents that ship with Lab: a neutral baseline prompt, and one that adds verification and safe-retry guidance. Stagehand's own model calls go through Lab's gateway, which is what makes an exact replay possible without an API key or a network call.

What a failure turns into

PieceWhat it is
SymptomWhat went wrong from the outside: false-success, missed-success, wrong-outcome, duplicate-action.
CauseDerived from the trace: for example stale-observation, unsafe-retry, app-dropped-field. A failure the rules cannot explain stays unexplained.
EvidenceThe step, the page state before and after it, and the request that shows it.
FixtureThe task, the starting state and the recorded model calls, so the run can be replayed.

Stagehand alternatives: which tool for which job

You want toUse
Drive a page with code plus natural-language instructionsStagehand (or Playwright directly, or browser-use from Python)
Find out why an agent run failed and keep it as a testWalkcast Lab
Check whether a new agent version fixed a bug or broke another taskWalkcast Lab, compare over your fixtures
Trace token counts and latency of runs you already haveAn observability tool, alongside Lab

Lab is not a replacement for Stagehand's way of driving a browser, and it does not need you to change it: it reads the recorder's output, so it also works with agents built on Playwright or browser-use. The Walkcast author has also proposed network record-and-replay to Stagehand's own eval tasks in browserbase/stagehand#3230 and #3231.

Sources

  • Stagehand's documentation describes its AI primitives (act, extract, observe), its Playwright-style page methods and the SDKs for TypeScript, Python and Go. docs.stagehand.dev
  • τ-bench introduced pass^k, a reliability measure over repeated trials; it found even strong function-calling agents succeeded on under half the tasks and were inconsistent across runs. That is the problem repeated trials are meant to expose. Yao et al., τ-bench (2024)

More

The full picture of runs, fixtures, experiments and the fault simulator is on the Walkcast Lab page, and the commands are in the Lab chapter of the README.

Questions people ask

How do I test a Stagehand agent?
Run it through Walkcast Lab against a real browser. A failed run is classified from the browser's own trace into a cause, saved as a fixture, and replayed against your next agent version from the recorded model calls, so a fix is checked rather than assumed.
What are Stagehand evals missing?
An eval says whether a task passed. It does not say why a run failed, and a pass rate over a few runs cannot separate a real improvement from a lucky one. Lab adds the classified cause with its evidence, a replayable fixture, and comparisons over repeated trials.
Is there a Stagehand alternative?
For driving a browser, the alternatives are Playwright directly or browser-use. For testing an agent after a run fails, Walkcast Lab is built for that job and works with Stagehand, Playwright and browser-use agents.
Stagehand vs browser-use vs Playwright: which should I use?
They are different tools for driving a browser, so the choice depends on how you want to write the automation: Playwright is a browser automation library you script directly, Stagehand adds natural-language actions on top of Playwright, and browser-use is an agent you run from Python. None of them decides why a run failed or proves a fix held. Walkcast Lab is the testing step after any of them.
Do I need an API key to replay a Stagehand run?
No. Stagehand's model calls are recorded when the run is made, and a replay serves those recorded responses instead of calling a provider, so it needs no key and no network.