Introduction
Evals (evaluations) let you measure how well your agent or task function performs across a set of test cases. Rather than checking a single output manually, you define a Dataset of inputs (with optional expected outputs), run your function over all of them, and score each result with Evaluators. This is a 1-1 TypeScript port of Pydantic AI’s evals module. Key benefits:- Systematic testing - catch regressions across many input scenarios
- Quantitative scoring - go beyond pass/fail with numeric scores and summary statistics
- LLM-as-judge - use a language model to evaluate subjective qualities like helpfulness or accuracy
- Concurrency - run cases in parallel with configurable limits
- Immutable data - all dataset transformations return new objects
Quick start
Dataset and case
A Dataset is an immutable collection of Cases. Each Case has:Creating datasets
Immutable transformations
Serialization
Built-in evaluators
All built-in evaluators implement theEvaluator interface and return an EvalScore.
Case-level evaluators
EvalScore
Every evaluator returns anEvalScore:
LLM-as-judge
For subjective qualities (helpfulness, accuracy, tone), use an LLM as the evaluator.Helper functions
For one-off judge calls (outside of a dataset):Custom evaluators
Implement theEvaluator interface for full control:
custom() factory:
Accessing context
TheEvaluatorContext gives evaluators access to:
Report-level evaluators
Report evaluators run once after all cases complete and receive the fullCaseResult[] array. Use them for aggregate metrics.
Experiment runner
UseDataset.evaluate() as your primary API. The runExperiment() function is a thin wrapper for cases where you want to merge extra evaluators at call time:
Evaluate options
Span-based evaluation
When your task function captures OTel spans, you can evaluate them withhasMatchingSpan: