Skip to main content
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:
  1. Test Case Definition: Define inputs, expected outputs, and validation criteria
  2. Execution: Run agent with test inputs
  3. Output Capture: Collect agent responses
  4. Validation: Compare outputs against expected results or quality criteria
  5. Scoring: Assign pass/fail or numerical scores
  6. 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:
Test individual capabilities in isolation
Test multi-step workflows
Test unusual or problematic 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

Base tests on actual user scenarios
Tests should produce consistent results
Test boundary conditions and unusual inputs

Integration with Other Primitives

With Traces

Use traces to debug failing evals:
Learn more: Traces Primitive

With Versioning

Test different versions systematically:
Learn more: Versioning Primitive

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

Problem: Tests pass/fail inconsistentlySolutions:
  • Make validation more flexible
  • Account for acceptable variations
  • Use semantic matching instead of exact matching
Problem: Tests fail on acceptable outputsSolutions:
  • Focus on essential criteria
  • Allow for reasonable variations
  • Use LLM-as-judge for nuanced evaluation

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
Remember: Evals are your safety net. Write tests for critical functionality, run them automatically, and let them catch issues before users do.