Evals (evaluations) are a primitive for testing agent behavior systematically, ensuring quality, consistency, and correctness before deploying to production.
Overview
The Evals primitive provides a structured approach to testing agent capabilities, validating outputs, and measuring performance. Like unit tests for code, evals for agents ensure reliability and catch regressions before they impact users. Evals are essential for:- Quality Assurance: Verify agents produce correct, high-quality outputs
- Regression Testing: Catch behavior changes when updating prompts or configs
- Performance Validation: Ensure agents meet speed and cost targets
- Confidence Building: Deploy with certainty that agents work as expected
- Continuous Improvement: Track quality metrics over time
Systematic Testing
Define test cases that cover expected behavior and edge cases
Automated Validation
Run evals automatically in CI/CD or on schedule
Multiple Eval Types
Unit tests, integration tests, performance tests, and quality assessments
Actionable Insights
Clear pass/fail results with detailed feedback for improvements
How Evals Work
Evaluation Process
Evals follow a structured testing process:- Test Case Definition: Define inputs, expected outputs, and validation criteria
- Execution: Run agent with test inputs
- Output Capture: Collect agent responses
- Validation: Compare outputs against expected results or quality criteria
- Scoring: Assign pass/fail or numerical scores
- Reporting: Generate detailed test reports with insights
Eval Types
Different eval types serve different purposes:- Functional Evals: Test core capabilities (can the agent do X?)
- Quality Evals: Assess output quality (is the output good enough?)
- Performance Evals: Measure speed, cost, efficiency
- Regression Evals: Ensure changes don’t break existing functionality
- Edge Case Evals: Test behavior in unusual or problematic scenarios
Continuous Testing: Evals should run regularly - on every code change, prompt update, or scheduled intervals to catch issues early.
Code Examples
Basic Eval Structure
Eval Suite
Performance Evals
Quality Evals with LLM-as-Judge
Regression Testing
Eval Patterns
Categorized Test Suite
Organize evals by category:Unit Tests
Unit Tests
Test individual capabilities in isolation
Integration Tests
Integration Tests
Test multi-step workflows
Edge Cases
Edge Cases
Test unusual or problematic scenarios
Error Scenarios
Error Scenarios
Test error handling
CI/CD Integration
Automate evals in your deployment pipeline:Continuous Monitoring
Run evals on schedule to detect production issues:Use Cases
1. Pre-Deployment Validation
Ensure quality before deploying changes:2. Prompt Engineering
Test and refine prompts:3. Version Validation
Test new versions before promotion:Best Practices
Effective Test Design
Test Real Use Cases
Test Real Use Cases
Base tests on actual user scenarios
Make Tests Deterministic
Make Tests Deterministic
Tests should produce consistent results
Cover Edge Cases
Cover Edge Cases
Test boundary conditions and unusual inputs
Integration with Other Primitives
With Traces
Use traces to debug failing evals:With Versioning
Test different versions systematically:Performance Considerations
Eval Execution Time
- Simple validation: < 100ms overhead
- LLM-as-judge: 2-5 seconds per eval
- Parallel execution: Run independent tests in parallel
Optimization
Troubleshooting
Flaky Tests
Flaky Tests
Problem: Tests pass/fail inconsistentlySolutions:
- Make validation more flexible
- Account for acceptable variations
- Use semantic matching instead of exact matching
Tests Too Strict
Tests Too Strict
Problem: Tests fail on acceptable outputsSolutions:
- Focus on essential criteria
- Allow for reasonable variations
- Use LLM-as-judge for nuanced evaluation
Related Primitives
Traces
Debug failing evals with execution traces
Versioning
Test different versions systematically
Hooks
Add custom validation logic
Self-Evolving
Use eval results to improve agents
Additional Resources
API Reference
Agent execution parameters
Best Practices
Quality assurance patterns