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

# Skill evals and session evals

> How to test an agent like software: many skill evals as unit tests at the bottom of the pyramid, a few session evals as integration tests at the top. Covers fixtures (sample input files with expected outputs), deterministic check scripts that catch drifted values, pulling realistic cases from connected tools, and benchmarking models. Read before changing a skill, comparing models, or when a scorecard drop needs a cause.

## Outcome

Every skill carries a suite of small, fast tests that run before any change ships, and the agent has a handful of end-to-end cases that prove the whole job works. A wrong value is caught by a script, not by a reviewer squinting at a report. When a run fails, you know which level to fix it at.

## The testing pyramid

Software teams keep most of their tests at the bottom of a pyramid: many unit tests that each check one piece, and few end-to-end tests at the top that check everything together. An end-to-end test is slow and a lot can go wrong in the middle, so when it fails it rarely says where. Agents work the same way.

| | Skill eval: the unit test | Session eval: the integration test |
| - | - | - |
| Question | Given this input, does this skill produce this output? | Did the agent do the whole job on this run? |
| Unit | One skill, one prompt, in a fresh subagent | One whole session: instructions, skills, tools, model |
| How many | Many: 20 or more per skill, positive and negative | Few: three to five seeded cases per evaluation category |
| Lives in | The skill's `evals/` folder, published with the skill | The agent's evaluation categories |
| Checks | Expectations per case; exact outputs checked by a script | The category's success criteria, pass or fail with a reason |
| Runs | On demand, in the skill's editor session, in minutes | Automatically on every finished run |
| Read in | The editor's **Evals** drawer | The agent's grades and the scorecard |
| Catches | A wrong step, a drifted value, a bad format, a description that never triggers | Missing tools, the wrong skill chosen, instruction conflicts, real-world drift |

Neither replaces the other. A skill can pass every case while the agent fails because the template lacks the Stripe provider. An agent can pass most runs while one skill quietly gets a value wrong on cases you have not seen yet. But most of your testing effort belongs at the bottom: testing a skill end to end means booting sessions, generating data and waiting on runs, while a skill eval reuses one editor session and answers in minutes.

## Which one to run

