דלג לתוכן הראשי

Test and evaluate

There are three ways to check a flow, from small to thorough: test one step, run the whole flow on a file, or evaluate it on a table of test cases and read a pass rate. Evaluations are how you change a flow, or the AI behind it, without wondering what you broke.

  • Build
  • Before you change a flow
  • YAML and console

Test one step​

Open a step in the editor and use its Test step section. It runs that one step with the settings you have on screen, saved or not, and shows what came out.

  • If you opened the editor from a run (Open in editor with this run's data), the step runs on that run's data. Without one it runs on an empty document.
  • A step that sends or saves something runs as a dry run: it shows what it would do and does nothing. Switch on Really send (emails, saves, API calls) to make a test act for real.
  • A step test is metered but never charged, and it never appears in the run list.

Run the whole flow​

Click Run in the editor and drop in files. This is a real run: it costs what any run costs and it sends the emails the flow sends. Your first flow walks through it.

When you want to test without sending anything, evaluate.

Evaluate a flow​

An evaluation runs your flow once for each row of a table of test cases, in test mode, and checks each result against what the row says it should be. The share of runs that pass is the pass rate.

An evaluation: rows, test runs, scores and a pass rateThe evaluation trigger names a table of test cases. Each row of the table becomes one test run of the flow. At most maxConcurrent test runs are running at the same time, four by default, and the rest wait to start. Every test run happens in test mode: steps that would change something outside Lumen are captured as dry runs, approvals are answered from the row, and AI steps run for real. At the end of each run the score step checks what the run made against what the row expects and marks the run passed or failed. The results of all the runs are added up into one pass rate. In the picture, two of three runs pass.at most maxConcurrent test runs at once (4 by default)Test casesone row per caseTest runrow 1Flow stepsin test modescorepassedTest runrow 2Flow stepsin test modescorepassedTest runrow 3Flow stepsin test modescorefailedPass rate2 of 3 runs
Each row becomes a test run, each run is scored by the flow's score step, and the scores add up to the evaluation's pass rate.

You set up three things: a table of cases, an evaluation trigger that names it, and a score step that checks the result.

1. A table of test cases​

The dataset is a table in your workspace with one row per case. Some column names have a meaning:

ColumnBecomes
from, to, cc, subject, bodyThe email the test run starts with, so {email.subject} reads the case.
attachmentsPaths in your Files, one per line. Each is copied the way an arriving email's attachments are, so a test starts from the same document a live run does.
approveThe answer to an approval step: approve or reject, yes or no.
any other columnAvailable to the flow and to the score step as {run.case.<column>}.

Add your own columns for what you expect, for example expected_supplier. Every column is a run.case field, whether or not it has a special meaning.

To start from a real run, open it and use Save as test case: the run's email and files become a row. On a flow's Evaluations tab, Set up evaluation creates the table with starter columns and adds the trigger for you.

2. The evaluation trigger​

A flow keeps its real trigger and gains a second one, Test cases (evaluation). It starts nothing by itself: no email and no schedule ever starts a run from it, and neither does Run. Only an evaluation does.

Console labelYAML keyDefaultWhat it does
Table of test casesdatasetrequiredThe table to read, by name.
Runs per caserepeat1 (1 to 10)Runs each case this many times, to see how steady the AI is.
Most cases per evaluationmaxRows50 (1 to 200)Stops an evaluation from running a huge table by accident.
Pass rate neededminPassRate1 (0 to 1)The share of runs that must pass for the evaluation to pass.
Most tokens per casemaxTokensPerCaseno limitA run that uses more fails its case, however well it scored.
Most credits per casemaxCreditsPerCaseno limitThe same, in credits.
Runs at oncemaxConcurrent4 (1 to 50)How many test runs run at the same time.
Approval answersapprovalsthe approve columnWhich column answers which approval step: {node: approver, column: approve}.
Model classmodelClassthe workspace's test modelThe model class the AI steps use during a test.

maxConcurrent limits how many test runs are going at once. The rest wait, unstarted and unbilled, and each run that ends lets the next one start, in the order of the table. The AI calls of a test queue behind each other anyway, so starting every case at once only makes each one slower. Set it on the trigger, or in the maxConcurrent field of the API request that starts the evaluation, which overrides the trigger.

3. A score step​

The Score a test run step (score) compares what the run made with what the case expects. Each check reads a field from a step's output (details.supplier) and compares it with a value you write or a column of the case.

opPasses when
equalsThe values are equal. Numbers compare by value, text is trimmed.
containsThe text contains the expected text, ignoring case.
matchesThe value matches a regular expression.
jsonThe expected JSON is part of the value.
countA list has the expected length, or a number is the expected number.
existsThe field is there (expected false: it is not).
changesA list of changes matches the expected list. In equal mode (the default) a change nobody expected is a wrong write and fails the check. include needs only the expected ones.

A run passes when all its checks pass. Set minScore on the step (0 to 1) to allow a share of them to fail. The step changes nothing and costs nothing.

Put the score step behind a branch on run.test, so live runs skip it:

evaluate-invoice-intake.yaml
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: evaluate-invoice-intake
namespace: tenant-acme
spec:
displayName: Invoice intake with test cases
triggers:
- id: email
ref: {name: email-arrives}
connectorRef: {name: invoices-inbox}
next: [text]
- id: cases
title: Test cases
ref: {name: evaluation}
config:
dataset: invoice-cases
repeat: 1
minPassRate: 0.9
maxTokensPerCase: 80000
maxConcurrent: 4
next: [text]
nodes:
- id: text
stepRef: {name: read-text}
next: [details]
- id: details
stepRef: {name: chat-agent}
config:
instructions: Find these details in the invoice.
fields: [{name: supplier}, {name: total, hint: Amount due, type: money}]
files: {mode: ifNoText}
next: [tell]
- id: tell
title: Send the details to accounting
stepRef: {name: send-email}
config:
to: accounting@acme.example
subject: "Invoice from {details.supplier}"
body: "Total: {details.total}"
next: [is-test]
- id: is-test
title: Is this a test?
branch:
- when: {field: run.test, op: eq, value: true}
next: [score]
- id: score
title: Check the details
stepRef: {name: score}
config:
checks:
- {name: supplier, actual: details.supplier, op: equals, expectedColumn: expected_supplier}
- {name: total, actual: details.total, op: equals, expectedColumn: expected_total}

What test mode does​

A test run is a normal run, started from a row, in a copy of the flow made for testing. The worker runs it step by step as it runs any run. What changes is what each step is allowed to do.

The stepIn a test run
AI and agent steps, and the logic steps (branches, filters, fields)Run for real. An agent may use only tools that are safe to try: no MCP tools, no browser.
Steps that read or compute, such as read the text, merge or split a PDF, rename a file, classifyRun for real.
Update a spreadsheetRuns for real, writing a new file under the run's own key. The workbook in Files is never written.
Steps that send or write outside the run: send, reply to and forward email, save a file, add or update a row, an HTTP request, WhatsApp, Jira and GitHub writes, in-app notifications, run code, dedupeCaptured. The step shows what it would have done, and nothing happens.
ApprovalsAnswered from the case's column.
Steps that cannot be held back: apps' remote steps, delay, memory stepsRefused.

If a flow holds a step that is refused, the evaluation does not start: Lumen names each such step first, so nothing runs by surprise. A step Lumen has not classified is refused too.

Inside a test run, {run.test} is true, and {run.case.<column>} is the row. A flow that runs another flow starts its child in test mode too. The evaluation scores the parent's run. A score step in the child runs and shows on the child's run, but does not count toward the pass rate.

Run an evaluation​

  1. Open the flow and choose the Evaluations tab. It shows your table of test cases and its row count.
  2. If the flow has no evaluation yet, click Set up evaluation. Then add rows to the table, or save runs as test cases.
  3. To run each case more than once, click the gear beside Run evaluation and set Runs per case. More than one shows how much the AI varies.
  4. Click Run evaluation. The row for it shows its progress ("Running 3/12") and fills in when every run has ended.

Read the results​

The Evaluations tab lists every evaluation, newest first: its date, Pass rate (such as 32/32 · 100%), Wrong writes with a red mark when there are any, Cost, Duration, the Model and who started it. A small line chart shows the pass rate over time, so you see whether a change helped.

Click an evaluation to open it. A grid shows each case against each check, with the tokens and credits it used and a link to its test run. Failures only narrows it to the runs that need a look. A run opens onto its checks. A changes check is drawn as a diff: As expected, Missing: expected, not made, Wrong write, or Extra, allowed. Held back lists what the run would have sent, saved or called.

An evaluation passes when the share of runs that passed reaches minPassRate. A run that failed to finish counts as a failure.

What it costs​

AI steps run for real in a test, so an evaluation is charged at the normal rate. Its usage is marked as an evaluation in Billing and usage, so you can tell testing from customer work. Test runs are not listed with your flow's real runs and are never counted in a budget: a budget never holds an evaluation back, and an evaluation never uses up a flow's budget. The step test is the exception: it is metered and not charged.

During a test, AI steps run on the workspace's test model unless the request or the trigger names another with modelClass. The evaluation records which model it used and how it was billed.

Keep the table small and sharp

Ten cases that each cover a different mistake tell you more than a hundred of the same kind. Add a case every time a live run goes wrong, with Save as test case, and the flow gets harder to break.

Next steps​