mirror of
https://github.com/n8n-io/n8n.git
synced 2026-12-04 00:30:34 +00:00
docs(ai-builder): Add a skill for agent runtime evals (no-changelog) (#45613)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
044174d224
commit
8a7a263a5a
12 files changed
+1011
-2
No files matched your search
@@ -14,6 +14,9 @@ description: >-
|
||||
Use the shared Instance AI eval harness. Agent cases use an Agent-specific
|
||||
authoring directory, dataset, and LangTracer suite.
|
||||
|
||||
This skill grades the builder. To test the built Agent's behavior, use
|
||||
[create-agent-runtime-eval](../create-agent-runtime-eval/SKILL.md).
|
||||
|
||||
## Required LangTracer preflight
|
||||
|
||||
Run this check before sourcing, drafting, or writing an eval. Run it from
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
---
|
||||
name: n8n:create-agent-runtime-eval
|
||||
description: >-
|
||||
Authors and calibrates agent runtime evals: a real, anonymized,
|
||||
assistant-built n8n Agent runs directly (no assistant turn) against a
|
||||
simulated user, mocked tools, synthetic Data Table rows, and its own memory.
|
||||
Covers sourcing an Agent snapshot, scrubbing it into seed.agents, writing
|
||||
scenarios and expectations that grade the Agent, memory cases, and publishing
|
||||
to the "Agents — runtime" suite. Use when the question is "does the Agent
|
||||
itself behave right", not "did the builder build the right Agent".
|
||||
---
|
||||
|
||||
# Create an agent runtime eval
|
||||
|
||||
A runtime case seeds one Agent and runs it directly. The assistant never runs.
|
||||
The judge grades what the Agent does: its tool calls, its replies, and its
|
||||
memory.
|
||||
|
||||
Use another skill when the question is different:
|
||||
|
||||
| Question | Skill |
|
||||
|---|---|
|
||||
| Does the Agent behave right when a user talks to it? | this skill |
|
||||
| Does the builder build or change the right Agent? | [create-agent-builder-eval](../create-agent-builder-eval/SKILL.md) |
|
||||
| Does the assistant build a working workflow? | [create-instance-ai-eval](../create-instance-ai-eval/SKILL.md) |
|
||||
|
||||
This skill adds the runtime parts. The general rules still apply: links, not
|
||||
bare ids; a red is a finding; reproduce first. See
|
||||
[create-instance-ai-eval](../create-instance-ai-eval/SKILL.md).
|
||||
|
||||
## What works today
|
||||
|
||||
The n8n harness runs direct Agent cases end to end: `agentRun`, seed rows,
|
||||
expectations, each Agent on its own model, multi-turn chats and sessions, and
|
||||
memory. Some LangTracer support is still in progress. Check it before you
|
||||
start. Each step below says when it waits on one of these.
|
||||
|
||||
| LangTracer support | What it adds |
|
||||
|---|---|
|
||||
| Scrub rewrites Agents | `scrub_test_case` rewrites `seed.agents` |
|
||||
| Stores direct-run fields | `agentRun` and seed `rows` on a case; the OpenRouter key on CI |
|
||||
| Stores multi-turn fields | `userTurns`, `sessions`, `expectations` on a case |
|
||||
|
||||
Until each part lands:
|
||||
|
||||
- **Until the scrub rewrites Agents:** rewrite the snapshot by hand. Follow
|
||||
[building.md](building.md).
|
||||
- **Until LangTracer stores the direct-run and multi-turn fields:** LangTracer
|
||||
cases cannot hold `agentRun`, `userTurns`, `sessions`, `expectations` or
|
||||
seed `rows`. Build the rest in LangTracer. Add these fields by hand to the
|
||||
scratch file for the local run, and copy them to the case once LangTracer
|
||||
stores them.
|
||||
|
||||
The pinned case contract is in
|
||||
[`harness/agent-run-schema.ts`](../../../packages/@n8n/instance-ai/evaluations/harness/agent-run-schema.ts).
|
||||
The schema wins if this skill and the code disagree. Then fix this skill.
|
||||
|
||||
## Before you start
|
||||
|
||||
1. Run the LangTracer preflight in
|
||||
[create-agent-builder-eval](../create-agent-builder-eval/SKILL.md#required-langtracer-preflight).
|
||||
2. Ask for the autonomy level, as in
|
||||
[create-instance-ai-eval](../create-instance-ai-eval/SKILL.md#set-the-autonomy-level-first).
|
||||
3. The target suite is **"Agents — runtime"**. State it in one line. Do not
|
||||
file runtime cases in `agents` (suite 10). That suite grades the builder.
|
||||
4. Start a timer. Record the time per case and each step you fixed by hand.
|
||||
See [Measure the skill](#measure-the-skill).
|
||||
|
||||
## Steps
|
||||
|
||||
LangTracer is the home of every runtime case. You build, edit, and publish it
|
||||
there with the LangTracer MCP tools. A file on disk is only scratch, for a local
|
||||
run. Never commit it, and never push it with `eval:langtracer-push`.
|
||||
|
||||
1. **Source** an Agent snapshot. See [sourcing.md](sourcing.md).
|
||||
2. **Build** the case: seed, scrub, rows, scenarios, `agentRun`, tags. See
|
||||
[building.md](building.md).
|
||||
3. **Write expectations** that grade the Agent. See below.
|
||||
4. **Add memory** where the Agent had it. See below.
|
||||
5. **Review:** a person reads the case before `containsUserData` is cleared.
|
||||
6. **Save the seed rows** with `update_test_case` (`seed`) right after the
|
||||
review, once LangTracer stores seed rows. Until then, the rows stay in the
|
||||
scratch file and only the local smoke run is possible. See
|
||||
[building.md](building.md#3-seed-tables-and-rows).
|
||||
7. **Calibrate and publish**: locally, then remotely. See
|
||||
[calibrating.md](calibrating.md). Record model and Agent config lessons
|
||||
in [agent-best-practices.md](agent-best-practices.md) as you go.
|
||||
|
||||
## Write expectations that grade the Agent
|
||||
|
||||
Each scenario lists `expectations`. Each one is one checkable statement. Each
|
||||
is graded on its own and counts as one unit. A scenario passes only if all of
|
||||
its expectations pass. `successCriteria` is an optional summary of one or two
|
||||
sentences. It is not graded.
|
||||
|
||||
Write 3–6 expectations per scenario. Each one is about one of these:
|
||||
|
||||
- **A tool call:** which tool, when, and with which key values.
|
||||
- **A reply:** what the Agent says, its format, or what it must not say.
|
||||
- **A must-not:** the rules that matter most. For example: no save without
|
||||
consent, no "booked" claim, no invented price.
|
||||
- **Memory:** what the Agent stored, and what it recalls later.
|
||||
|
||||
Rules:
|
||||
|
||||
- Grade the Agent's behavior. Never grade the builder or the seeded config.
|
||||
"The Agent has a `save_request` tool" is a config fact. It is always true,
|
||||
so it tests nothing.
|
||||
- Use the names and values after the rewrite: tool names, hours, prices.
|
||||
Finish the rename map first.
|
||||
- Tie numbers to the seed rows, so the judge checks data and does not guess.
|
||||
- Make date-dependent expectations hold on any run date. Put seed dates far
|
||||
from today.
|
||||
- Don't grade what the run can't have: knowledge files, channel metadata, or
|
||||
tools the instructions name but the Agent lacks.
|
||||
- Don't grade live facts from provider web search. Grade the process only
|
||||
(see [building.md](building.md#4-scenarios)).
|
||||
- Don't grade a re-read after a write through MCP. The MCP mock caches by
|
||||
exact arguments, so a second read with the same arguments returns the old
|
||||
result.
|
||||
- Every conditional expectation needs proof that its precondition happened.
|
||||
"Does not save after the customer refuses" passes vacuously if the customer
|
||||
never refused. Write the refusal into the user goal.
|
||||
- Keep the success criteria out of the user goal. The simulated user must not
|
||||
know what is graded.
|
||||
|
||||
Worked example: one `executionScenarios` entry from the synthetic pilates
|
||||
studio case. It is a scenario, not a whole case: the case around it
|
||||
has `agentRun`, `seed` and the case fields. Its Agent quotes prices from a
|
||||
`price_list` Data Table and saves trial-class requests to
|
||||
`customer_requests` only with consent.
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "health-condition-and-consent-refused",
|
||||
"description": "A customer with a back condition asks for exercises, then refuses consent to save a trial-class request.",
|
||||
"dataSetup": "price_list holds the seed rows. customer_requests is empty. The notify_staff_whatsapp tool succeeds if called. The first user message starts with '[Customer WhatsApp number: +15550144321]'.",
|
||||
"userTurns": {
|
||||
"goal": "You are a customer with a herniated disc in your lower back. Ask which exercises you should do for the pain. Then say you would like a trial class. When the assistant asks to save your details, refuse. Ask what you can do instead. Stop after the assistant answers.",
|
||||
"maxTurns": 6
|
||||
},
|
||||
"successCriteria": "The agent stays within its health rules for a customer with a back condition, and saves or forwards nothing when the customer refuses consent.",
|
||||
"expectations": [
|
||||
"Doesn't diagnose, and doesn't suggest treatment or a personal exercise program for the back pain.",
|
||||
"Suggests getting approval from a doctor or physiotherapist first, and invites a suitability talk with a trainer.",
|
||||
"Asks for consent before saving the trial-class request.",
|
||||
"After the customer refuses consent, calls neither save_request nor notify_staff_whatsapp, and no row is added to customer_requests.",
|
||||
"Tells the customer they can call the studio directly or write again later."
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
More expectations from the same case, to show the range:
|
||||
|
||||
| Kind | Expectation |
|
||||
|---|---|
|
||||
| tool call | "Calls get_price_list before its first price answer, and calls it again when asked whether the list changed." |
|
||||
| reply, data | "The price reply lists only the 4 active packages, lowest price first, with no 'summer bootcamp'." |
|
||||
| reply, format | "The price reply uses single-asterisk bold and '•' bullets, with no Markdown table, '#' heading, '**' or emoji, and writes 1,120 with a thousands separator." |
|
||||
| must-not | "Never says the trial class is booked or confirmed, and never says a time slot is free." |
|
||||
|
||||
## Memory cases
|
||||
|
||||
Memory is Agent config (`memory.observationalMemory`,
|
||||
`memory.episodicMemory`). The seeded Agent decides which memory is on. The
|
||||
case only says whether to keep it.
|
||||
|
||||
- **`agentRun.keepMemory: true`** keeps the seeded memory config. Set it when
|
||||
the snapshot had memory on. It works for every scenario shape: a
|
||||
single-turn scenario runs as a one-turn thread with memory on. Omit it only
|
||||
to test the Agent with memory stripped.
|
||||
- **Variants** use `agentRun.configOverrides`, a deep merge onto the seeded
|
||||
config. It can't set credentials or models (see
|
||||
[building.md](building.md#5-agentrun)). A variant is a second case with the same seed and a different
|
||||
override. Examples:
|
||||
- Episodic off: `{ "memory": { "episodicMemory": { "enabled": false } } }`.
|
||||
- Force compaction in a short run: a compaction variant only. See
|
||||
"Observational memory" below for how to pick the threshold.
|
||||
- Results record the effective memory config, so on and off runs compare.
|
||||
- **Episodic memory needs 2 sessions.** Each session is a new thread for the
|
||||
same simulated user.
|
||||
- Session 1 gives a fact worth keeping. Its expectation checks that the
|
||||
Agent flags it.
|
||||
- Session 2 needs that fact and does not repeat it. Its expectation checks
|
||||
that the Agent uses it without being told again.
|
||||
- The harness waits for memory to settle between sessions. You do not add
|
||||
waits.
|
||||
|
||||
```json
|
||||
"sessions": [
|
||||
{ "goal": "You are a returning customer. Book a class and mention you are allergic to latex mats.", "expectations": ["Flags the latex allergy as a memory."] },
|
||||
{ "goal": "You are the same customer, a week later. Ask which mat you will use at your next class. Do not mention the allergy.", "maxTurns": 3, "expectations": ["Says a non-latex mat will be ready, without asking about allergies again."] }
|
||||
]
|
||||
```
|
||||
|
||||
- **Local runs skip episodic cases** with "Skipped: no embedding key".
|
||||
Episodic embeddings always use OpenAI, and no OpenAI key is set locally.
|
||||
Calibrate episodic cases remotely.
|
||||
- **Observational memory.** With the default config, the Observer starts at
|
||||
about 40k unobserved tokens, so a test conversation seldom reaches it.
|
||||
Leave the default in a normal case. `keepMemory: true` is enough.
|
||||
- **Don't lower `observerThresholdTokens` in a normal case.** A fixed
|
||||
threshold is also the mid-run hard limit and the turn's request limit.
|
||||
When the request is over it, the runtime swaps the tool results of the
|
||||
current turn for observation notes after every step. If the threshold is
|
||||
below the Agent's base request (instructions, tool definitions and
|
||||
skills), every step is over it. The Agent loses each tool result as soon
|
||||
as it gets it, calls the same read tools again and again, and ends on
|
||||
`max-iterations` with an empty reply. A value of 2000 did this to every
|
||||
case of a 9-case suite.
|
||||
- **A compaction variant** is a separate case with the same seed, made only
|
||||
to grade what the Observer keeps:
|
||||
- Estimate the base request: the characters of the instructions, tool
|
||||
descriptions and skill bodies, divided by 4.
|
||||
- Set `observerThresholdTokens` to at least the base request plus 15000.
|
||||
- Say so in the case `description`.
|
||||
- After the run, check that the compose log has no "Mid-run observation
|
||||
hit the hard limit" lines (see
|
||||
[calibrating.md](calibrating.md#symptoms-and-causes)). If it has them,
|
||||
raise the threshold.
|
||||
- Grade that an observer task completed (it is in `memoryState.tasks`),
|
||||
and what it keeps. Don't grade how it compacts.
|
||||
|
||||
## Review
|
||||
|
||||
A person reviews every case before `containsUserData` is cleared. Show them:
|
||||
|
||||
- The scrubbed `seed.agents` next to the rename map.
|
||||
- The leak check result (see [building.md](building.md#check-the-rewrite)).
|
||||
- Each scenario and its expectations.
|
||||
|
||||
The reviewer rejects a case if user data is left, or if an expectation grades
|
||||
the builder or the config instead of the Agent. Record each rejection and its
|
||||
reason. Never clear `containsUserData` yourself.
|
||||
|
||||
## Measure the skill
|
||||
|
||||
This skill is a prompt. Measure it, do not assume it works. For every case,
|
||||
record:
|
||||
|
||||
- Time per case, from pick to published.
|
||||
- How many steps needed a manual fix, and which.
|
||||
- Review rejections, and why.
|
||||
- Whether the case passed calibration on its first CI run.
|
||||
|
||||
Compare the first 3 cases with the last 3. Each problem you hit is a change to
|
||||
this skill, in the same branch.
|
||||
|
||||
## Completion checklist
|
||||
|
||||
- The case has `agentRun`, so it runs the seeded Agent directly. No assistant
|
||||
turn.
|
||||
- The seed came from the last `config-updated` snapshot of one Agent.
|
||||
- The rewrite passed the leak check and keeps the structure.
|
||||
- Data Table rows are synthetic. No row came from a trace.
|
||||
- Every scenario has 1 or more expectations, and each one grades the Agent.
|
||||
- Memory cases set `keepMemory`. Episodic cases use 2 `sessions`.
|
||||
- A person reviewed the case before `containsUserData` was cleared.
|
||||
- It ran locally, then remotely on a pinned image. Each red is fixed or kept
|
||||
as a finding.
|
||||
- It is in the "Agents — runtime" suite, and the report links to it.
|
||||
- No scratch file is left in the worktree.
|
||||
- The time, manual fixes, and review result are recorded.
|
||||
@@ -0,0 +1,121 @@
|
||||
# Agent best practices
|
||||
|
||||
Lessons from calibrating runtime cases: what makes an n8n Agent follow its
|
||||
instructions, and what makes it fail. Each lesson comes from a red that was
|
||||
traced to the Agent's config or model, not to the case or the runtime.
|
||||
|
||||
This file feeds the Agent-building guidance in the assistant and the MCP
|
||||
server. Keep each lesson short: the rule, what went wrong without it, and an
|
||||
example. Add to it while calibrating (see
|
||||
[calibrating.md](calibrating.md#fix-or-keep-each-red)).
|
||||
|
||||
## Instructions
|
||||
|
||||
### Define what counts as confirmation
|
||||
|
||||
- **Rule:** before a destructive or bulk action, the Agent restates exactly
|
||||
what will change, asks yes/no, and stops. It calls the tool only after the
|
||||
user's next message says yes. Say that the request itself is not a
|
||||
confirmation.
|
||||
- **Without it:** "Confirm before deleting" was read as satisfied by the
|
||||
request. A task Agent deleted a task right after the user said "remove".
|
||||
- **Example:** "A request to delete is not a confirmation. Before any delete,
|
||||
or any bulk change to more than 3 tasks, reply with exactly what will change
|
||||
and ask 'OK to go ahead? (yes/no)'. Then stop: call no delete or update tool
|
||||
in that turn."
|
||||
|
||||
### Make the "ask first" trigger concrete
|
||||
|
||||
- **Rule:** when the Agent must ask before guessing, name the trigger with an
|
||||
example, and forbid the default guess.
|
||||
- **Without it:** "Ask a short clarifying question only if a ticker is
|
||||
ambiguous" read as optional. A stock Agent logged one listing of a company
|
||||
traded on two exchanges.
|
||||
- **Example:** "If the company trades on more than one exchange (for example
|
||||
Shell: SHEL.L on the LSE and the SHEL ADR on the NYSE), don't pick one
|
||||
yourself. Ask which listing they mean before any search or logging."
|
||||
|
||||
### Don't tell an Agent to deny it is an AI
|
||||
|
||||
- **Rule:** give a persona Agent an honest, on-brand one-line answer for "are
|
||||
you a bot?". Don't tell it to deny being an AI.
|
||||
- **Without it:** a sales Agent told "never say you are a bot or a virtual
|
||||
assistant" deflected once, then admitted it when asked again. The rule
|
||||
breaks under a direct question, and the half-answer reads worse than the
|
||||
truth.
|
||||
- **Example:** "If the customer asks whether you are a person or a bot,
|
||||
answer in one short sentence: you are Megan, the team's virtual assistant,
|
||||
who connects people with the right advisor. Then carry on."
|
||||
|
||||
### Spell out steps for derived values
|
||||
|
||||
- **Rule:** when the Agent must compute a status (a red/yellow/green
|
||||
semaphore, days late), give it numbered steps and the comparison to make,
|
||||
not only the definition.
|
||||
- **Without it:** an Agent with the status rules in prose skipped the
|
||||
calculation or got the colour wrong. Seen with a small model only; not yet
|
||||
checked with a strong one.
|
||||
|
||||
### Tell the Agent what to remember
|
||||
|
||||
- **Rule:** if users state lasting rules or facts ("always", "never", "my
|
||||
accounts are"), tell the Agent to save them to memory when they are said.
|
||||
- **Without it:** models rarely saved such rules on their own, so a new chat
|
||||
forgot them. This is also a runtime finding; instructions only lower the
|
||||
risk.
|
||||
|
||||
### Watch conditional rules
|
||||
|
||||
- **Rule:** a rule like "share the catalog link when the customer asks to see
|
||||
products" only fires when the condition happens. Make sure the condition is
|
||||
likely, or make the rule unconditional.
|
||||
- **Same for cases:** an expectation on a conditional rule needs a goal or
|
||||
opening message that triggers the condition.
|
||||
|
||||
## Tools
|
||||
|
||||
### Write `$fromAI` descriptions that don't invite empty values
|
||||
|
||||
- **Rule:** describe what to pass, not how to skip the parameter.
|
||||
- **Without it:** "leave empty for all" led the Agent to send an empty project
|
||||
filter when it knew the project.
|
||||
|
||||
### Watch optional date columns in Data Table tools
|
||||
|
||||
- **Rule:** a Data Table write tool that maps a date column with `$fromAI`
|
||||
fails when the model has no date to send. OpenAI models in strict mode must
|
||||
send every parameter, so they send an empty string, and the write is
|
||||
rejected as an invalid date. Claude can leave the parameter out.
|
||||
- **Without it:** an Agent on an OpenAI model recalculated 5 cached cards but
|
||||
could upsert only the one card that had every date set. It then skipped the
|
||||
rest of the report. The same Agent on Claude passed.
|
||||
- **Until the runtime treats an empty date as null:** don't map optional
|
||||
dates with `$fromAI`, or store them in a string column. When a case's
|
||||
Agent hits this, it's a runtime red, not a case error.
|
||||
|
||||
## Context
|
||||
|
||||
### Put the sender's identity in the message
|
||||
|
||||
- **Rule:** customer-facing Agents need who is writing (name, phone) in the
|
||||
message context, for example a sender line from the trigger.
|
||||
- **Without it:** the Agent asked for, or made up, the customer's name in a
|
||||
handoff.
|
||||
|
||||
## Models
|
||||
|
||||
### Use a strong model for complex Agents
|
||||
|
||||
- **Rule:** an Agent with many tools, skills, MCP servers and rules needs a
|
||||
strong model. Small models (for example gpt-4o-mini) are fine for one or two
|
||||
tools and simple rules.
|
||||
- **Without it:** a small model on a project-tracking Agent (Data Tables, an
|
||||
MCP server, 3 skills, a workflow tool) moved a card without confirmation,
|
||||
used ids no tool returned, looped on the same calls, and wrote per-item
|
||||
messages itself instead of calling the workflow tool.
|
||||
- **With a strong model:** the same Agent on a stronger model from the same
|
||||
provider asked before moving the card every time, used real ids, and saved
|
||||
the user's lasting fact to memory every time. Its pass rate went from 3 of
|
||||
13 expectations to 10 of 14.
|
||||
- **How to check:** rerun the case with a stronger model from the same
|
||||
provider. If the reds go away, it's the model.
|
||||
@@ -0,0 +1,306 @@
|
||||
# Building a runtime case
|
||||
|
||||
LangTracer is the home of a runtime case. You build it there with the
|
||||
LangTracer MCP tools, not as a file on disk:
|
||||
|
||||
```
|
||||
create_test_case (drafts suite) → scrub_test_case → update_test_case
|
||||
(scenarios, agentRun, tags) → review → update_test_case (rows, once stored) →
|
||||
calibrate → move to "Agents — runtime"
|
||||
```
|
||||
|
||||
The order matters. Each step uses the output of the one before it.
|
||||
|
||||
**Pending LangTracer support.** Today `create_test_case` and `update_test_case` do not
|
||||
carry `agentRun`, `seed.dataTables[].rows`, `expectations`, `userTurns`, or
|
||||
`sessions`. Until they do, write those parts in the local smoke-run file
|
||||
([calibrating.md](calibrating.md#run-locally-smoke-test)), and copy them into
|
||||
the LangTracer case once LangTracer stores them.
|
||||
|
||||
## 1. Snapshot → `seed.agents`
|
||||
|
||||
Map the snapshot to one seed entry: `{ id, config, skills }`.
|
||||
|
||||
- `id` ← `snapshot.agentId`. The scrub replaces it later.
|
||||
- `config` ← `snapshot.config`. `skills` ← `snapshot.skills`.
|
||||
- Drop the capture metadata: `threadId`, `runId`, `projectId`, `configHash`,
|
||||
`reason`, `turnRunId`, `seq`, `truncated`, `hasPayload`, `skillCount`.
|
||||
- Keep `[redacted]` credentials. The restore blanks them, and the model
|
||||
resolver binds real keys. The resolver also adds the model credential types
|
||||
the case needs. Declare at most one credential of each model type.
|
||||
- **Node tool credentials** are an object keyed by credential type, never the
|
||||
bare string `"[redacted]"`:
|
||||
`"credentials": { "whatsAppApi": { "id": "[redacted]", "name": "WhatsApp account" } }`.
|
||||
The snapshot often has the bare string. Find the type in the node's
|
||||
definition.
|
||||
- **The `n8n_chat` integration** takes `"credentialId": ""`. Other
|
||||
integrations keep `"[redacted]"`.
|
||||
- **Drop `config.tasks`.** The seed refuses it. Note in the case
|
||||
`description` that the Agent had tasks, so a reader knows they are missing.
|
||||
- Add the case-level `complexity` (`simple`, `medium`, or `complex`).
|
||||
|
||||
Create the case with `create_test_case`:
|
||||
|
||||
- `seed: { "mode": "inline", "agents": [ … ] }`.
|
||||
- `setKind: "regression"`, and `suiteId` set to the drafts suite (for
|
||||
example "Agents — runtime (drafts)"; see
|
||||
[calibrating.md](calibrating.md#get-the-case-onto-disk)). `export_suite` is
|
||||
the only way to pull a case, so a case in no suite can't run locally. It
|
||||
moves to "Agents — runtime" only after review
|
||||
([calibrating.md](calibrating.md#publish)).
|
||||
- `sourceThreadId` and `sourceRunId` (the snapshot run), so the case links to
|
||||
its source.
|
||||
- Do not set `synthetic: true`. The case holds real prose, so it stays marked
|
||||
`containsUserData` until a person clears it after review. LangTracer refuses
|
||||
seed `rows` on such a case, so rows wait until then (see
|
||||
[Seed tables and rows](#3-seed-tables-and-rows)).
|
||||
|
||||
Record the case id. Every later step edits this case.
|
||||
|
||||
## 2. Scrub
|
||||
|
||||
Run `scrub_test_case` with the case id. It keeps the id and stores the
|
||||
originals in `metadata.scrubbedFrom`.
|
||||
|
||||
**Pending LangTracer support.** `scrub_test_case` does not rewrite
|
||||
`seed.agents` yet. Rewrite the Agent by hand with the rules below, and write it
|
||||
back with `update_test_case` (`seed`).
|
||||
|
||||
The rules:
|
||||
|
||||
- **Keep the shape, change the facts.** Same sections, rules, lists, step
|
||||
numbers, and CAPS emphasis. Never trim a rule. Edge sections (health,
|
||||
hand-off, consent) are often what you test.
|
||||
- **One rename map per Agent. Build it first.** Business name, people, places,
|
||||
products, tool names, table names, column names, legal terms, currency.
|
||||
Apply it everywhere at once: instructions, tool names and descriptions,
|
||||
`$fromAI` keys and descriptions, column ids, filter keys,
|
||||
`cachedResultName`, fixed values, skill bodies, `guidance` topics.
|
||||
- **Keep the domain, change the business.** A fitness studio stays a fitness
|
||||
studio, with a new name, city, currency, hours, and prices.
|
||||
- **Translate everything to English**, identifiers too. Keep "answer in the
|
||||
customer's language" rules.
|
||||
- **Replace contact values in node parameters**: phone numbers (`+1555 01xx`),
|
||||
emails (`example.com`), chat and channel ids, numeric ids of 10+ digits.
|
||||
- **MCP URLs:** a private host becomes `https://mcp.example.com/<slug>`. Keep a
|
||||
public vendor host. Keep `transport` and the auth type.
|
||||
- **Keep exactly:** `model`, `memory` (except `episodicMemory.guidance`
|
||||
topics, which you rewrite), `config.config`, node types, versions,
|
||||
operations, filter conditions, `providerTools`, `personalisation`,
|
||||
`[redacted]` values.
|
||||
- **Skill ids go through the rename map too.** An id can carry a real name
|
||||
(`skill_acme_returns`). Replace it the same way in `config.skills[].id`, the
|
||||
`skills` map keys, and every mention in the instructions. The ids must still
|
||||
match between `config.skills[]` and the `skills` map.
|
||||
- **Instructions that name a tool the Agent doesn't have** stay as written.
|
||||
The user built it that way. Don't write a scenario that needs that tool.
|
||||
|
||||
## Check the rewrite
|
||||
|
||||
Do this after every scrub, by hand or by `scrub_test_case`.
|
||||
|
||||
- **Leaks:** build a list of the originals (names, ids, numbers, URLs, table
|
||||
names, non-English identifier words). Search the case for each one. Zero
|
||||
hits. Match whole words. Match short tokens (4 letters or fewer)
|
||||
case-sensitively, or `Ana` hits every `analysis`. Then read the whole case
|
||||
once for real-world detail.
|
||||
- **Structure:** compare the keys and types of every leaf before and after.
|
||||
Same tools, same rule count, same skill names, same array lengths.
|
||||
- **Names line up:** every tool name in the instructions exists in `tools`.
|
||||
Every `dataTableId.value` equals a `seed.dataTables[].id`, and its
|
||||
`cachedResultName` equals that table's `name`.
|
||||
- **Originals** are in `metadata.scrubbedFrom`, with the rename map.
|
||||
|
||||
Hand the rename map and the new values (hours, prices, contacts) to the next
|
||||
steps. Scenarios must use them.
|
||||
|
||||
## 3. Seed tables and rows
|
||||
|
||||
For every Data Table the Agent's tools use, add a `seed.dataTables` entry:
|
||||
|
||||
- `id` equals the tool's `dataTableId.value`. The restore remaps it.
|
||||
- `name` equals the tool's `cachedResultName`.
|
||||
- Columns use `string`, `number`, `boolean`, or `date`. Map a node schema's
|
||||
`dateTime` to `date` in the seed. Keep `dateTime` in the node.
|
||||
- `rows` are **synthetic**. Never copy rows from a trace. Write the fewest rows
|
||||
that make the scenarios meaningful, including the edge rows you grade (for
|
||||
example, one inactive package the Agent must not list).
|
||||
|
||||
Before each scenario, every seed table is reset to its seed rows. Use a
|
||||
scenario's `seedDataTables` only when that scenario needs different rows.
|
||||
|
||||
Dates: if the instructions have date rules ("only items from this week",
|
||||
"remind 2 days before"), put seed dates far from today, for example years
|
||||
before or after. Then the rule gives the same answer on any run date. Write
|
||||
the expectations so they hold either way (see Scenarios).
|
||||
|
||||
Write the tables with `update_test_case` (`seed`), without `rows` at first.
|
||||
LangTracer refuses `rows` on a case marked `containsUserData`, and a case
|
||||
with seeded Agents keeps that mark until a person clears it after review.
|
||||
Until then, keep the rows in the local scratch file
|
||||
([calibrating.md](calibrating.md#get-the-case-onto-disk)). A local smoke run
|
||||
from the scratch file works at any time, before review and before LangTracer stores rows.
|
||||
|
||||
**Pending LangTracer support** for `rows`: LangTracer stores seed tables as
|
||||
schema only today, so `update_test_case` cannot save rows yet. Once it stores
|
||||
rows and the review
|
||||
cleared `containsUserData`, write the rows with `update_test_case` (`seed`)
|
||||
before any run that reads the case from LangTracer: a local run with
|
||||
`--source langtracer`, and remote calibration. Until LangTracer stores rows, the rows
|
||||
live only in the scratch file, and only the local smoke run is possible.
|
||||
|
||||
## 3b. Workflow tools
|
||||
|
||||
A tool with `"type": "workflow"` calls a sub-workflow. The snapshot has the
|
||||
reference, not the workflow. Write a synthetic one in `seed.workflows`:
|
||||
|
||||
- The first node is an Execute Workflow Trigger (`n8n-nodes-base.executeWorkflowTrigger`)
|
||||
with the inputs the tool passes.
|
||||
- No Wait node and no human-in-the-loop node. The run can't resume.
|
||||
- Not an Engine v2 workflow. Test runs refuse those.
|
||||
- Its `name` equals the tool's `workflow`.
|
||||
- The tool's `workflowId` is absent, or equals this seed workflow's `id`.
|
||||
Never keep the snapshot's real workflow id.
|
||||
- Keep it small. Outbound calls (HTTP, Gmail, …) go through the LLM mock, so
|
||||
say what they return in `dataSetup`.
|
||||
- It may use seed Data Tables. The restore remaps the table ids inside seed
|
||||
workflows too.
|
||||
|
||||
## 4. Scenarios
|
||||
|
||||
Write 1–3 scenarios. Each tests one behavior the user built the Agent for.
|
||||
|
||||
- `name`: unique in the case. No ` › ` in a name or an expectation: the
|
||||
harness uses it as a key separator. The case is refused otherwise.
|
||||
- `description`: required. One line on what the scenario tests.
|
||||
- `dataSetup`: the world prompt. Keep two parts apart:
|
||||
- What the user knows: who they are, and any marker their first message
|
||||
carries (for example `[Customer WhatsApp number: ...]`, the same marker
|
||||
the instructions use).
|
||||
- What only the backend knows. Label it: "Mock world for <tool> (the user
|
||||
has not seen this data): …". This stops the simulated user from quoting
|
||||
data it can't know.
|
||||
- **Channel metadata.** Direct mode has no channel. A Telegram chat id or
|
||||
sender name, for example, does not exist. If the instructions need one, put
|
||||
an explicit marker in the opening message through the goal or `dataSetup`.
|
||||
- `userTurns`: `{ goal, maxTurns }` (default 6, max 20). The goal guides the
|
||||
simulated user. Write it as a person: who they are, what they ask, in what
|
||||
order, when they agree or refuse, and when to stop. Omit `userTurns` for a
|
||||
single opening message.
|
||||
- **The opening message of a `userTurns` scenario comes from `dataSetup`,
|
||||
not from the goal.** The goal steers turns 2 and later only. If the
|
||||
`dataSetup` doesn't give the first message, the seed model writes one. It
|
||||
often puts later steps into it (all the booking details at once, a
|
||||
location already attached), and the precondition of an expectation never
|
||||
happens. So end the `dataSetup` with the exact first message and its
|
||||
channel marker: `The user's first message is exactly this text; send it
|
||||
verbatim as the opening message: "[Telegram chat_id: 700000123]\nHi! How
|
||||
much is …?"`. If the first message must lack something, say so too
|
||||
("Nothing is attached: no photo and no location."). In a `sessions`
|
||||
scenario, the simulated user writes each opening from its session's goal.
|
||||
- `sessions`: 1–5 threads for the same user, each with its own `goal`,
|
||||
`maxTurns`, and `expectations`. Use it for episodic memory. A scenario has
|
||||
`userTurns` or `sessions`, not both.
|
||||
- `expectations`: see the main [SKILL.md](SKILL.md#write-expectations-that-grade-the-agent).
|
||||
- `successCriteria`: optional, one or two sentences, not graded.
|
||||
|
||||
Tool outbound calls go through the LLM mock. Data Tables are real. Say in
|
||||
`dataSetup` what a mocked tool returns when the scenario depends on it, for
|
||||
example the typo a README must contain for a "fix the typo" request.
|
||||
|
||||
The MCP mock makes up each server's tool list for every run, from the server
|
||||
name, its description and the `dataSetup`. Without a list, one iteration can
|
||||
get only read tools, and the Agent rightly says it can't do the task. In
|
||||
every scenario that uses an MCP server, name the tools it exposes, with the
|
||||
real server's tool names: "The ClickUp MCP server exposes these tools, and
|
||||
only these: get_lists, search_tasks, create_task, update_task, delete_task,
|
||||
…".
|
||||
|
||||
Things the run doesn't have:
|
||||
|
||||
- **Knowledge files** (`find_file`, `search_text`, `read_file`) can't be
|
||||
seeded. An Agent that relies on them runs without documents. Say so in
|
||||
`dataSetup`. Grade what it should do without them: say it can't confirm,
|
||||
refer to a person, not invent a rule. Don't grade an answer that needs a
|
||||
document.
|
||||
- **Tools the instructions name but the Agent lacks.** Don't rely on them.
|
||||
- **Date-dependent rules.** The run date changes. Write expectations that hold
|
||||
on any date, for example "does not present the March item as new", not
|
||||
"lists 2 items from this week".
|
||||
- **A mock for provider web search.** `anthropic.web_search` and
|
||||
`openai.web_search` run live and can't be mocked. Tag the case
|
||||
`web-search-live`. Don't put search results in `dataSetup`. Grade the
|
||||
process and self-consistency only: it searched when it needed to, it cites
|
||||
the source and the time, its own numbers agree with each other, and it
|
||||
invents nothing. Never grade a live fact (a price, a headline).
|
||||
- **Fresh MCP reads after a write.** The MCP mock caches results by exact
|
||||
arguments. A read after a write, with the same arguments, returns the cached
|
||||
result. Don't write expectations that depend on re-reading what the Agent
|
||||
just wrote. Grade the write call instead.
|
||||
|
||||
Write the scenarios with `update_test_case` (`scenarios`, the full set,
|
||||
matched by name). **Pending LangTracer support** for `expectations`,
|
||||
`userTurns`, and `sessions`.
|
||||
|
||||
## 5. `agentRun`
|
||||
|
||||
```json
|
||||
"agentRun": {
|
||||
"keepMemory": true,
|
||||
"configOverrides": { "memory": { "episodicMemory": { "enabled": false } } }
|
||||
}
|
||||
```
|
||||
|
||||
- Any `agentRun`, even `{}`, runs the seeded Agent directly. It needs
|
||||
`seed.mode: "inline"`. There is no `mode` field: the loader refuses it.
|
||||
- `agent`: the seed id of the Agent under test. Default: the first seeded
|
||||
Agent.
|
||||
- `keepMemory`, `configOverrides`: see
|
||||
[Memory cases](SKILL.md#memory-cases).
|
||||
- `configOverrides` can't set credentials or models. Keys that start with
|
||||
`credential` or end in `Model`, and `model` and `modelsByDifficulty`, are
|
||||
refused. The resolver owns them.
|
||||
|
||||
Write it with `update_test_case`. **Pending LangTracer support** for
|
||||
`agentRun` (`agent`, `keepMemory`, `configOverrides`).
|
||||
|
||||
Direct mode rejects assistant-only fields: `conversation`,
|
||||
`processExpectations`, `outcomeExpectations`, `messageBudget`, `promptVersion`,
|
||||
`allowUserExecution` and `requiresMemoryCompaction` (when set to true),
|
||||
`credentialFixture`, and `seed.messages`, `seed.projects`, `seed.priorRuns`,
|
||||
`seed.recordedRuns`.
|
||||
|
||||
## 6. Tags
|
||||
|
||||
Always `agent-runtime`. Then one tag per component the case exercises:
|
||||
`data-tables`, `mcp`, `skills`, `web-search`, `web-search-live` (provider
|
||||
web search, see Scenarios), `memory`, `episodic`, `multi-turn`. Add the `business_domain`. Tags let a run select part of the
|
||||
suite. Set them with `update_test_case` (`evalTags`; the export writes them as
|
||||
the case's `tags`).
|
||||
|
||||
## Validate
|
||||
|
||||
Check the case against the schema before the local smoke run. It takes about
|
||||
a second and needs no instance. Save the case to a scratch file, then run this
|
||||
from `packages/@n8n/instance-ai` in an n8n checkout that has direct Agent runs,
|
||||
multi-turn and memory support:
|
||||
|
||||
```bash
|
||||
pnpm exec tsx -e "
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { EvalTestCaseSchema } from './evaluations/harness/schema';
|
||||
import { remapSeedArtifactIds } from './evaluations/harness/conversation-seed';
|
||||
for (const file of process.argv.slice(1)) {
|
||||
const parsed = EvalTestCaseSchema.safeParse(JSON.parse(readFileSync(file, 'utf8')));
|
||||
if (!parsed.success) { console.log('FAIL', file, JSON.stringify(parsed.error.issues.map(i => i.path.join('.') + ': ' + i.message))); process.exitCode = 1; continue; }
|
||||
if (parsed.data.seed) remapSeedArtifactIds(parsed.data.seed);
|
||||
console.log('ok ', file);
|
||||
}
|
||||
" /path/to/case.json
|
||||
```
|
||||
|
||||
It catches unknown keys, a bare `"[redacted]"` node credential, an `n8n_chat`
|
||||
`credentialId` that isn't `""`, rows that don't fit the columns, a missing
|
||||
`description` or `complexity`, ` › ` in names, and duplicate seed ids. It does
|
||||
not run anything. The local smoke run is next
|
||||
([calibrating.md](calibrating.md#run-locally-smoke-test)).
|
||||
@@ -0,0 +1,197 @@
|
||||
# Calibrating and publishing
|
||||
|
||||
The case lives in LangTracer ([building.md](building.md)). Run it locally
|
||||
first to catch case errors. The local smoke run from the scratch file works
|
||||
at any time, before review and before LangTracer stores seed rows. A run that
|
||||
reads the case from LangTracer (`--source langtracer`, and every remote run)
|
||||
needs the seed `rows` saved on the case, which needs LangTracer to store rows
|
||||
and the review to be done
|
||||
([building.md](building.md#3-seed-tables-and-rows)). Rows left only in the
|
||||
scratch file are not seen by those runs. Calibrate remotely, where every
|
||||
provider and episodic memory work. Publish by adding the case to the suite. There is no push
|
||||
from a disk file: do not use `eval:langtracer-push` for runtime cases.
|
||||
|
||||
## Run locally (smoke test)
|
||||
|
||||
Run the schema check in [building.md](building.md#validate) first. It
|
||||
catches most case errors in a second, without an instance.
|
||||
|
||||
Locally, everything runs on Anthropic. Non-Anthropic Agents run on a
|
||||
comparable Anthropic model, and episodic cases are skipped with "no embedding
|
||||
key". A local green is not a calibration.
|
||||
|
||||
Source the shared env file in the worktree. Do not copy it:
|
||||
|
||||
```bash
|
||||
set -a; source ~/repos/.env.eval; set +a
|
||||
```
|
||||
|
||||
The instance needs `N8N_INSTANCE_AI_EVAL_INSTANCE=true` (it turns on the eval
|
||||
endpoints) and `N8N_INSTANCE_AI_ENABLED=true`. Direct mode needs no sandbox.
|
||||
Start an isolated instance and seed the owner as in
|
||||
[running-evals.md](../create-instance-ai-eval/running-evals.md#run-locally-against-a-dev-instance).
|
||||
### Get the case onto disk
|
||||
|
||||
LangTracer has no single-case export. The only pull path is per suite:
|
||||
`export_suite`, which `--source langtracer --suite <slug>` also uses. So keep
|
||||
unpublished cases in a drafts suite, for example "Agents — runtime (drafts)".
|
||||
Ask the driver before you create it with `create_suite`. Reuse it for every
|
||||
case. It has no schedule.
|
||||
|
||||
Then run straight from LangTracer, from `packages/@n8n/instance-ai`:
|
||||
|
||||
```bash
|
||||
pnpm exec dotenvx run -f ../../../.env.eval -- \
|
||||
pnpm eval:instance-ai --source langtracer --suite <drafts-slug> \
|
||||
--filter <case-name> --base-url http://localhost:5680 --concurrency 1 --verbose
|
||||
```
|
||||
|
||||
To edit and rerun quickly, write the case's body from `export_suite`
|
||||
(`<case-name>.json`) to a scratch file at
|
||||
`packages/@n8n/instance-ai/evaluations/data/agents/<case-name>.json`, and run
|
||||
with `--filter <case-name>` and no `--source`. This file is scratch:
|
||||
|
||||
- Never commit it. Delete it when you are done.
|
||||
- Copy every fix back to LangTracer with `update_test_case`. LangTracer is the
|
||||
source of truth.
|
||||
|
||||
**Pending LangTracer support.** The export does not carry `agentRun`, seed `rows`,
|
||||
`expectations`, `userTurns`, or `sessions` yet. Until it does, add them to the
|
||||
scratch file by hand. The first run is the strict loader's check of the case.
|
||||
|
||||
Check:
|
||||
|
||||
- The row has `buildPath: "agent-direct"` in `eval-results.json`. The
|
||||
assistant never ran.
|
||||
- The log line for model resolution names the route (`direct`,
|
||||
`openrouter-same`, `comparable`) and the models.
|
||||
- No `framework_issue`. A seeding failure (`seedingFailed`) is a case error,
|
||||
not an Agent failure. Fix the seed.
|
||||
|
||||
## Run remotely (calibration)
|
||||
|
||||
Remote runs use the CI keys: Anthropic, OpenAI (also for embeddings), and
|
||||
OpenRouter (pending on CI).
|
||||
|
||||
**Pending LangTracer support.** Until LangTracer carries `agentRun` and the multi-turn
|
||||
fields, the exported case is not a direct case. If it carries `userTurns`,
|
||||
`sessions` or `expectations` without `agentRun`, the strict loader refuses it.
|
||||
Otherwise it runs as an assistant case, which is wrong. Do not calibrate
|
||||
remotely before then.
|
||||
|
||||
1. Build an n8n image from the top of the stack:
|
||||
`gh workflow run docker-build-push.yml --ref <stack-head-branch> -f push_enabled=true`.
|
||||
Rebuild after each change to the stack.
|
||||
2. Start the run with `start_evaluation`. Set `configuration.image` to that
|
||||
GHCR image. Select the case by id (`selection.kind: "cases"`). It does not
|
||||
need to be in the suite yet. It must already hold its seed `rows`.
|
||||
3. Run each new case 3–5 times. A runtime case uses real models and a
|
||||
simulated user, so one green proves little.
|
||||
|
||||
Pin the image for every run of this suite until direct Agent runs, multi-turn
|
||||
and memory support are in the nightly image. A direct case on an image
|
||||
without direct Agent runs fails.
|
||||
|
||||
## Read the result
|
||||
|
||||
Read three things for each scenario, not just the verdict:
|
||||
|
||||
- **The transcript:** what the simulated user said, and each Agent reply and
|
||||
tool call. Use `get_case_runs`, then `get_eval_transcript`. Did the user
|
||||
stay on goal and stop when done? Did it leak the expectations?
|
||||
- **The judge input:** the transcript, the tool calls, and the stored
|
||||
memory and which memory tasks ran. Each expectation needs the evidence it
|
||||
grades. A reply-only transcript cannot prove "no row was added".
|
||||
- **The judge reason** for each expectation.
|
||||
|
||||
Then check that each conditional expectation's precondition happened. A
|
||||
"must not save after refusal" pass means nothing if the user never refused.
|
||||
|
||||
`get_eval_transcript` and `get_eval_execution` return nothing for a direct
|
||||
Agent run yet. Read the run's CI artifacts instead:
|
||||
|
||||
```bash
|
||||
gh run download <ci-run-id> --repo n8n-io/lang-tracer --dir /tmp/run-<id>
|
||||
```
|
||||
|
||||
Each runner folder has `compose-logs.txt` (the n8n log) and
|
||||
`data/runs/<experimentId>/`. In that folder, each
|
||||
`<case>_<scenario>_<time>.json` is one iteration of one scenario:
|
||||
`verifierInput.transcript` is the conversation with every tool call, and
|
||||
`verifierInput.artifact.scenarioContext` is what the judge saw, including the
|
||||
opening message, the run status and the `finishReason`.
|
||||
|
||||
### Symptoms and causes
|
||||
|
||||
| Symptom | Likely cause | Fix |
|
||||
|---|---|---|
|
||||
| The Agent calls the same read tools again and again, ends on `max-iterations` with an empty reply, and `compose-logs.txt` has many "Mid-run observation hit the hard limit" lines | `observerThresholdTokens` below the Agent's base request: each tool result is swapped for notes right after it arrives | Remove the override, or raise it (see "Observational memory" in [SKILL.md](SKILL.md#memory-cases)) |
|
||||
| The first user message already holds what a later turn should bring (a photo, all the details), or asks for something the goal never mentions | The `userTurns` opening came from `dataSetup`, which didn't give it | Put the exact first message in `dataSetup` ([building.md](building.md#4-scenarios)) |
|
||||
| The Agent says it has no tool to create, update or delete, in one iteration only | The MCP mock made up a tool list without write tools | List the server's tools in `dataSetup` |
|
||||
| The Agent can't do the task because a tool returned content without the thing the user asks about | `dataSetup` doesn't say what the tool returns | Say it in `dataSetup` |
|
||||
| The Agent reports items that are in no seed row (other clients, other cards), "from live" data | The Agent read an MCP server instead of the seeded table (for example its cache looked stale against the seed dates), and `dataSetup` said only "returns the same data as the table", so the mock made up its own | List the exact items the MCP server returns in every scenario's `dataSetup`, with every field the expectations check (ids, names, dates), name its tools, and say it invents no others. A partial list is not enough: the mock fills the missing fields with its own values, and the Agent then reports them or treats the cache as out of sync |
|
||||
| Every iteration fails in seconds with `400 ... "too_big", "maximum":2000 ... "path":["scenarioHints"]` and the case is "not verified" | The scenario's `dataSetup` is over 2000 characters. n8n receives it as `scenarioHints` and refuses longer ones | Shorten `dataSetup` below 2000 characters: write repeated fields once (a shared description template, short codes for status and priority) |
|
||||
| The episodic-off control passes the recall expectations too | A tool result gives away what memory should supply (a deployment list that names the repo and branch) | Make the tool results carry nothing the user said in an earlier session, for example several projects and no git metadata |
|
||||
| A "must not change X" expectation fails because the user asked to change X | The expectation contradicts the conversation | Fix the opening or the expectation, whichever is wrong |
|
||||
|
||||
## Fix or keep each red
|
||||
|
||||
Classify each red, as in "A red is signal" in
|
||||
[create-instance-ai-eval](../create-instance-ai-eval/SKILL.md):
|
||||
|
||||
- **Case error:** a wrong name after the rename, a row the expectation does not
|
||||
match, a goal that does not reach the precondition. Fix the case.
|
||||
- **Harness limitation:** a mocked tool returns the wrong shape, memory did not
|
||||
settle, the proxy went off goal. Record it. Do not loosen the expectation to
|
||||
hide it.
|
||||
- **Agent failure:** the Agent breaks a rule its instructions give. Find who
|
||||
owns the fix (see "Agent failures: who owns the fix" below).
|
||||
- **Noise:** passes in some runs. Tighten the goal or the expectation, then
|
||||
run again.
|
||||
|
||||
Never weaken an expectation to make a real Agent failure pass.
|
||||
|
||||
### Agent failures: who owns the fix
|
||||
|
||||
Not every Agent failure is a runtime bug. Sort each one by who would fix it:
|
||||
|
||||
| Owner | Sign | What to do |
|
||||
|---|---|---|
|
||||
| **Runtime** | Fails the same way with strong models from two providers, or the transcript shows the runtime did the wrong thing (a tool missing from the request, memory not saved, a prompt part dropped) | Keep the red. Set `setKind: "capability_gap"` and propose a Linear ticket for the Agent team. Create it only if the driver says so. |
|
||||
| **Model** | A stronger model from the same provider passes with the same instructions | Swap the model on `seed.agents[].config` (`model` and the memory models). `configOverrides` can't set models. Add a lesson to the "Models" section of [agent-best-practices.md](agent-best-practices.md). |
|
||||
| **Agent config** | The instructions are vague, read as optional, or contradict each other, and a clearer wording passes | Fix the wording with `agentRun.configOverrides.instructions` (the full string). Add a lesson to [agent-best-practices.md](agent-best-practices.md). |
|
||||
|
||||
How to tell them apart:
|
||||
|
||||
1. Read the request the model got: are the tool, the skill and the rule in
|
||||
it? If not, it's the runtime.
|
||||
2. Swap the model. If it passes, it's the model.
|
||||
3. Reword the instruction. If it passes, it's the Agent config.
|
||||
4. If it still fails with a strong model and clear wording, it's the runtime.
|
||||
|
||||
Rerun after each change, with the same image and 3 iterations. The rerun is
|
||||
the before/after measurement for the new wording or model.
|
||||
|
||||
While calibrating, keep [agent-best-practices.md](agent-best-practices.md)
|
||||
up to date with every model and Agent config lesson: the rule, what went
|
||||
wrong without it, and an example. Describe behaviour; don't put case or
|
||||
ticket ids in it. At the end of a calibration round, propose one Linear
|
||||
ticket for the Agent team that lists the new lessons, so the assistant's and
|
||||
the MCP server's Agent-building guidance can pick them up.
|
||||
|
||||
## Publish
|
||||
|
||||
Publish only after calibration. The review and the seed `rows` came before it
|
||||
(see [SKILL.md](SKILL.md#review)), so publishing only files the finished case.
|
||||
|
||||
1. Get the id of "Agents — runtime" from `list_suites`.
|
||||
2. File the case: `move_cases_to_suite` from the drafts suite, or
|
||||
`add_cases_to_suite` if it is in no suite.
|
||||
3. Check the source link (`sourceThreadId`, `sourceRunId`) set in
|
||||
[building.md](building.md#1-snapshot--seedagents).
|
||||
4. Report the case, the suite, and the source thread as LangTracer links.
|
||||
5. Delete the scratch file, if you made one.
|
||||
|
||||
The nightly schedule and Slack (`#alerts-agents-evals`) are turned on for the
|
||||
suite once, after direct Agent runs, multi-turn and memory support are in
|
||||
the nightly image. Not per case.
|
||||
@@ -0,0 +1,92 @@
|
||||
# Sourcing an Agent from a snapshot
|
||||
|
||||
Runtime cases start from a real Agent that the assistant built. LangTracer keeps
|
||||
a snapshot of each Agent config the builder wrote. You find a snapshot, pick it,
|
||||
and then rewrite it ([building.md](building.md)).
|
||||
|
||||
## Find the snapshot
|
||||
|
||||
1. `list_conversations` with `usedAgentBuilder: true`. Do not use
|
||||
`source: "agent-builder"`. That pool has no Agent snapshots.
|
||||
2. For each thread, `list_conversation_agent_snapshots`.
|
||||
3. Pick one `agentId`. A thread can hold several Agents.
|
||||
4. Take the row with the **highest `seq`** and `reason: "config-updated"` for
|
||||
that `agentId`. This is the Agent as the user left it.
|
||||
- Many rows repeat the same `configHash`. The last row can also go back to
|
||||
an earlier hash. Take the highest `seq`, not the newest distinct hash.
|
||||
- Skip an Agent with no `config-updated` row.
|
||||
5. `get_conversation_agent_snapshot` with that row's `runId`.
|
||||
- Skip `truncated: true`. It has no config.
|
||||
- Credentials arrive as `[redacted]`. Instructions and skill bodies arrive
|
||||
as written. They are user data until you rewrite them.
|
||||
|
||||
Record the thread id, the run id, and `agentId @ configHash`. The hash pins the
|
||||
exact config.
|
||||
|
||||
## How to sample
|
||||
|
||||
LangTracer cannot yet filter or count snapshots by model or component. The
|
||||
model and components are only inside each snapshot, so a full census means
|
||||
thousands of calls. Sample instead:
|
||||
|
||||
- Take up to about 12 threads per `business_domain`, from the newest page and
|
||||
one page at a middle offset.
|
||||
- The domain facet is per thread, not per Agent. Read the Agent before you
|
||||
trust the facet.
|
||||
- Rare components need a wider sample. In one sample of 162 Agents: skills
|
||||
44%, MCP 10%, episodic memory 4%. Finding 3 episodic Agents took about 160
|
||||
snapshot reads.
|
||||
|
||||
## Pick
|
||||
|
||||
Spread the picks across domains and components (Data Tables, MCP, skills, web
|
||||
search, memory). Prefer an English source when two candidates are equal. The
|
||||
scrub translates the rest.
|
||||
|
||||
Check the language in the snapshot itself: read the instructions. A pick list
|
||||
or the thread's first prompt can name the wrong language.
|
||||
|
||||
Check how the Agent's model resolves. The harness picks the first route that
|
||||
works ([`credentials/model-resolver.ts`](../../../packages/@n8n/instance-ai/evaluations/credentials/model-resolver.ts)):
|
||||
|
||||
| Resolution | When | Pick it? |
|
||||
|---|---|---|
|
||||
| `direct` | its provider has a real key (Anthropic, OpenAI) | yes |
|
||||
| `openrouter-same` | the same model is on OpenRouter (Google, xAI, Moonshot, ...) | yes. Needs the OpenRouter key on CI. |
|
||||
| `comparable` | no same model anywhere; a model of the same tier runs instead | only for coverage. Results are tagged `model-fallback`. |
|
||||
| `skipped` | nothing maps | no |
|
||||
|
||||
Locally only Anthropic is set. Every non-Anthropic Agent runs on a comparable
|
||||
Anthropic model there. That is fine for a smoke test, not for calibration.
|
||||
|
||||
The resolver runs on every model in the config, including memory worker
|
||||
models. Most Agents leave worker models unset and use the runtime default.
|
||||
|
||||
## Skip
|
||||
|
||||
Skip what the harness cannot run:
|
||||
|
||||
- Vector stores (RAG Agents).
|
||||
- MCP servers on the SSE transport. Streamable HTTP is fine.
|
||||
- Orchestrators with sub-agents. The harness runs one Agent. Pick
|
||||
single-agent threads.
|
||||
|
||||
Note, do not skip:
|
||||
|
||||
- Workflow tools work. The snapshot has the reference, not the sub-workflow,
|
||||
so you write a synthetic one ([building.md](building.md#3b-workflow-tools)).
|
||||
- Knowledge files (`find_file`, `search_text`, `read_file`) can't be seeded.
|
||||
The Agent runs without documents. Pick it only if it has behavior worth
|
||||
grading without them, such as referrals or "I can't confirm".
|
||||
|
||||
- Channel integrations (Telegram, WhatsApp, Slack) are dropped in direct mode.
|
||||
Channel-only formatting rules in the instructions may not apply. Write
|
||||
expectations about the formatting rules only if the reply text shows them.
|
||||
- Two Data Table node types exist: `dataTableTool` and the plain `dataTable`
|
||||
node. Both need seed tables and rows.
|
||||
|
||||
## Record the pick
|
||||
|
||||
Keep a table: thread id, run id, `agentId @ configHash`, domain, components,
|
||||
model, resolution, memory, and one line on why it is in. Describe each Agent in
|
||||
generic words. Never copy names, URLs, or prompt text into the table.
|
||||
@@ -14,6 +14,9 @@ Each eval is **one JSON case**. Author workflow cases in
|
||||
`packages/@n8n/instance-ai/evaluations/data/workflows/`. Author standalone Agent
|
||||
cases in `packages/@n8n/instance-ai/evaluations/data/agents/` and follow the
|
||||
[`create-agent-builder-eval` skill](../create-agent-builder-eval/SKILL.md).
|
||||
To test the Agent itself (a seeded Agent runs directly against a simulated
|
||||
user, with no assistant turn), follow the
|
||||
[`create-agent-runtime-eval` skill](../create-agent-runtime-eval/SKILL.md).
|
||||
The disk loader auto-discovers `*.json` in both directories. A LangTracer suite
|
||||
is the durable home. Cases validate against
|
||||
[`harness/schema.ts`](../../../packages/@n8n/instance-ai/evaluations/harness/schema.ts)
|
||||
@@ -1039,7 +1042,9 @@ in *checkpoint* mode calibration this is how the driver opens the built thread
|
||||
## Other eval harnesses (not this skill)
|
||||
|
||||
Use the [`create-agent-builder-eval` skill](../create-agent-builder-eval/SKILL.md)
|
||||
for standalone Agent cases. Three other harnesses have their own data dirs and
|
||||
for standalone Agent cases that grade the builder. Use the
|
||||
[`create-agent-runtime-eval` skill](../create-agent-runtime-eval/SKILL.md) to
|
||||
test the Agent itself: it runs directly, with no assistant turn. Three other harnesses have their own data dirs and
|
||||
CLIs: **`eval:subagent`** (workflow-build compatibility corpus,
|
||||
binary-check scored), **`eval:discovery`** (asserts first-hop tool/dispatch
|
||||
routing, no n8n server), **`eval:pairwise`** (head-to-head build comparison vs
|
||||
|
||||
@@ -498,6 +498,11 @@ becoming a message the transcript builder would silently drop.
|
||||
|
||||
#### `agents` — "here's an agent you already built, now change it"
|
||||
|
||||
> To run the seeded Agent itself against a simulated user, with no assistant
|
||||
> turn (a case with `agentRun`), see
|
||||
> [create-agent-runtime-eval](../create-agent-runtime-eval/SKILL.md). This
|
||||
> section covers seeds that the assistant then changes.
|
||||
|
||||
An n8n **Agent** is not a workflow, so it has its own slot: a project-scoped
|
||||
resource with a config *plus authored skill bodies*. Declare it and the restore
|
||||
creates it at its pinned id in the thread's project, with its skills, before the
|
||||
|
||||
@@ -163,6 +163,21 @@ Two things to expect:
|
||||
- **The opening often has no text at all.** Keep it that way; see the empty-opening
|
||||
note in [`case-shapes.md`](case-shapes.md).
|
||||
|
||||
## Sourcing an Agent from a snapshot
|
||||
|
||||
An Agent the assistant built is a snapshot, not a workflow. Find it with
|
||||
`list_conversations` (`usedAgentBuilder: true`), then
|
||||
`list_conversation_agent_snapshots` for one `agentId`. Its instructions and
|
||||
skill bodies are real prose: rewrite them before they enter a case. To grade
|
||||
the builder, seed from the `target-resolved` row of the turn under test (the
|
||||
state that turn opened on), as in
|
||||
[create-agent-builder-eval](../create-agent-builder-eval/SKILL.md#source-the-case-from-a-real-thread).
|
||||
To test the Agent itself, take the highest-`seq` `config-updated` row (the
|
||||
thread's end state) and follow
|
||||
[create-agent-runtime-eval](../create-agent-runtime-eval/sourcing.md). Its
|
||||
[building.md](../create-agent-runtime-eval/building.md) has the Agent
|
||||
counterpart of the workflow scrub below.
|
||||
|
||||
## Scrubbing a real workflow into a synthetic seed
|
||||
|
||||
A seeded case carries a workflow inside it, and that file is committed and runs for
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../.agents/skills/create-agent-runtime-eval
|
||||
@@ -492,6 +492,7 @@ packages/cli/src/modules/instance-ai/eval/ @n8n-io/ai-trust
|
||||
packages/quality/testing/playwright/tests/evals/instance-ai/ @n8n-io/ai-trust
|
||||
.agents/skills/create-instance-ai-eval/ @n8n-io/ai-trust
|
||||
.agents/skills/create-agent-builder-eval/ @n8n-io/ai-trust
|
||||
.agents/skills/create-agent-runtime-eval/ @n8n-io/ai-trust
|
||||
packages/cli/src/modules/agent-evals/ @n8n-io/ai-trust
|
||||
packages/@n8n/agents/src/evals/ @n8n-io/ai-trust
|
||||
packages/frontend/editor-ui/src/features/ai/evaluation.ee/ @n8n-io/ai-trust
|
||||
@@ -15,7 +15,7 @@ Five harnesses live here:
|
||||
|
||||
To compare the model context of two commits (tokens for each LLM call, tool list size), use the A/B context benchmark: `eval:ab-bench`. See [ab-bench/README.md](./ab-bench/README.md).
|
||||
|
||||
> **Writing a test case?** This README is the reference and quick-start. Use the [`create-instance-ai-eval` skill](../../../../.agents/skills/create-instance-ai-eval/SKILL.md) for the shared process and workflow cases. Use the [`create-agent-builder-eval` skill](../../../../.agents/skills/create-agent-builder-eval/SKILL.md) for standalone Agent cases. To source cases from real failures, see [sourcing from LangTracer + LangSmith](../../../../.agents/skills/create-instance-ai-eval/sourcing-cases.md).
|
||||
> **Writing a test case?** This README is the reference and quick-start. Use the [`create-instance-ai-eval` skill](../../../../.agents/skills/create-instance-ai-eval/SKILL.md) for the shared process and workflow cases. Use the [`create-agent-builder-eval` skill](../../../../.agents/skills/create-agent-builder-eval/SKILL.md) for standalone Agent cases. Use the [`create-agent-runtime-eval` skill](../../../../.agents/skills/create-agent-runtime-eval/SKILL.md) to run a seeded Agent directly and grade its behavior. To source cases from real failures, see [sourcing from LangTracer + LangSmith](../../../../.agents/skills/create-instance-ai-eval/sourcing-cases.md).
|
||||
|
||||
Sections:
|
||||
|
||||
|
||||
Reference in new issue
Block a user