EvalContext. Knowing what the context holds and how it becomes a result covers most of what you need to write evals.
Define an eval
- The eval’s name is the Python function name or the first argument to
evaluate(). Its id is<file>::<name>, for examplesupport.eval.ts::test_cancellation. datasetdefaults to the file name (evals.pybecomesevals,support.eval.tsbecomessupport).- Functions can be sync or async.
- With no options, use a bare
@evalorevaluate(name, fn).
reference, default_score_key, timeout, trials, target, evaluators, cases, input_loader) is in the Python and TypeScript references.
The context
Options you pass to the decorator start out onctx. Your eval fills in the rest:
store() sets several fields in one call. metadata and trace_data merge. A score with the same key as an existing score replaces it.
Run information
The context also tells your eval where it’s running. You can use this to tag traces in an external tool, or to read the settings of a run config:Errors
An exception other than an assertion failure is not a score. It’s recorded as the result’serror: the exception type, the message and the traceback. Anything already on the context, such as the input and any output you set, is kept. Errored results don’t pass, and evaluators don’t run on them.
Timeouts
Settimeout (in seconds) on an eval, in file defaults, or for every eval with --timeout or timeout in ezvals.json. The run-wide value overrides per-eval timeouts. When an eval hits its timeout it stops, and its error is TimeoutError: Evaluation timed out after 5.0s.
The timeout cancels the whole eval function, so an except TimeoutError inside the eval never runs. To score slowness instead of treating it as an error, put a shorter time limit on the agent call yourself:
In TypeScript, code that blocks the event loop can’t be interrupted. The eval is still reported as timed out, but the blocking work keeps running until it finishes.
Returning several results
An eval can also return a list of results instead of usingctx. This is useful when one call produces many outputs to grade. In Python, return EvalResult objects. In TypeScript, return plain objects with the same fields.

