Test runs and results analysis
Test runs provide a repeatable way to ask an agent the prompts in a project test suite and judge its answers. The system runs selected tests against one or more models and context versions, stores each attempt, and presents pass results, failures, history, and model cost trade-offs in the settings workbench. Runs can start manually or from a recurring schedule. The workbench also lets an engineer choose the change source for a comparison and run a test from an open test tab. See also Testing and evaluation and Web application.
Test case configuration
Test cases define the question to ask and the evidence that makes an answer correct. They are shared by the CLI and the web application, so the same test can be run locally or inspected in project history.
Test definitions
Each test is a YAML file under the project tests/ folder. A test has a prompt and can add reference SQL, a database, tool-call assertions, tags, and an owner. The file path identifies the test across runs, while a content hash marks results from an older version of the test.
Assertions check agent behavior before the final data check. A tool-call assertion can require a tool, a subset of its arguments, and a minimum call count. Reference SQL supplies expected data; without it, the test can only use assertions and a test with neither check is reported as having no verification.
References: apps/…/test-suite.service.ts• L17-25 apps/…/test-suite.service.ts• L124-158 apps/…/test-run.ts• L221-233 cli/…/case.py• L27-51
Test selection
The runner can use the full suite or a subset. The web workbench selects individual paths or tags and can search by test name or path, while the CLI selects a test by name, file stem, or folder. Invalid selected files block the run instead of silently reducing the suite.
References: apps/…/test-suite.service.ts• L80-92 apps/…/test-runner.service.ts• L267-276 cli/…/runner.py• L526-571 apps/…/test-suite-panel.tsx• L120-137 apps/…/test-suite-panel.tsx• L228-290
Run orchestration
A run is the planned set of test, model, attempt, and context combinations. The backend creates the run first, then executes its attempts in the background so the web client can follow progress without holding the start request open.
Run planning
The plan resolves the selected tests, models, reasoning efforts, attempt count, concurrency, and comparison tolerances. Values come from the start request, then project test settings, then project model defaults. The plan also chooses a verification model when several models are being compared.
The system limits the number of models, attempts, and worker threads. A project can have only one queued or running run, which prevents overlapping runs from reading or changing the same test context in conflicting ways.
References: apps/…/test-runner.service.ts• L262-359 apps/…/test-run.ts• L23-41 apps/…/test-run.queries.ts• L13-21 apps/…/sqlite-schema.ts• L1226-1266
Attempt execution
The runner expands the plan into jobs and executes several jobs at a time. Each job creates a test chat, runs the agent with the chosen model, evaluates the answer, and records a pass or fail result with usage and timing data.
The run reports queued, running, completed, failed, or cancelled state. A heartbeat detects work left behind by a stopped process, and cancellation stops work that is still in flight. A failed attempt is recorded as a failed result; a runner-level error fails the run after active work settles.
The following flow shows how a configured test becomes a stored result.
flowchart LR
A[Test file and run settings] --> B[Run plan]
B --> C[Attempt job]
C --> D[Agent chat]
D --> E[Assertions and data verification]
E --> F[Attempt result]
F --> G[Run totals and history]
References: apps/…/test-runner.service.ts• L361-423 apps/…/test-runner.service.ts• L430-512 apps/…/test-run.queries.ts• L269-340
Scheduled runs
Schedules start production-context runs with a chosen tag scope, model set, and attempt count. A schedule can come from the project configuration or from the settings workbench. Workbench schedules can be edited, paused, resumed, or deleted; configuration schedules are managed in nao_config.yaml.
The scheduler resolves a user who can read the project context before it starts a run. A run that is already active is retried later, while an invalid or empty test selection is skipped until the next scheduled time. Scheduled outcomes can also trigger failure notices.
References: apps/…/test-schedule.service.ts• L35-113 apps/…/test-schedule.service.ts• L120-187 apps/…/test-runner.service.ts• L141-145
Context variants
A production run tests the saved context. A changes run tests the current draft context. A comparison run executes both variants for the same tests, models, and attempt numbers so the result can show what changed rather than only showing two unrelated runs.
The settings workbench can choose the change source used for the changes side. This source can be the user's File Explorer changes, the current File Explorer branch, or a branch from a synced repository. Production remains on its own branch while the selected source supplies the comparison side. The start service maps the selected production, changes, or comparison mode to the matching backend run and rejects a missing or unusable draft before the run starts.
Tests edited only in the workbench do not count as context changes. A draft comparison needs at least one relevant context change and keeps enough draft metadata to identify the version that was tested.
References: apps/…/test-run-start.service.ts• L8-43 apps/…/test-run-start.service.ts• L45-69 apps/…/test-runner.service.ts• L122-185 apps/…/test-run.ts• L9-21 apps/…/use-test-run-start.ts• L36-67 apps/…/test-run-actions.tsx• L90-138 apps/…/test-run-actions.tsx• L185-225 apps/…/test-upstream-picker.tsx• L28-120
Result persistence
Persistence separates run-level progress from attempt-level evidence. This lets the application show a live run summary while keeping the answer, SQL, data, and chat link for later inspection.
Run records
The run record stores the project, trigger, context identity, selected tests, models, requested attempts, progress counts, total token use, total cost, timestamps, and any run error. It is the source for recent-run lists and live progress.
References: apps/…/sqlite-schema.ts• L1226-1266 apps/…/test-run.queries.ts• L13-21
Attempt records
An attempt record identifies the test version, model and reasoning effort, context variant, attempt number, verdict, error, chat link, and usage metrics. Its details can include the answer text, expected and actual rows, row counts, comparison text, reference SQL, verification SQL, and the source queries used for verification. Stored result rows are bounded so large answers do not make run history unmanageable.
References: apps/…/sqlite-schema.ts• L1226-1304 apps/…/pg-schema.ts• L1146-1214 apps/…/test-runner.service.ts• L416-512
Verdict calculation
The verdict is a single pass or fail decision built from independent checks. Tool behavior must satisfy all configured assertions, and a test with reference SQL must also produce data that matches the reference result.
Behavioral checks
The evaluator extracts tool calls from the agent run and checks each assertion. Argument objects match as subsets, so an assertion can focus on the fields that matter without requiring an exact full call. All assertions must pass for the behavioral part to pass.
References: apps/…/test-evaluation.service.ts• L27-66 apps/…/test-verdict.ts• L56-120 cli/…/assertions.py• L92-159
Data checks
The reference SQL runs in the project query context. A verification step reads the agent's query results and produces the actual data to compare with the reference data. The comparison normalizes values, ignores column and row order, rounds floats, and allows numeric differences within configured relative and absolute tolerances.
The verification query uses the same project access rules as a test query. It can also account for the project's semantic-layer mode, while privileged project roles can verify reference SQL that includes compiled semantic queries.
Missing columns, different row counts, missing data, and values outside tolerance fail the data check. The result keeps a readable difference and a row-level diff for the workbench.
References: apps/…/test-evaluation.service.ts• L39-71 apps/…/test-evaluation.service.ts• L80-135 apps/…/test-data-comparison.ts• L39-91 apps/…/test-data-comparison.ts• L94-152 cli/…/runner.py• L85-195
Result summaries
The history layer turns individual attempts into views that answer three questions: which tests passed, how models compare, and how a draft changed the result. These summaries use only the attempts that are present, so active runs can remain partial while they are displayed.
Run totals
A test passes at the run level only when all expected attempts pass. A test with both passing and failing attempts is flaky. Totals are grouped by context variant and model, which keeps a multi-model run from hiding disagreement between models.
References: apps/…/test-run-totals.ts• L22-39 apps/…/test-run-totals.ts• L64-72 apps/…/test-history.service.ts• L82-90 apps/…/test-model-matrix.tsx• L98-115 apps/…/test-run-verdict.tsx• L34-102
Model trade-offs
Model summaries rank accuracy first and use cost per correct answer as a value measure. They also show reliable test count, cost per question, tool calls, median duration, and token use. The workbench can rank models by these measures and plot accuracy against cost, including a point for each reasoning effort when a model runs at several efforts.
Comparison views pair the same model across the saved and draft contexts. They can plot accuracy against cost, tokens, tool calls, or time, so an engineer can see whether a context change improved quality at an acceptable operating cost.
References: apps/…/test-model-summary.ts• L19-79 apps/…/test-model-leaderboard.tsx• L94-166 apps/…/test-model-frontier-chart.tsx• L25-81 apps/…/test-model-changes-chart.tsx• L21-105
Context comparisons
Comparison runs pair production and draft attempts by test, model, and attempt number. A test is pending until both sides have all expected attempts. The final change is classified as regressed, worsened, fixed, improved, unchanged, or pending by comparing pass rates. New and deleted tests are treated as one-sided results rather than as false changes in accuracy.
For a model comparison, the workbench also compares accuracy with cost, tokens, tool calls, or time. An arrow from production to the draft shows whether the user's context changes moved the model toward or away from the desired result.
References: apps/…/test-comparison.ts• L27-75 apps/…/test-history.service.ts• L121-175 apps/…/test-model-changes-chart.tsx• L60-105 apps/…/test-run-results.tsx• L111-159 apps/…/test-run-verdict.ts• L31-32 apps/…/test-run-verdict.ts• L105-120
Test history
Test history lists recent runs that included one test and adds data diffs for each attempt. It marks a result as outdated when the test file hash changed after the run, so an old pass is not mistaken for a result for the current test.
The workbench refreshes active runs while they execute. If a selected run is older than the recent history window, it fetches that run as well, so opening a run from a suite view does not lose the selected result.
References: apps/…/test-history.service.ts• L51-79 apps/…/test-history.service.ts• L121-145 apps/…/use-test-history.ts• L7-27 apps/…/use-latest-changes-run.ts• L1-59 apps/…/test-workbench.tsx• L49-89 apps/…/test-status-button.tsx• L7-67
CLI execution
nao test is the terminal entry point for running the same YAML test style outside the web workbench. It loads project defaults, discovers and filters tests, runs each test against each selected model for the requested number of attempts, saves a JSON result file, and exits with a failure status when any attempt fails.
CLI workflow
The CLI uses the test API for the agent run and evaluation. It sends the prompt, model, reference SQL, assertions, and comparison settings to the backend, then consumes the returned verdict and verification data. It can authenticate with a stored login, credentials, or an API key, and it can run jobs in parallel.
References: cli/…/__init__.py• L1-17 cli/…/runner.py• L589-767 cli/…/client.py• L150-214 apps/…/test.ts• L29-95
CLI results
The CLI writes timestamped JSON under tests/outputs/. The file contains raw results, suite totals, per-model summaries, and repeated-attempt metrics. For k attempts, pass@1 is the average attempt pass rate, pass@k means at least one attempt passed, and pass^k means every attempt passed.
References: cli/…/runner.py• L381-397 cli/…/runner.py• L400-500 cli/…/summary.py• L65-129
Settings workbench
The settings workbench is the interactive view for choosing tests, starting runs, and inspecting stored evidence. It sits beside the context explorer and connects test files, draft changes, run history, model summaries, and attempt details.
Run settings
The workbench remembers a user's models, reasoning efforts, attempt count, thread count, and preferred context mode in the browser. If no browser override exists, it uses the project test settings and then the default chat model. The run controls select production, changes, or comparison mode based on whether the context has relevant draft changes.
The upstream picker chooses the change source for a comparison. It can use File Explorer changes, the current File Explorer branch, or a branch from a synced repository. A branch switch is blocked when the File Explorer has changes that could be lost.
The model picker estimates answer count, cost, and time from recent model history. It also lets an engineer test one or more reasoning efforts and copy the selection as the test block of nao_config.yaml, so a useful browser choice can become a reviewed project default. The same picker exposes production schedules for the current test scope. It shows the next run time and lets an engineer save the selected models and attempt count for a recurring run.
References: apps/…/test-model-picker.tsx• L40-67 apps/…/test-model-picker.tsx• L338-445 apps/…/test-schedules.tsx• L49-134 apps/…/test-run-actions.tsx• L55-141 apps/…/test-upstream-picker.tsx• L28-120 apps/…/test-upstream-picker.tsx• L123-180 apps/…/use-test-run-start.ts• L31-67 cli/…/__init__.py• L8-33
Suite and run views
The suite view lists valid and invalid tests, tags, search results, latest outcomes, and recent runs. It supports selecting an exact set or a filtered scope for the next run. Recent runs can be filtered by run type or outcome, including scheduled runs. A run view follows progress, filters passed, failed, or disagreeing tests, and shows a model leaderboard, a draft-change chart, a reasoning-effort matrix, or single-model statistics.
The run view can group results by tag. Tagged tests count in every tag they carry, while untagged tests appear in a separate group. The tag summary shows pass counts, accuracy, model results, cost, and time, and selecting a tag filters the test list to that group.
The workbench uses an expandable drawer with an All tests tab and one tab for each opened test. Test tabs can be reordered or closed. Each tab can start its test from the tab bar, while the drawer bar keeps suite or open-test run controls available. The recent-runs column can be resized with a pointer or keyboard and keeps its width for the next visit.
Compact status buttons show the latest result for a test. They distinguish a complete pass, an incomplete result, and an outdated result, and open the relevant test view when selected.
References: apps/…/test-suite-panel.tsx• L58-137 apps/…/test-run-filter-menu.tsx• L19-115 apps/…/test-run-list-item.tsx• L149-218 apps/…/test-run-results.tsx• L48-151 apps/…/test-tag-breakdown.tsx• L23-178 apps/…/test-drawer.tsx• L95-182 apps/…/test-drawer.tsx• L202-332 apps/…/test-drawer-layout.tsx• L10-43 apps/…/test-drawer-layout.tsx• L60-151 apps/…/test-tab-run-button.tsx• L11-75 apps/…/test-status-button.tsx• L7-67 apps/…/test-suite-panel.test.tsx• L33-349 apps/…/test-drawer.test.tsx• L83-180
Attempt inspection
The attempt view lets an engineer select a model and attempt, then inspect the data diff, answer, or SQL. Comparison attempts show the saved and draft contexts side by side. The SQL view compares the agent queries and keeps reference SQL available, while the answer view links to the original chat when it is available and otherwise uses saved answer text. When compared attempts used different queries, the SQL view marks the changed lines; when they used the same query, it makes that fact clear.
The view also exposes the basic cost, time, token, and tool-call measures for the selected answer. It favors a failed or changed attempt first, so the engineer reaches the evidence most likely to explain the run result.
References: apps/…/test-run-details.tsx• L31-96 apps/…/test-attempt-details.tsx• L17-99 apps/…/test-attempt-sql.tsx• L20-75 apps/…/test-attempt-sql.tsx• L41-73 apps/…/test-workbench.tsx• L74-89
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the YAML test contract aligned between backend parsing, CLI loading, and the
/api/test/runpayload. - Keep verdict rules aligned between the backend evaluator and CLI fallback evaluation so the same test does not produce different pass states.
- Preserve the pairing keys for comparison results: test path, model, reasoning effort, context variant, and attempt number.
- Update result detail consumers when stored fields change because the workbench uses saved answer text, replayed chats, agent queries, and reference SQL.
- Keep project test defaults, browser run overrides, context mode, model efforts, and run limits consistent with the settings controls.
- Keep schedule source, cron validity, tag scope, model selection, attempt count, pause state, and next-run display consistent across nao_config.yaml, scheduled jobs, and the settings workbench.
- Keep the selected upstream source aligned with context branch switching and the production-versus-draft labels shown in run results.
- Keep drawer tab state, per-tab run actions, suite actions, compact result status, recent-run selection, and tag filtering synchronized when the workbench navigation changes.
- Keep history refresh able to return both active runs and a selected older run opened from a suite result.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Invalid YAML or invalid nao_config.yaml test settings | The selected run is rejected before attempts start. | Validate files and settings before planning the run. |
| A project already has a queued or running run | A second run cannot be created. | The active-run database constraint and the workbench disable start controls. |
| A process stops refreshing its heartbeat | The run can remain active and block later runs until it is marked failed. | Stale-run cleanup fails runs with an old heartbeat. |
| Reference SQL returns no data or the agent returns no data | The data verdict fails even if the agent produced text. | Show the verification error and stored answer in attempt details. |
| Test content changes after a run | The old result may no longer describe the current test. | Store the test hash and mark the history entry as outdated. |
| A comparison side has incomplete attempts | The change stays pending and must not be treated as a regression or fix. | Compare only after both variants reach the expected attempt count. |
| A selected historical run is outside the recent history response | The workbench could show the wrong run or no run. | Fetch the selected run when it is not in the latest history list. |
| File Explorer has unsaved or uncommitted changes when its branch must switch | The requested upstream cannot be selected, which prevents a misleading context change. | Block branch switching until the worktree is safe to change. |
| A requested changes or comparison run has no usable draft | The run does not start and no result is created. | Read the selected upstream or user draft strictly and show the actionable missing-draft error. |
| A test status comes from an older test version | The compact status can suggest success for content that is no longer current. | Mark the result outdated and prompt the engineer to test again. |
| A schedule has an invalid cron expression | The schedule is rejected and no recurring job is saved. | Validate the schedule before saving it. |
| A scheduled run finds an active run or no valid matching tests | The scheduled attempt is delayed or skipped without creating a misleading result. | Retry active-run conflicts and wait for the next tick after input errors. |
Key files
| File | Why to read it |
|---|---|
| apps/…/test-run.ts | Shared terms for tests, runs, models, variants, verdicts, and summaries. |
| apps/…/test-suite.service.ts | Test discovery, YAML shape, validation, and selection. |
| apps/…/test-run-start.service.ts | Selection of production, changes, or comparison mode and draft validation. |
| apps/…/test-runner.service.ts | Run planning, background execution, context variants, scheduling trigger, and attempt creation. |
| apps/…/test-schedule.service.ts | Recurring test schedules from the app and nao_config.yaml. |
| apps/…/test-evaluation.service.ts | The boundary between an agent answer and its checks. |
| apps/…/test-verdict.ts | Combined pass or fail rules for assertions and reference data. |
| apps/…/test-data-comparison.ts | Data normalization, tolerance behavior, and readable diffs. |
| apps/…/test-history.service.ts | History queries, model summaries, and paired context results. |
| apps/…/test-run.queries.ts | Run lifecycle, persistence, progress totals, and history reads. |
| apps/…/test-run.routes.ts | Web-facing test, run, history, cancellation, and schedule operations. |
| apps/…/test.ts | CLI-facing single-test execution contract. |
| cli/…/runner.py | CLI discovery, orchestration, output, and exit behavior. |
| cli/…/summary.py | CLI aggregate and repeated-attempt metrics. |
| apps/…/test-drawer.tsx | The settings entry point that connects test tabs, suite views, run controls, and workbench panels. |
| apps/…/test-suite-panel.tsx | Suite selection, filtering, latest outcomes, and run list. |
| apps/…/test-run-actions.tsx | Production, changes, and comparison actions for suites and open tests. |
| apps/…/test-run-filter-menu.tsx | Recent-run filters for run type and outcome. |
| apps/…/test-run-results.tsx | Run-level filters, model views, and test outcomes. |
| apps/…/test-tag-breakdown.tsx | Tag-level result grouping, comparison accuracy, and tag filtering. |
| apps/…/test-run-types.ts | Shared workbench result types, run state, model labels, and summary helpers. |
| apps/…/test-run-verdict.ts | User-facing pass, fail, flaky, pending, and comparison labels. |
| apps/…/test-run-list-item.tsx | Recent-run status, scope, progress, and comparison summaries. |
| apps/…/test-model-picker.tsx | Model, reasoning-effort, attempt, thread, schedule, and run estimate settings. |
| apps/…/test-schedules.tsx | Settings workbench controls for recurring production runs. |
| apps/…/test-upstream-picker.tsx | Sources for the changes side of a production comparison. |
| apps/…/test-tab-run-button.tsx | Per-tab test execution from the drawer tab bar. |
| apps/…/test-status-button.tsx | Compact latest-result status and outdated-result cue. |
| apps/…/test-run-details.tsx | Model and attempt selection for detailed inspection. |
| apps/…/test-attempt-details.tsx | Data, answer, SQL, and comparison inspection tabs. |
| apps/…/test-attempt-sql.tsx | Agent-query and reference-query views for attempt evidence. |
| apps/…/use-test-history.ts | Active-run refresh and selected-run history loading. |
| apps/…/use-test-run-start.ts | The browser contract for starting production, changes, and comparison runs. |
| apps/…/test-drawer.test.tsx | User-facing drawer behavior for test tabs, run controls, and active-run state. |
| apps/…/test-suite-panel.test.tsx | User-facing suite filtering, selection, run outcomes, and model comparison behavior. |