Skip to main content
Every eval function receives an EvalContext that accumulates evaluation data and builds into an EvalResult.

Pre-populated Fields

Set context fields directly in the @eval decorator:
With cases=, input and reference in each case auto-populate the context fields:

Setting Fields

Input, Output, and Reference

Metadata

Store additional context for debugging and analysis:

Scoring with Assertions

Use assertions to score:
Failed assertions become failing scores with the message as notes.

Using store() for Explicit Scoring

For numeric scores or multiple named metrics, use store():

Setting Multiple Fields at Once

store() lets you set multiple context fields in one call:

Auto-Return Behavior

You don’t need to explicitly return anything—the context automatically builds into an EvalResult when the function completes:

Exception Safety

If your evaluation throws an exception, partial data is preserved:
The resulting EvalResult will have:
  • input and output preserved
  • error field with the exception message
  • A failing score automatically added

Default Scoring

If no score is added and no assertions fail, EZVals auto-adds a passing score:

Custom Parameters

For case-based tests with custom data, store it in ctx.input:

Run Metadata (for Observability)

When your eval function runs, the context includes metadata about the current run and eval. This is useful for tagging traces in LangSmith or other observability tools.

Run-Level Metadata

Per-Eval Metadata

API Reference

store() Parameters