# Overview

## At a glance

MorganaBench lets you evaluate your AI agent, and compare agents or successive versions of one
agent, on a benchmark built for that agent. The benchmark is custom in two senses: it is grounded
in the agent's own resources, and it covers the scenarios *you* decide are worth testing. The
agent is then scored on that benchmark with the metrics you choose.

```mermaid
flowchart LR
    C[Corpus]
    S[Specification]
    E[Example seeds]
    M[Metrics]
    C --> B[Benchmark]
    S --> B
    E --> B
    B --> R[Your agent runs the benchmark]
    R --> V[Evaluation]
    M --> V
```

## Corpora: the agent's resources

A corpus is the set of resources your agent has access to.

Resources come in two kinds. **Documents** are the agent's knowledge base — the material it
draws on to answer. **Tool definitions** describe the actions it can take to perform tasks.

Providing your agent's corpora to MorganaBench is essential to generating a benchmark that is
truly custom to your agent. Together with your guidance and your own metrics, it is what
separates an evaluation that measures agents in general from one that measures *your* agent's
knowledge and capabilities.

See [Corpora](ui-guide/corpora.md) for the accepted formats and the processing lifecycle.

## Specifications: controlling the mix

A benchmark specification configures the characteristics and variations of the synthetic
test cases that are generated and constitute the benchmark. Where the corpus supplies the
material, the specification shapes the cases built from it.

It has two parts. The **scenario description** states properties that hold for *every*
case — a description of the agent, who it serves, what it is for. **Categories** work at
the other end: each one is a single axis along which the cases should *vary*. Its labels
name the alternatives along that axis, and their weights set the proportions in which the
benchmark covers them.

Categories can express variation of any kind. Some axes are stylistic: how a request is phrased,
how verbose it is, what kind of response it expects, whether the user's grammar is correct.
Others characterize different types of users — a category whose labels are English speakers and
Spanish speakers produces a benchmark covering both. An axis can also be **topic**: a category
whose labels are topic areas steers part of the benchmark toward those topics within your corpus,
giving you deliberate coverage of the areas you care about instead of whatever the corpus happens
to be dense in.

See [Specifications](reference/specifications.md) for references and guidelines.

## Starting from examples instead

When your agent already serves real traffic, that traffic is the most faithful description of
what it has to handle. The *more like this* path is for building a benchmark that reflects it:
instead of describing the test cases you want, you show examples of the ones you already see.

You provide a scenario description and example requests, and MorganaBench extends them into a full
benchmark grounded in your corpus. The variation is carried by the examples themselves, so this
path takes the place of defining categories rather than adding to it.

Real traffic is not a prerequisite. If you have only a few examples in mind — a cold start —
MorganaBench can help you build the seed itself, so also a few examples can be used instead of
writing a specification. Working from your scenario description and whatever you have so far, it
proposes candidate requests drawn from your corpus. You approve the ones that belong in the seed,
decline the ones that don't, and ask for more. Each round takes your decisions into account, so
the proposals move toward the kind of conversation you are after; you keep going until the seed
represents what you want tested, and generate the benchmark from it.

## Benchmark: test cases and ground truth

A benchmark is a set of test cases. Each case is a synthetic conversation paired with its ground
truth — the behaviour that counts as correct.

Each benchmark is generated from a corpus — either documents or tool definitions — together with
either a specification or a seed of examples.

Ground truth takes two forms, because "correct" means different things in the two modes. When the
request is a knowledge-based question, it is an **expected response**: the content a good reply
should convey. When the request requires the agent to use tools, it is a set of **expectations**
about behaviour — this tool should have been called, with these arguments; that one should not.

See [Benchmarks](ui-guide/benchmarks.md) for modes, inputs, and the output format.

## Metrics: what counts as good behaviour

A metric is one question about the agent's behaviour, asked of every test case in the benchmark
and answered with a score.

**System metrics** come with MorganaBench and ask questions that apply to almost any agent: how
closely an answer aligns with the ground truth, or whether it contradicts it; whether it stays
faithful to the material the agent retrieved rather than inventing content; whether it is relevant
to what was asked; how often the agent refuses a request it was expected to answer. For tool-use benchmarks the questions
are about actions — were the expected tools called with the expected arguments, and did the agent
correctly refrain from calling one when no call was warranted.

But some of what "good" means is particular to your domain: a support agent that must always name
the relevant policy, a medical assistant that must never speculate. A **custom metric** is how you
state such a standard — you write the criterion in plain language, and each response is judged
against it. Metrics are named and reusable, so the same standard can be applied to every evaluation
you run.

See [Metrics](reference/metrics.md) for the available system metrics and how to author your own custom metrics.

## Evaluation

An evaluation is a scored run of a benchmark against one agent. You run your own agent on the
benchmark cases and bring its results back to MorganaBench in the expected format, along
with your choice of which metrics to compute. MorganaBench then scores them.

Each metric produces a score per test case, and those aggregate into one benchmark-level number.
The aggregate is the headline, the one worth comparing between agent versions, prompts, or model
choices. The per-case scores are where you find out *why* that number is what it is: which
cases the agent failed, and what those failures have in common.

See [Evaluation](reference/evaluation.md) for the file formats and how results are reported.