# Benchmark

`mb benchmark` (alias: `mb bm`) generates and manages benchmarks — datasets of test cases for testing an agent, built from a corpus and guidance. Guidance comes in two forms: a category-driven specification (`--spec` / `--spec-id`) or a seed of example requests (`--seed-examples`, see [More like this](#more-like-this-mlt) below).

```bash
# Generate a benchmark from an inline specification YAML.
# Exactly one source is required: --spec, --spec-id, or piped stdin.

# From a YAML file:
mb benchmark create --corpus <id> -n 10 --spec ./spec.yaml --name "My Benchmark"

# From a saved Library spec (server-side fetched, snapshotted onto the benchmark):
mb benchmark create --corpus <id> -n 10 --spec-id <library-spec-id> --name "My Benchmark"

# From stdin:
cat spec.yaml | mb benchmark create --corpus <id> -n 10 --name "My Benchmark"
mb benchmark create --corpus <id> -n 10 --spec - --name "My Benchmark" < spec.yaml

# --spec and --spec-id are mutually exclusive. With --spec set, piped stdin is
# ignored. The YAML is capped at 200,000 characters client-side to match the
# server cap. Whatever YAML is sent is snapshotted onto the benchmark row;
# later edits to the source Library spec do not affect the benchmark.

# Note for users upgrading from older CLIs: --spec previously meant "saved
# spec ID". It now means "path to a YAML file (or '-' for stdin)". Use
# --spec-id <id> for the old behaviour. Scripts that pass an ID to --spec
# will fail with "spec file <id> does not exist".

# Manage benchmarks
mb benchmark list [--corpus-type docs|tools]
mb benchmark get <id>
mb benchmark update <id> --name "Updated"
mb benchmark delete <id> [--force] [--uncharge]

# Download benchmark data
mb benchmark download <id> -o benchmark.jsonl [--limit 100] [--offset 0]

# Stop an in-progress generation, keeping partial results (only while GENERATING)
mb benchmark stop <id>

# Wait for benchmark generation
mb benchmark wait <id> --timeout 1800
```

`mb benchmark create` polls until generation reaches `ready` or `failed`
unless `--no-wait` is set — see [Polling and Waiting](index.md#polling-and-waiting).
See [List Filtering](index.md#list-filtering) for the flags shared by every
`list` command.

## More like this (MLT)

Rather than a fully category-driven specification, you can seed generation with a
handful of illustrative example requests and let MorganaBench generate broadly
around them ("More like this"). Pass `--seed-examples` alongside a **scenario-only**
specification (one with no `categories` key — the two are mutually exclusive on the
same benchmark):

`--seed-examples` takes NDJSON — one [SDK `Example`](https://sdk.morganalabs.ai/) object per
line, the same format as benchmark JSONL and `eval create --file`. Only the last message of
each line is used, and it must have role `"user"`:

```bash
cat <<'EOF' > seed-examples.ndjson
{"inputs": {"messages": [{"role": "user", "content": "What approach should be taken toward setting priorities after a major national conflict?"}]}}
{"inputs": {"messages": [{"role": "user", "content": "How should tariffs be balanced against the interests of domestic producers?"}]}}
EOF

mb benchmark create --corpus <id> -n 20 \
    --spec ./scenario-only-spec.yaml \
    --seed-examples seed-examples.ndjson \
    --name "MLT Benchmark"

# --seed-examples also accepts stdin, so you can slice an existing benchmark
# JSONL straight into it:
head -n 5 benchmark.jsonl | mb benchmark create --corpus <id> -n 20 \
    --spec ./scenario-only-spec.yaml --seed-examples - --name "MLT Benchmark"
```

Up to 1000 seed examples are accepted. The web UI additionally offers an
interactive "discover new examples" step that proposes corpus-grounded
candidates for you to accept or reject one at a time — there is no CLI
equivalent for that exploratory step (see [What the CLI doesn't cover](index.md#what-the-cli-doesnt-cover));
script your own examples directly instead. See
[More like this (web UI walkthrough)](../use-cases/search-bmark-doc-examples.md)
for the concept and the full accept/reject workflow.

## Next steps

- Run your agent against the downloaded benchmark, then score it with [Evaluation](evaluation.md).
- Prefer a UI-driven workflow instead? See the [UI Guide: Benchmarks](../ui-guide/benchmarks.md).