> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eigenpal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Evaluate a workflow

> Define evaluators, run an experiment over a dataset, and compare versions.

Once you have a [dataset](https://docs.eigenpal.com/guides/build-a-dataset.md), you can score a workflow
across every example and compare versions. This is how you tell whether a change
made the workflow better or worse.

## 1. Define evaluators

Evaluators score actual output against each example's expected output. Put them
in `evaluators.yaml`:

```yaml theme={null}
passThreshold: 0.85
evaluators:
  - type: exact-diff
    name: fields-match
    config:
      rules:
        invoiceNumber: {}
        total:
          numericTolerance: 0.01
        lineItems:
          order: unordered
          items: exactly
          matchBy: sku
        lineItems[]:
          allowExtraFields: false
        lineItems[].unitPrice:
          numericTolerance: 0.01
        lineItems[].evidence:
          ignore: true
  - type: llm-judge
    name: summary-quality
    config:
      promptExtension: |
        Score how well the summary captures the invoice totals and vendor.
```

* `exact-diff` for output that should match exactly.
* `llm-judge` for fuzzy correctness using explicit evaluation criteria.
* `custom-script` for correctness you can compute in typed TypeScript.

`passThreshold` is workflow-level: the weighted mean across evaluators must
reach it for the run to pass.

### Per-field exact-diff rules

Under `config.rules`, each key is a path into the workflow output. `$` targets
the full output; `{}` selects a path with inherited platform defaults. An
ancestor rule covers its subtree, and more specific descendants override
inherited settings.

* `order: unordered` on an array path compares items by value, not position.
  Matches always use distinct item slots; `items` independently controls whether
  missing expected or additional actual items are allowed.
* `matchBy` on an unordered array of objects pairs items by exact identity
  (`sku` or `[country, sku]`) before comparing the paired objects. It requires
  `order: unordered` on the same rule and is not inherited by nested arrays. A
  matching identity with a wrong field reports that field path. Identity type
  and value must both match: numeric `10` differs from string `'10'`; there is
  no coercion or numeric tolerance. Omit it to keep structural matching,
  including legitimate duplicate objects. With `items: at-least`, extra actual
  items may omit or duplicate identities; with `at-most`, missing expected
  identities are allowed but every actual item being checked needs a unique
  valid identity; `exactly` validates both sides.
* `items: at-least` requires every expected item and allows additional actual
  items. `items: at-most` allows missing expected items but rejects unexpected
  actual items. `items: exactly` permits neither. The default is `at-least`.
* `order` is independent. Ordered arrays use positional prefix matching:
  `at-least` requires expected to match actual from index 0 (only trailing
  actual extras allowed); `at-most` requires actual to match expected from
  index 0 (only trailing expected extras allowed); `exactly` is equal-length
  positional comparison. `unordered` ignores positions. Set `order`, `items`,
  and `matchBy` on the array path (`lineItems`), not the item path
  (`lineItems[]`).
* `allowExtraFields: false` on an object path (often `someArray[]`) rejects extra
  object keys in actual output.
* `numericTolerance` sets an absolute tolerance for numeric fields at that path.
  When omitted, comparison keeps the historical relative epsilon.
* `ignore: true` removes that path and its descendants from both expected and
  actual output. Use it under a selected parent to discard volatile evidence,
  citations, timestamps, or other fields captured in golden output. It cannot
  be combined with other settings on the same rule. If every rule is ignored,
  exact-diff compares the full output minus those paths.

Use `lineItems` for the array, `lineItems[]` for each element, and
`lineItems[].unitPrice` for a field inside every element. Extract steps may add
`_grounding` metadata; exact-diff strips it automatically before comparison.

Configs authored before per-field rules continue to run unchanged. Do not mix
legacy top-level options with `rules` in the same evaluator.

Validate and push:

```bash theme={null}
eigenpal workflow evaluators validate
eigenpal workflow evaluators push <workflow-id> --file ./evaluators.yaml
```

## 2. Run an experiment

An experiment runs the workflow across the whole dataset and collects every
score in one batch:

```bash theme={null}
eigenpal workflow experiment run <workflow-id> --wait
eigenpal workflow experiment results <workflow-id> <experiment-id> \
  --format json --out ./results.json
```

`--wait` blocks until the experiment finishes and exits non-zero if any example
failed, so it works in CI. Some CLI help still calls the experiment id a
`batchId`; it is the same identifier.

## 3. Compare versions

Change the workflow, push a new version, run a second experiment, then diff the
two experiments:

```bash theme={null}
eigenpal workflow experiment compare <old-experiment-id> <new-experiment-id>
```

The comparison shows which examples improved, regressed, or stayed the same.

## Tips

* `llm-judge` scores have variance. Average across runs or raise `passThreshold`
  deliberately rather than chasing single-run noise.
* Keep expected outputs in the dataset so `exact-diff` and `llm-judge` have
  ground truth to compare against.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.