Skip to content

Harnesses

A harness is the boundary between production behavior and eval infrastructure. It should be thin: call the same app entrypoint you use in production, then return the output, ordered transcript events, optional traces, and usage that tests and judges need. Tool-call helpers derive their results from the transcript.

Use the first-party adapter that matches the runtime your app already uses. Use createHarness() when the app is not built on a supported SDK or when you need full control over normalized run data.

Every harness returns a JSON-serializable result. Judges and reports read the same shape regardless of runtime:

FieldPurpose
outputThe domain value your tests usually assert on.
session.eventsOrdered transcript events, including messages, tool-call requests, and tool results.
toolCalls(result)Deterministic tool-call projection for tool judges and replay checks.
tracesOperation spans for runs, model calls, tools, guardrails, handoffs, or custom work.
usageStable usage units such as provider, model, tokens, tools, and retries.

First-party harnesses attach trace spans automatically from native runtime data they observe. createHarness() attaches a fallback run span when a custom harness does not return traces itself. Span attributes are JSON-safe and include typed OpenTelemetry GenAI semantic keys where they apply.