Why Evaluations Matter
- Performance Optimization: Identify which models and settings work best for your specific automation tasks
- Cost Control: Track token usage and inference time to optimize spending
- Reliability: Measure success rates and identify failure patterns
- Model Selection: Compare different LLMs on real-world tasks to make informed decisions
Live Model Comparisons
View real-time performance comparisons across different LLMs on the Stagehand Evals Dashboard
Comprehensive Evaluations
Evaluations help you systematically test and improve your automation workflows. Stagehand provides both built-in evaluations and tools to create your own.To run evals, you’ll need to clone the Stagehand repo and run
npm install
to install the dependencies.- Deterministic Evals - These are evals that are deterministic and can be run without any LLM inference.
- LLM-based Evals - These are evals that test the underlying functionality of Stagehand’s AI primitives.
LLM-based Evals
To run LLM evals, you’ll need a Braintrust account.
npm run evals
from within the Stagehand repo. This will test the functionality of the LLM primitives within Stagehand to make sure they’re working as expected.
Evals are grouped into three categories:
- Act Evals - These are evals that test the functionality of the
act
method. - Extract Evals - These are evals that test the functionality of the
extract
method. - Observe Evals - These are evals that test the functionality of the
observe
method. - Combination Evals - These are evals that test the functionality of the
act
,extract
, andobserve
methods together.
Configuring and Running Evals
You can view the specific evals inevals/tasks
. Each eval is grouped into eval categories based on evals/evals.config.json
. You can specify models to run and other general task config in evals/taskConfig.ts
.
To run a specific eval, you can run npm run evals <eval>
, or run all evals in a category with npm run evals category <category>
.
Viewing eval results

npm run evals
.
By default, each eval will run five times per model. The “Exact Match” column shows the percentage of times the eval was correct. The “Error Rate” column shows the percentage of times the eval errored out.
You can use the Braintrust UI to filter by model/eval and aggregate results across all evals.
Deterministic Evals
To run deterministic evals, you can just runnpm run e2e
from within the Stagehand repo. This will test the functionality of Playwright within Stagehand to make sure it’s working as expected.
These tests are in evals/deterministic
and test on both Browserbase browsers and local headless Chromium browsers.
Creating Custom Evaluations
Step-by-Step Guide
1
Create Evaluation File
Create a new file in
evals/tasks/your-eval.ts
:2
Add to Configuration
Update
evals/evals.config.json
:3
Run Your Evaluation
Best Practices for Custom Evals
Test Design Principles
Test Design Principles
- Atomic: Each test should validate one specific capability
- Deterministic: Tests should produce consistent results
- Realistic: Use real-world scenarios and websites
- Measurable: Define clear success/failure criteria
Performance Optimization
Performance Optimization
- Parallel Execution: Design tests to run independently
- Resource Management: Clean up after each test
- Timeout Handling: Set appropriate timeouts for operations
- Error Recovery: Handle failures gracefully
Data Quality
Data Quality
- Ground Truth: Establish reliable expected outcomes
- Edge Cases: Test boundary conditions and error scenarios
- Statistical Significance: Run multiple iterations for reliability
- Version Control: Track changes to test cases over time
Troubleshooting Evaluations
Evaluation Timeouts
Evaluation Timeouts
Symptoms: Tests fail with timeout errorsSolutions:
- Increase timeout in
taskConfig.ts
- Use faster models (Gemini 2.5 Flash, GPT-4o Mini)
- Optimize test scenarios to be less complex
- Check network connectivity to LLM providers
Inconsistent Results
Inconsistent Results
Symptoms: Same test passes/fails randomlySolutions:
- Set temperature to 0 for deterministic outputs
- Increase repetitions for statistical significance
- Use more capable models for complex tasks
- Check for dynamic website content affecting tests
High Evaluation Costs
High Evaluation Costs
Symptoms: Token usage exceeding budgetSolutions:
- Use cost-effective models (Gemini 2.0 Flash, GPT-4o Mini)
- Reduce repetitions for initial testing
- Focus on specific evaluation categories
- Use local browser environment to reduce Browserbase costs
Braintrust Integration Issues
Braintrust Integration Issues
Symptoms: Results not uploading to dashboardSolutions:
- Check Braintrust API key configuration
- Verify internet connectivity
- Update Braintrust SDK to latest version
- Check project permissions in Braintrust dashboard