Skip to main content

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

Output:

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 the Evaluator interface and return an EvalScore.

Case-level evaluators

EvalScore

Every evaluator returns an EvalScore:

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 the Evaluator interface for full control:
Or use the custom() factory:

Accessing context

The EvaluatorContext gives evaluators access to:

Report-level evaluators

Report evaluators run once after all cases complete and receive the full CaseResult[] array. Use them for aggregate metrics.

Experiment runner

Use Dataset.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 with hasMatchingSpan:

Dataset generation

Use an LLM to generate test cases automatically:

Eval pipeline

Concurrency flow