Skip to main content
This guide covers the complete syntax for writing evals, from basic tests to complex multi-validator scenarios.

File Structure

Evals are defined in YAML files. Each file can contain multiple eval definitions:

Eval Definition

Required Fields

Eval names must be unique across all eval files in your project. The CLI will error if duplicate names are found.

Optional Fields

Params Structure

The params field contains input parameters passed to your runnable:

Simple Prompt

With Messages

Use messages to establish conversation history for multi-turn testing:
The agent receives the full conversation history and responds to the last message. This is useful for testing context retention, memory, and whether the agent avoids redundant tool calls when context is already available.
When using messages instead of prompt, the agent’s input key will be messages rather than prompt.

Additional Parameters

Pass any additional parameters your agent accepts:

Validating Output

The output section validates the final response from your agent:
Multiple validators can be combined - all must pass.

Validating Timing

The elapsed section validates total execution time in milliseconds:

Validating Tool Spans

Validate specific tools by their name:

Validating Token Usage

Access usage metrics on LLM spans:
The token field names depend on the model provider:
  • OpenAI: Use input_text_tokens and output_text_tokens (e.g., input_text_tokens: lte!: 500, output_text_tokens: lte!: 1000)
  • Anthropic: Use input_tokens and output_tokens (e.g., input_tokens: lte!: 500, output_tokens: lte!: 1000)
For multi-model scenarios, tokens are automatically summed across models.

Flow Validators

Sequence Validation

Use seq! to validate the order of tool execution:
With wildcards for flexible matching:

Parallel Validation

Use parallel! to validate concurrent execution:

Nested Flow Validation

Combine sequence and parallel:

Span Validation Within Sequence

Validate span inputs/outputs within the sequence:

Complete Example

Wildcard Patterns in Sequences

Tags and Filtering

Use tags to organize and filter evals:

Environment Variables

Set environment variables for specific evals:

Best Practices

Names should clearly indicate what’s being tested:
Use multiple validators to thoroughly test behavior:
Don’t just check the output - validate how the agent got there:
For outputs that can vary in wording but should convey the same meaning:
Prefer prompt! (a verifiable statement about the output) for behavioral checks. Use semantic! when matching against a description of tone or style, e.g. semantic!: "A professional, empathetic response".
Create specific evals for error conditions:

File Naming Conventions

Timbal discovers eval files matching these patterns:
  • eval*.yaml - e.g., eval_search.yaml, evals.yaml
  • *eval.yaml - e.g., search_eval.yaml, my_eval.yaml
Organize evals by feature or agent: