evalLab
Runtime + EvalSuite + (optional) ReplayClient trio wired for research reproducibility. The eval / research lab recipe — supply the model config, the eval suite cases, and a replay-cache backend, and re-derive the report months later without re-running the LLM.
evalLab bakes the canonical wiring of @pleach/core +
@pleach/eval + @pleach/replay for research-grade eval
runs. The factory constructs a SessionRuntime, hands it to
a consumer-supplied EvalSuite factory, and optionally
constructs a ReplayClient for deterministic re-derivation
of a past run's report from its captured event log.
Best fit: an eval / research lab. The load-bearing constraint is that the SAME suite must reproduce results bit-exactly months later, often for peer review or regulatory audit. The factory bakes the wiring order so the consumer just supplies the model config, the suite cases, and (optionally) the replay-cache factory.
The recipe and @pleach/eval are both experimental: their shapes
can change between releases.
Quickstart
import { evalLab } from "@pleach/recipes/eval-lab";
import { AnthropicSdkProvider } from "@pleach/core";
import { EvalSuite } from "@pleach/eval";
import { ReplayClient } from "@pleach/replay";
const lab = evalLab({
suiteId: "claude-vs-gpt5-2026-Q3",
provider: new AnthropicSdkProvider({
apiKey: process.env.ANTHROPIC_API_KEY!,
}),
model: "claude-sonnet-4-6",
evalSuiteFactory: (opts) => new EvalSuite(opts),
replayClientFactory: (runtime) =>
new ReplayClient({ runtime, tenantId: "lab-001", eventSource: myEventSource }),
});
lab.addCase({
kind: "expected",
id: "qa-pubmed-001",
input: "What gene is implicated in cystic fibrosis? Answer with the symbol only.",
expected: /\bCFTR\b/,
});
const report = await lab.run(); // each case is answered by the model
console.log(`Passed: ${report.summary.passed}/${report.summary.total}`);
// Months later, re-derive the report without re-running the LLM:
const replayed = await lab.replay(report.runId);
console.log(`Identical: ${replayed.summary.passed === report.summary.passed}`);provider and model are the main path: the runtime builds its own
adapter over that provider, so there is nothing to register at boot.
AnthropicSdkProvider loads @anthropic-ai/sdk when a case runs, so
install it alongside the recipe.
Advanced: orchestratorConfig. You can pass orchestratorConfig
instead of provider. It is forwarded to the runtime as
host.strategies.orchestratorConfig, and on its own it does not wire a
model: register an adapter constructor at app boot with
setOrchestratorAdapterCtor() from @pleach/core/runtime, before
calling evalLab(...). Import the setter from that subpath, not the
root @pleach/core barrel, or the runtime will not see it.
What it does
The recipe constructs three things in sequence:
- A
SessionRuntimeviacreatePleachRuntimefrom@pleach/core/runtime.providerandmodelpass straight through;orchestratorConfig, when set, is plumbed throughhost.strategies.orchestratorConfig(mirrorssimpleChatbot). - An
EvalSuiteby calling the consumer-suppliedevalSuiteFactory({suiteId, runtime}). Calling the factory eagerly at construction lets the consumer calllab.addCase(...)before the firstlab.run(). - (Optional) A
ReplayClientby calling the consumer-suppliedreplayClientFactory(runtime). Without it,lab.replay()throws — research consumers who need deterministic re-derivation must supply one.
The lab then installs its own actual-output resolver on the
suite, so the model's reply is what gets graded. For each case,
lab.run() sends the case input to the runtime in a fresh
session, collects the reply, grades it with the case's
expected, scorer or judges, and deletes the session. No
conversation state carries from one case to the next.
With no provider wired (no provider, no orchestratorConfig,
and no adapter attached through runtime.adapter.set() by the
time run() is called), lab.run() rejects with
NoProviderConfiguredError before any case runs. A report never
grades the case input or placeholder text as the model's answer.
lab.replay(runId) delegates to replayClient.fromRun(runId).
addCase forwards to the suite's register.
Config reference
type OrchestratorConfigPassthrough = Record<string, unknown>;
interface EvalCaseLike {
id: string;
input: string | Record<string, unknown>;
}
interface EvalReportLike {
runId: string;
summary: { total: number; passed: number; failed: number };
cases: readonly unknown[];
}
interface EvalSuiteLike {
register(testCase: EvalCaseLike): void;
setActualResolver(
resolver: (testCase: EvalCaseLike) => Promise<string> | string,
): void;
run(): Promise<EvalReportLike>;
}
interface ReplayClientLike {
fromRun(runId: string): Promise<{
summary: { runId: string; total: number; passed: number; failed: number };
}>;
}
interface EvalLabConfig extends CreatePleachRuntimeConfig {
// From CreatePleachRuntimeConfig: `provider?: AgentProvider`
// and `model?: string` — the main way to wire the model.
/** Identifier for the suite — surfaces in per-case report rows. */
suiteId: string;
/**
* Advanced. Forwarded as host.strategies.orchestratorConfig;
* needs an adapter ctor registered at boot with
* setOrchestratorAdapterCtor() from @pleach/core/runtime.
*/
orchestratorConfig?: OrchestratorConfigPassthrough;
/**
* REQUIRED. Pass `(opts) => new EvalSuite(opts)` from
* @pleach/eval. The recipe does NOT hard-import the class
* — that would force a build-time peer dep on the suite
* class for every consumer of @pleach/recipes.
*/
evalSuiteFactory: (opts: {
suiteId: string;
runtime: SessionRuntime;
}) => EvalSuiteLike;
/**
* Optional. Pass `(runtime) => new ReplayClient({...})` from
* @pleach/replay. When omitted, lab.replay() throws.
*/
replayClientFactory?: (runtime: SessionRuntime) => ReplayClientLike;
}
interface EvalLab {
readonly runtime: SessionRuntime;
readonly suite: EvalSuiteLike;
addCase(c: EvalCaseLike): void;
run(): Promise<EvalReportLike>;
replay(runId: string): Promise<{
summary: { runId: string; total: number; passed: number; failed: number };
}>;
}Common gotchas
evalSuiteFactoryis REQUIRED. The recipe does NOT hard-importEvalSuitefrom@pleach/eval— that would force a build-time peer dep on every@pleach/recipesconsumer. You supply(opts) => new EvalSuite(opts)and the recipe wires it in. The structural typeEvalSuiteLikeis the contract.replayClientFactoryis OPTIONAL but load-bearing for the eval / research lab use case. Without it,lab.replay(runId)throws with a message explaining the contract. Research consumers whose value proposition is reproducible re-derivation must supply one — typically(runtime) => new ReplayClient({ runtime, tenantId, eventSource }).- The suite is constructed eagerly.
evalSuiteFactoryfires atevalLab(...)call time, not at firstrun(). This lets you calladdCase(...)before the first run; it also means a factory that throws will surface at construction. addCaseforwards tosuite.register. The recipe does not validate or transform the case payload. The shape is whateverEvalSuite.register(c)accepts at the@pleach/evalversion you installed.- The lab owns the suite's actual-output resolver. It
replaces any resolver the factory's suite already had.
Calling
lab.suite.setActualResolver()yourself replaces the lab's resolver, and the suite stops grading the model's answers. - Two optional peers, both load-bearing.
@pleach/evalis required at runtime forevalSuiteFactoryto resolve.@pleach/replayis required only whenreplayClientFactoryis supplied. Install the pair alongside@pleach/recipes. - Subpath import is load-bearing. Import from
@pleach/recipes/eval-lab, not the root barrel.
See also
@pleach/recipesoverview — every recipe in one page.@pleach/eval—EvalSuite, scorer types, suite shape.@pleach/replay—ReplayClient,fromRun, the deterministic re-derivation contract and the divergence error hierarchy.Eval and Replay— the composition pattern this recipe wires.Determinism— the substrate guarantee replay relies on.enterpriseAgent— composes cleanly alongsideevalLabfor the enterprise provider-parity validation loop.
enterpriseAgent
Compliance scrubber + sub-agent attribution + procurement-visible permittedFamilies envelope, stacked into one factory. The frontier-lab direct-enterprise recipe — two of the three pillars wired in-process; the third (gateway-side family failover) reads the envelope at runtime.
Customer support agent
A multi-turn support agent with tool-backed lookups, human escalation, and a per-customer audit trail you can hand to a regulator without grep.