* **You are writing or editing a skill.** Skill evals. Run them before and after the change and publish only if they hold. Watching the scorecard instead takes days of traffic and mixes your change with everything else.
* **You want to know if a cheaper model can do it.** Skill evals, once per model. See [Benchmark models](#benchmark-models).
* **You changed the skill's description.** Trigger evals: prompts that should load the skill and prompts that should not. See [Trigger evals](#trigger-evals).
* **You changed tools, instructions or the template.** Session evals. Re-run the seeded cases from [Prove it works and iterate](https://docs.runtm.com/build/launch-and-iterate.md) and read the grades.
* **The scorecard dropped.** Start at the top: read the failing runs. Then fix at the level the failure points to.
* **A step is now a script.** Test it like code: give its skill eval a fixture and an exact expected output. See [Code or prompt](https://docs.runtm.com/build/how-it-works/code-or-prompt.md).

## Fixtures and expected outcomes

A grader can tell that a report was created. It cannot reliably tell that the third row's amount is off by a cent. For that, write the case the way you would write a unit test: a fixed input, the exact output you expect, and a check that compares them.

```text theme={null}
evals/
  evals.json                     the cases
  files/
    two-new-rows/sheet.xlsx      input fixtures, one folder per case
    missing-column/sheet.xlsx
  expected/
    two-new-rows/rows.json       the exact output each case must produce
  checks/
    same_json.py                 deterministic comparison, exits 0 or 1
```

Then make the check an expectation. The grader runs it and reports its output, so the verdict comes from a script, not from judgment:

```json theme={null}
{
  "skill_name": "sheet-updates",
  "evals": [
    {
      "id": 1,
      "prompt": "Add the two pending refunds in refunds.txt to the ledger sheet.",
      "expected_output": "Two rows appended to the Ledger table, nothing else changed",
      "files": ["evals/files/two-new-rows/sheet.xlsx", "evals/files/two-new-rows/refunds.txt"],
      "expectations": [
        "python3 evals/checks/same_json.py evals/expected/two-new-rows/rows.json out/rows.json prints MATCH",
        "No existing row in the sheet changed",
        "The agent ran scripts/append_rows.py rather than writing cells itself"
      ]
    },
    {
      "id": 2,
      "prompt": "Add the pending refunds to the ledger sheet.",
      "expected_output": "Stops and names the missing amount column; nothing written",
      "files": ["evals/files/missing-column/sheet.xlsx"],
      "expectations": [
        "The reply names the missing amount column",
        "out/rows.json does not exist"
      ]
    }
  ]
}
```

A comparison script that names the first difference keeps a failure readable:

```python theme={null}
"""Exit 0 when two JSON files hold the same data, else print the first difference."""

import json
import sys


def first_diff(expected, actual, path="$"):
    if type(expected) is not type(actual):
        return f"{path}: expected {type(expected).__name__}, got {type(actual).__name__}"
    if isinstance(expected, dict):
        for key in sorted(set(expected) | set(actual)):
            if key not in actual or key not in expected:
                return f"{path}.{key}: {'missing' if key not in actual else 'unexpected'}"
            if d := first_diff(expected[key], actual[key], f"{path}.{key}"):
                return d
    elif isinstance(expected, list):
        if len(expected) != len(actual):
            return f"{path}: expected {len(expected)} items, got {len(actual)}"
        for i, (e, a) in enumerate(zip(expected, actual)):
            if d := first_diff(e, a, f"{path}[{i}]"):
                return d
    elif expected != actual:
        return f"{path}: expected {expected!r}, got {actual!r}"
    return None


expected, actual = (json.load(open(p)) for p in sys.argv[1:3])
if diff := first_diff(expected, actual):
    sys.exit(f"MISMATCH {diff}")
print("MATCH")
```

Keep fixtures small and specific, like unit tests: five rows that exercise one rule beat five thousand that exercise everything. Write one case per behavior: a tier boundary, a bad row, a missing file, a duplicate. Publishing the skill publishes `evals/` with it, and the next person who edits the skill gets the suite back.

Publish saves text files. Keep fixtures as CSV, JSON or TXT where you can. Add a binary fixture, such as an `.xlsx` file, with `runtm-api skills upload-file <skill_id> --file sheet.xlsx --path evals/files/two-new-rows/sheet.xlsx --mode binary`, and add it again after you publish from the editor.

## Get realistic cases

You don't have to invent the data. The editor session can load the tools the skill uses: open the session's context panel, load the providers, and ask the agent to fetch real examples and save them as fixtures.

> Find the opportunity at this Salesforce URL, save its fields to evals/files/won-deal/opportunity.json, and add a case that expects the skill to classify it as a good opportunity. Then find one we lost and add it as a negative case.

Pull examples whose outcome you already know: a case a person decided, a report someone checked. Add the negatives deliberately, and the hard cases: once the suite passes, ask the agent to write harder variants and keep the ones that fail.

## Benchmark models

The suite doubles as a model benchmark, without new agents or new sessions:

1. Run the suite on the model you use today. That is the baseline.
2. Switch the model in the session's prompt bar and run it again. The session keeps its sandbox, files and history.
3. Ask the agent to compare the runs ("summarize pass rates per model and which cases failed where"). The drawer shows the latest run; the session's history has every run.
4. Where the cheaper model fails, change the skill, often a few lines, and run both models again until they agree.

## Run a skill's evals

**1. Open the skill's editor**

In **Settings > Context > Skills**, open the skill and click **Edit**, or start a new one with **New skill > Create with AI**. Both open a session with the skill's files, its eval suite and the `skill-creator` skill loaded.

**2. Write the suite**

Open **Evals** in the session's toolbar and add cases, pull one from the session's prompt history, or ask the agent to draft them, fixtures and expected outputs included. Each case is a realistic prompt plus two to five expectations a grader can check, at least one of them a script when the output is data.

**3. Run it**

Click **Run evals**. The agent runs each prompt in a fresh subagent with the current skill loaded, runs the checks, grades every expectation with evidence, and writes the results the drawer shows. Fix the skill and run again until the suite passes.

**4. Publish**

Click **Update skill** (or **Publish skill**). The suite, fixtures and checks are published with the skill and seeded back the next time anyone edits it.

## How the levels fit together

Session evals find problems; skill evals pin them down and keep them fixed, the way a bug report becomes a regression test.

1. A graded run fails. Read the grade's reason and the transcript.
2. If a skill did a step wrong, turn the run's input into a fixture, write the output it should have produced, add the case, fix the skill and run the suite. The case now guards every future edit.
3. If the skill never loaded, add the prompt as a should-trigger query and tighten the description.
4. If a tool or credential was missing, or two instructions disagreed, it is not a skill problem. Fix the template or the instructions and re-run the seeded case.
5. Publish, then confirm the agent's pass rate holds over the next graded runs.

## Trigger evals

To measure how reliably the description loads the skill, ask the editor agent to run trigger evals: a list of should-trigger and should-not-trigger queries, each run on the session's own agent. It reports a trigger rate per query and can suggest a better description. Use this when the skill is not being picked up, not on every edit.

## Gotchas

* **Expectations about quality cannot be graded.** "The reply is helpful" passes everything. Write observable facts, and make a script check any value that has one right answer.
* **Testing only at the top.** Twenty end-to-end runs are slower and less precise than twenty skill cases, and they cost a session each. Keep the top for a few cases per category.
* **Only happy paths.** Add cases the skill should refuse or stop on: a missing file, a request outside its job.
* **A spreadsheet fixture published from the editor.** Publish saves every file as text, which breaks an `.xlsx`. Upload binary fixtures with `runtm-api skills upload-file --mode binary`, or keep them as CSV and let the case convert them.
* **Fixtures that change.** A case that reads live data passes today and fails tomorrow for reasons unrelated to the skill. Save the example as a file once and test against the file.
* **A skill eval does not run on the agent's template.** It runs in the editor session, which has only the tools you load into it. Load the providers the skill requires before running cases that call a vendor, or the cases fail for a reason the agent would not hit.
* **Grading one skill by the scorecard.** The agent's pass rate moves with every skill, tool and instruction it has. Use it to confirm a change in production, not to judge one.
* **The suite stops growing.** Every failure you fix in a skill should leave a case behind.

> [card] [2. Measure success](https://docs.runtm.com/build/measure-success.md)
>
> Evaluation categories, grading and the scorecard.

> [card] [Deterministic fraud monitoring](https://docs.runtm.com/guides/payments/fraud-monitoring-spreadsheets.md)
>
> A worked example: fixture days, expected rows and a check script.


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