SDKJune 26, 20261 min read
Code-colocated evals: defineEval in the TypeScript SDK
Define evals next to your flows and agents with defineEval, converge them with evals.ensure, and gate CI with the runtype eval run command. Trace graders assert on tool calls, step order, and cost.
evalssdkclici
Evals now live in your repo, right next to the flows and agents they test. Author them in TypeScript, converge them at deploy time, and fail CI when quality regresses.
defineEval. A pure, typed constructor for eval suites: target, cases, and graders, with builders likecontains,matchesExpected,jsonField, andjudgefor AI grading.evals.ensure. Hash-first, idempotent converge for suites, the eval sibling offlows.ensure. Unchanged suites are a no-op;evals.pullreads the platform's current definition back.runtype eval run. The CLI discovers*.eval.tsfiles, runs each suite synchronously against its target, and maps results to exit codes, with--junitoutput for CI. Backed by the new synchronous/eval/runendpoint.- Trace graders. Deterministic, free assertions over how the run behaved:
calledTool,toolOrder,ranStep,stepOrder,completed,maxToolCalls, andcost. - Inline
evals:on flows. Attach suites directly todefineFlow; they converge with the flow, defaulting to it as the target. Graders can chain.gate()or.soft(), and--strictpromotes soft misses to failures.
One CI step, and an eval regression stops in review instead of production.