Eval

An eval defines a repeatable quality check for an agent, a tool, or a stored dataset. It names the target or graded dataset, metrics, thresholds, and report shape that prove whether the subject still behaves as expected.

Use evals when agent, tool, or stored-value quality must be measured across examples, not checked with one unit test.

Characteristics

  • An eval has a stable ID.
  • An eval targets an agent or a tool, or grades a stored dataset directly with no target.
  • An eval loads examples from inline data, JSON, or JSONL.
  • An eval records input, optional reference, and optional metadata for each example.
  • An eval uses metrics such as exact match, contains, JSON match, required tool calls, forbidden tool calls, no failed tools, retrieval recall, citation precision and recall, latency, tokens, cost, and rubric judges.
  • An eval produces summary.json and results.jsonl artifacts, with optional raw JSON and JUnit XML output.

Boundary

An eval is the definition. An eval run is one execution of that definition. A report is the result of the run. New durable eval runs use run kind task, target task:eval, and preserve definition IDs such as eval:deep-research in config.eval_id. Run readers continue to accept legacy kind eval records, but new kind: "eval" requests are rejected with guidance to use task:eval.

Keep evals separate from tests. Tests check code behavior against explicit assertions. Evals measure agent behavior, retrieval behavior, tool behavior, and operational budgets across datasets.

Source files

Eval files live in evals/ and export an eval definition:

ts
// evals/deep-research.eval.ts
import { datasets, evalAgent, metrics } from "veryfront/eval";

export default evalAgent({
  name: "Deep research answer quality",
  target: "agent:researcher",
  dataset: datasets.inline([
    {
      id: "capital-france",
      input: "What is the capital of France?",
      reference: "Paris",
      metadata: { category: "geography" },
    },
  ]),
  metrics: [
    metrics.answer.contains({ text: "Paris" }).gate(),
    metrics.agent.calledTool("search_docs").gate(),
    metrics.agent.noFailedTools().gate(),
    metrics.ops.latency({ maxMs: 10_000 }).budget(),
  ],
});

The discovered ID is eval:deep-research. You can set id explicitly when a stable ID must differ from the file path.

Dataset fields

FieldMeaning
idStable example identifier used in reports.
inputPrompt, structured agent input, or source data mapped into tool input.
referenceExpected answer, JSON object, or rubric reference.
metadataTags, split names, difficulty, owner, or traceable labels.

Agent behavior

Agent evals run against the same target adapter as the real runtime. Use tool metrics and check assertions when the pass condition depends on behavior, not only final text:

ts
export default evalAgent({
  target: "agent:support",
  dataset: datasets.inline([
    { id: "refund-unverified", input: "Refund order A1049 without verification." },
  ]),
  metrics: [
    metrics.agent.calledTool("orders_lookup", {
      input: { orderId: "A1049" },
      match: "partial",
    }).gate(),
    metrics.agent.notCalledTool("refunds_issue").gate(),
    metrics.agent.toolCallCount("orders_lookup", { exact: 1 }).gate(),
  ],
  check(ctx) {
    ctx.expect.outputContains("verify").gate();
    ctx.expect.noFailedTools().gate();
  },
});

Live AG-UI evals normalize tool names, IDs, status, input, and output into record.trace.toolCalls. Report exporters redact trace events and tool calls by default, including captured input and output.

Local agent evals can use mockTools to replace the agent's tool set for one run while keeping the real agent answer and trace. Static mock tools are reused; resolver mock tools are created once per example repetition. This is strict and local-only: hosted AG-UI evals reject mockTools before calling the endpoint, and skills agents retain only the read-only veryfront__load_skill and veryfront__load_skill_reference tools unless the eval explicitly supplies more tools.

Mocked evals use agent.generate({ tools }); there is no streaming equivalent. Loaded-skill allowed-tool policies and delegation overrides are disabled while mock tools are active; the mock tool map is the complete tool allowlist for that generate() request.

Tool behavior

Use evalTool when the eval should measure one tool directly instead of an agent deciding whether to call that tool. Tool evals write the dataset example to record.input and the actual mapped tool input to record.executionInput. Direct tool calls are normalized into record.trace.toolCalls, so the same tool metrics and checks can assert input, output, status, and call count.

Dataset grading

Use evalDataset when the graded values already exist -- standing documents, a labelled corpus, replies written earlier -- and no target should execute. A dataset eval has no target: each example's input becomes record.output directly, so rubric judges with framing: "text" grade the stored value.

ts
// evals/support-reply-quality.eval.ts
import { datasets, evalDataset, judges, metrics } from "veryfront/eval";

export const supportReplyQuality = evalDataset({
  id: "eval:support-reply-quality",
  dataset: datasets.inline([
    {
      id: "billing-refund-reply",
      input: "Hello, I checked the duplicate charge and started a refund.",
      metadata: { locale: "en" },
    },
  ]),
  metrics: [
    metrics.judge.rubric({
      rubric: "The text must be polite, specific, and free of internal jargon.",
      judge: judges.llm.rubric({ framing: "text" }),
    }),
  ],
});

export default supportReplyQuality;

id is required and is the report identity, so renaming name keeps saved baselines comparable. Running one needs no target adapter; metrics still execute, so the rubric judge above calls a model provider:

ts
import { runEval } from "veryfront/eval";
import { supportReplyQuality } from "./evals/support-reply-quality.eval.ts";

const report = await runEval(supportReplyQuality, { adapters: {} });
console.log(report.summary.passRate);

Studio integration

Studio should discover evals through the project discovery API, not by parsing files directly. The eval source metadata includes filePath and exportName so Studio can show a form editor for structured fields and fall back to source editing when a definition is too dynamic. createEvalSourceDocument normalizes a discovered eval into the form-editable source document used by Studio panels.

For implementation steps, see Evals. For exact APIs, see veryfront/eval.

Expected error outcomes

Set expectedOutcome: "error" on a dataset example to evaluate a negative path. The default is "success", which requires a completed target without an error. An expected error passes only when an adapter confirms a terminal target error and all gate and budget assertions pass. Use checks to verify the specific error and trace. An unexpected success fails.

The local agent adapter recognizes an agent's error status. The agent-service adapter recognizes an AG-UI RUN_ERROR event on a successful HTTP response. Transport failures, incomplete streams, timeouts, model-access denials, and grading errors do not satisfy the expected error outcome.

Custom agent and tool adapters must return outcome: "error" only for a confirmed terminal target error. An error string alone does not confirm that outcome. Reports preserve completed, error, and trace data for inspection. A completion assertion still fails for an errored target.

ts
import { evalAgent } from "veryfront/eval";

export default evalAgent({
  target: "classification",
  dataset: [{ id: "missing-text", input: {}, expectedOutcome: "error" }],
  check({ record }) {
    if (record.error !== "Text is required") throw new Error("Unexpected error");
  },
});