Skip to main content
Evaluators are a special type of step that scores content — usually LLM output. They return an EvaluationResult with a value, a confidence score, and optional reasoning. The real power is using that score in your workflow to control what happens next: retry if quality is low, skip a step if confidence is high, or branch to a different path. This generate-evaluate-retry loop is how you build self-correcting workflows — and it’s a core pattern when building AI agents. Evaluators can be deterministic (rule-based checks) or use an LLM to judge quality. Deterministic evaluators are great for structured checks like length, format, or required fields. But more often than not, you’ll want LLM-as-a-judge — using an LLM to evaluate things that are hard to check with rules, like whether a summary is accurate, an email sounds natural, or a classification makes sense.

Deterministic Evaluator

A simple evaluator that checks whether a company summary meets basic structural requirements:
evaluators.ts
Deterministic evaluators are fast and predictable — confidence is always 1.0 because there’s no ambiguity. Use them for checks where the rules are clear-cut.

LLM-as-a-Judge Evaluator

For subjective quality — accuracy, tone, relevance — you need an LLM to evaluate. This is the more common pattern:
evaluators.ts
Evaluators are called from workflows like regular async functions — await judgeSummaryQuality({ summary, companyName }). The workflow decides what to do with the result.

Evaluator Properties

EvaluationResult Types

Evaluators must return an EvaluationResult. Three types are available depending on what you’re scoring:

EvaluationBooleanResult

EvaluationBooleanResult:
  • Pass/fail judgments
  • value: boolean
  • Quality gates, compliance checks

EvaluationNumberResult

EvaluationNumberResult:
  • Numeric scores
  • value: number
  • Ratings (1-10), percentages

EvaluationStringResult

EvaluationStringResult:
  • Category assignments
  • value: string
  • Classifications, labels
All three types share the same base fields:

Boolean Evaluator

Pass/fail checks. Use these as quality gates — does this output meet the bar?
evaluators.ts

Number Evaluator

Numeric scores for when you need more granularity than pass/fail. In most cases, pass/fail or a three-tier scale (pass/borderline/fail) gives more consistent results — see Evaluator Best Practices. But numeric scores are useful when you need to rank or compare outputs, or when you have well-defined anchors for each score level.
evaluators.ts

String Evaluator

Category assignments — classifying content into labels.
evaluators.ts

Feedback and Dimensions

For more detailed evaluations, you can attach feedback (specific issues and suggestions) and dimensions (sub-scores that break down the overall result).
evaluators.ts

Using Evaluators in Workflows

Evaluators are called like regular async functions. The typical pattern is: generate something, evaluate it, then decide what to do based on the score.
workflow.ts
This pattern — generate, evaluate, retry if needed — is the core of LLM-as-a-judge. The evaluator gives your workflow a way to check its own work.

Options

Evaluators support the same options as steps for configuring retry behavior and timeouts. See Step Options for the full list.
evaluators.ts

Shared Evaluators

When multiple workflows need the same evaluator, put it in src/shared/evaluators/:
src/shared/evaluators/check_factuality.ts
Import shared evaluators in any workflow:
workflow.ts
Shared evaluators can only be imported by workflows, not by other evaluators or steps. This enforces the activity isolation rule — evaluators are activities and activities can’t call other activities.

Evaluation Workflows

The evaluators on this page run inside your workflows — they power generate-evaluate-retry loops in production. For testing workflow quality across datasets without modifying your workflow code, see Evaluation Workflow. It covers verify() for creating typed evaluators, Verdict helpers for deterministic assertions, LLM judge functions, datasets, and running evals from the CLI.

What’s Next