# Evaluations

> Run a workflow version over a dataset of known cases, score each run against the Result it should produce, and compare versions on accuracy, duration, tokens, and cost.

Source: https://developers.manykind.ai/agents/workflows/evaluate/overview/

This group covers evaluating a workflow: this overview, then [datasets](https://developers.manykind.ai/agents/workflows/evaluate/datasets/) of cases, [experiments](https://developers.manykind.ai/agents/workflows/evaluate/experiments/) that run them, and the typed [Result](https://developers.manykind.ai/agents/workflows/evaluate/results/) they are matched against.

An evaluation answers one question before you switch a workflow to a new version: does it still produce the right Result, and what does it cost? You keep a **dataset** of cases, run a workflow version over it as an **experiment**, and compare that experiment with a **baseline**.

A dataset marked **Required for release** gates a release: Release runs it and gives no version number until it passes. Every other dataset is warn-only, and nothing in evaluations blocks `mk push` or a deploy. See [Release and deploy](https://developers.manykind.ai/agents/workflows/release/#required-datasets).

## The parts

| Term | What it is |
|---|---|
| **Dataset** | A versioned set of cases for one workflow. Names are unique per workflow. |
| **Case** | One `workflow.start` payload (`input`) and what the run's Result should be (`expected`). |
| **Dataset version** | A frozen cut of a dataset: every live case pinned at one revision. Cut automatically when an experiment runs changed cases. |
| **Experiment** | One dataset version run against one workflow version, each case run `repeats` times. |
| **Run** | One case × one repeat inside an experiment, with its output, scores, and metrics. |
| **Result** | The fields a workflow's Result step (`output` step) declares. Runs are scored against these fields and nothing else. |
| **Baseline** | The experiment other experiments on a dataset are compared to. |

```
dataset "triage" v3 ──┐
                      ├─► experiment exp-… ──► runs (case × repeat) ──► scores + metrics
workflow v1.4.0 ──────┘                                   │
                                                          ▼
                                          compare with the baseline experiment
```

## How a run is scored

1. The experiment publishes the case's `input` as a `workflow.start` event into a context of its own (`eval-<experimentId>-<caseId>-<repeat>-a<attempt>`).
2. The workflow runs as it would for any other start event: real model calls, real agent steps, real cubby writes.
3. When the run ends, its `workflow.completed` output (the declared [Result](https://developers.manykind.ai/agents/workflows/evaluate/results/)) is matched field by field against the case's `expected`.
4. The run's duration, tokens, cost, and step count are read back from the platform and checked against the dataset's limits.

A case passes when every judged field passes. Limits only warn; they never fail a case. See [Results](https://developers.manykind.ai/agents/workflows/evaluate/results/) for the matching rules.

:::caution
An experiment runs your workflow for real. Every run calls models, writes cubby rows, publishes events, and performs connector actions. Run experiments in a vault where that is safe, and make side-effecting steps idempotent. An experiment's runs have ids starting with `run-eval-`, so rows you key on `{{ $runId }}` are easy to tell apart.
:::

## Evaluations and tests

| | Local tests | Evaluations |
|---|---|---|
| Runs | On your machine, in-process | On the platform, against a deployed version |
| Models | Mocked | Real |
| Checks | Exact behaviour: cubby rows, events, branches, budgets | The Result, plus duration, tokens, cost, steps |
| Answers | "Does the graph do what I wrote?" | "Is this version as good as the last one, on real inputs?" |
| Use | Every commit | Before switching the live version, after prompt or model changes |

Use both. Tests pin down logic that must never change; a dataset catches the quality drift that only real model calls show. See [Test a workflow](https://developers.manykind.ai/agents/workflows/test/).

## Where evaluations live

**ROC.** Open a workflow and select the **Evaluations** tab. It has two views:

- **Experiments**: every experiment of the workflow, across its datasets. Tiles for the newest one against its dataset's baseline (**Accuracy**, **p50 duration**, **Tokens/run**, **Cost/run**), a **History** chart, **Accuracy by field**, and the experiment list with a **Verdict** per experiment. Filter the list by `dataset:`, `workflow:`, `verdict:`, or free text.
- **Datasets**: the workflow's datasets in a list, with **New dataset**. The open dataset shows its cases, **Import**, **Add from executions**, **Add case**, and its **History** of versions.

**Run experiment**, beside the tabs, runs the dataset open in the **Datasets** view, or asks which dataset when none is open. The **Evaluations** item in the sidebar lists every dataset across the Agent Service's workflows, with each one's **Latest verdict** and **Accuracy**.

![Experiments view with metrics, history chart and experiment list](https://developers.manykind.ai/shots/evals-experiments.png)

**CLI.** `mk eval` reads and writes the same storage as ROC, so either sees what the other wrote:

```sh
mk eval create triage
mk eval pull triage                                   # cases into ./datasets/triage/
mk eval push triage                                   # your edits back as new revisions
mk eval import triage --from cases.csv --map map.json # bulk-add cases from a table
mk eval capture triage support-4821                   # a case from a real run
mk eval check triage                                  # cases vs the version's Result
mk eval run triage                                    # run against the live version
mk eval show exp-mgfz8c1k-a1b2                         # one experiment's results
mk eval compare <base> <candidate>
mk eval baseline triage exp-mgfz8c1k-a1b2             # set the dataset's baseline
```

**Library.** [`@manykind-ai/eval`](https://developers.manykind.ai/reference/eval/) is the browser-safe library both ROC and the CLI use. Use it to build your own tooling over the same storage.

## Storage

Datasets and experiments are JSON objects in the **vault scope the workflow runs in** (its live version's scope, otherwise its newest version's), under an `evals/workflows/<workflowId>/` prefix. Access is the scope's own grant: write on the scope to create or edit datasets and run experiments, read to see them. Case revisions and dataset versions are write-once, so an old experiment always reloads exactly the cases it ran. See [Datasets](https://developers.manykind.ai/agents/workflows/evaluate/datasets/#storage).

A workflow with no published version has no scope yet: creating evaluations for it asks you to publish it once first.

## Related

- [Next: Datasets](https://developers.manykind.ai/agents/workflows/evaluate/datasets/)
- [Experiments](https://developers.manykind.ai/agents/workflows/evaluate/experiments/)
- [Results](https://developers.manykind.ai/agents/workflows/evaluate/results/)
- [Test a workflow](https://developers.manykind.ai/agents/workflows/test/)
- [`@manykind-ai/eval` reference](https://developers.manykind.ai/reference/eval/)
