Testing and evaluation
Testing and evaluation turns expected analytical behavior into repeatable checks for an agent and its data answers. Engineers can define realistic questions with trusted reference results, run them across models or context versions, and use the outcomes to judge quality, reliability, cost, and speed.
Test suite
Test definitions
A test definition is a small analytical contract stored as a YAML file under tests/. It gives the agent a natural-language prompt and can give the system reference SQL, tool-call checks, tags, and an owner. The prompt should represent how a user asks a question, while the reference SQL states the expected result without exposing the answer in the prompt.
The suite is discovered from the project context and can be run as a whole or narrowed by test path or tag. Invalid files remain visible as errors and block a run when they are part of the selected scope. The test folder is treated as project data, so reads must remain inside the project boundary.
References: apps/…/test-suite.service.ts• L17-42 apps/…/test-run.ts• L221-252 skills/…/SKILL.md• L14-31 apps/…/project-symlink-reads.test.ts• L65-81
Test coverage
The suite acts as a reliability benchmark for the project context. Good coverage includes key metrics and the user wording, time ranges, multi-step queries, empty results, null values, and ambiguous terms that can change an answer.
Tests must use SQL that runs against the real warehouse. They should not include table hints or other clues that a real user would not provide.
References: skills/…/SKILL.md• L10-12 skills/…/SKILL.md• L33-62 example/…/total_revenue.yml• L1-5
Evaluation model
Agent and data checks
Each attempt sends the test prompt through the test agent without treating it as a normal saved conversation. The test agent focuses on analytical work, so it keeps query and chart actions while leaving out interactive chat and context-edit actions.
The evaluator checks two kinds of behavior:
- Action checks verify that the agent made required tool calls. An assertion can match a tool name, a subset of its arguments, and a minimum call count.
- Answer checks compare the agent's data with the data from the reference SQL when the test defines reference SQL.
Agent behavior is also bounded by the tools and context access available to the run. The surrounding agent checks protect context edits, file and warehouse reads, user rules, onboarding handoffs, skill loading, SQL dialect guidance, and story actions, so a correct answer does not hide an unsafe or invalid tool action.
The answer check compares the meaningful table shape and values. It ignores column and row order, normalizes common number and date forms, and allows configured numeric tolerances. A test passes only when every configured check passes.
References: apps/…/test-agent.service.ts• L43-69 apps/…/test-evaluation.service.ts• L28-67 apps/…/test-verdict.ts• L11-53 apps/…/test-data-comparison.ts• L39-91 apps/…/agent-profiles.test.ts• L64-81 apps/…/context-fix-collector.test.ts• L12-142 apps/…/dialect-rules.test.ts• L20-126 apps/…/internal-skills.test.ts• L17-151 apps/…/onboarding-agent.test.ts• L8-23 apps/…/onboarding-step-tools.test.ts• L16-39 apps/…/storage-tools.test.ts• L47-187 apps/…/story-edit-from-another-chat.test.ts• L47-165 apps/…/story-tool.test.ts• L7-21 apps/…/user-rules.test.ts• L71-105 apps/…/test-data-comparison.test.ts• L11-219
Verification results
The evaluator uses the agent's fetched query results to form the answer that it compares with the reference data. This keeps the check focused on the answer produced from the agent's own data and records the source queries and comparison details for later review.
When a test has no reference SQL, action assertions are the available checks. A test with neither reference SQL nor assertions has no verification check and therefore does not measure answer correctness.
The comparison report makes differences visible at the level needed for diagnosis. It can show missing or extra columns, row-count changes, value differences, close numeric values, empty-result differences, and truncated stored data.
References: apps/…/test-agent.service.ts• L99-160 apps/…/test-evaluation.service.ts• L40-66 apps/…/test-verdict.ts• L41-53 apps/…/test-data-comparison.test.ts• L250-349
Test runs
Run planning
A test run is a selected set of tests executed with one or more language models. The run can repeat each test to expose unstable behavior, use selected reasoning efforts, and limit parallel work. Project settings provide defaults, while the web application can supply a different selection for a run.
The available model controls follow the capabilities of the selected model. This keeps reasoning and sampling choices valid for listed, custom, and region-specific models. Model prices can come from built-in data or declared project values, so the run can report cost even when a model is not in the built-in list.
The run records which tests, models, attempts, and context variant it used. This makes results comparable even when the project changes later. A model can also be evaluated by a separate verification model when several models are under test.
References: apps/…/test-runner.service.ts• L229-261 apps/…/test-run.ts• L6-32 apps/…/use-test-run-settings.ts• L30-53 apps/…/test-runner.service.test.ts• L118-285 apps/…/provider-meta.test.ts• L174-454 apps/…/model-prices.test.ts• L17-81
Run lifecycle
The run is created first and then executes its attempts in the background. Each attempt creates a test chat, runs the agent, evaluates the result, and stores the verdict with useful evidence such as response text, data samples, queries, token use, cost, duration, and tool-call count.
Only one active run is allowed for a project. A run can be cancelled, and cancellation aborts attempts that are still running or setting up. Interrupted work is marked failed when its heartbeat becomes stale so that it does not block later runs. An agent error fails its attempt without hiding the rest of the run's results.
References: apps/…/test-runner.service.ts• L199-227 apps/…/test-runner.service.ts• L328-390 apps/…/test-runner.service.ts• L393-460 apps/…/test-run.ts• L70-89 apps/…/test-runner.service.test.ts• L302-385 apps/…/test-runner.service.test.ts• L594-640
Context variants
The product can test the production context, the current user changes, or both. A changes-only run evaluates the draft context by itself. A comparison run sends matching tests and models through both variants so that the result shows whether a change improved or harmed behavior rather than only showing the new state.
The comparison can also use a selected branch from a synced upstream repository as the alternate context. The draft can come from the project editor even when the project has no connected context repository. The comparison uses a temporary snapshot and removes it when the run ends or cannot start. A comparison is rejected when the draft has no applicable changes.
The comparison is reported per test as pending, unchanged, improved, fixed, worsened, or regressed. A comparison stays pending until both sides have all expected attempts.
This diagram shows how one test can produce paired evidence for production and draft context.
flowchart LR
T[Test definition] --> P[Production context]
T --> D[Draft or upstream context]
P --> PA[Attempts]
D --> DA[Attempts]
PA --> C[Per-test comparison]
DA --> C
References: apps/…/test-runner.service.ts• L123-160 apps/…/test-comparison.ts• L27-75 apps/…/use-test-run-start.ts• L41-73 apps/…/test-runner.service.test.ts• L397-601 apps/…/test-run-actions.test.tsx• L130-204 apps/…/test-run-actions.test.tsx• L275-403
Quality comparison
Model comparison
A run can place several models or reasoning efforts under the same test workload. The product compares their pass rates and reliable-test counts, then adds cost, tokens, tool calls, and duration so an engineer can weigh answer quality against operating cost.
The comparison view highlights tests where models disagree. A leaderboard and model matrix make the trade-off visible without mixing results from different context variants. Cost uses the best available model price data, while missing prices remain unknown instead of becoming a false estimate.
References: apps/…/test-model-summary.ts• L19-66 apps/…/model-prices.ts• L14-38 apps/…/test-model-matrix.tsx• L17-35 apps/…/test-run-results.tsx• L117-147 apps/…/model-prices.test.ts• L17-81 apps/…/test-runner.service.test.ts• L173-285 apps/…/test-suite-panel.test.tsx• L93-191
Run history
The system keeps run and attempt history so a test can be judged over time. The latest outcome for a test is marked outdated when its file changed after the run, and a later run can be compared with an earlier run of the same model over the same tests.
The test workbench also identifies results from an older test version and presents the latest context comparison in plain language. This history supports two questions: whether the current test definition still passed, and whether a context or model change moved the benchmark in the right direction.
References: apps/…/test-history.service.ts• L51-79 apps/…/test-history.service.ts• L92-145 apps/…/test-workbench.tsx• L49-91 apps/…/test-workbench.test.tsx• L132-165 apps/…/test-workbench.test.tsx• L210-224
Product workflow
Web workbench
The web application exposes testing through a test drawer in the context editor. Engineers can inspect the suite, search and filter tests by tags or owners, select a scope, edit and validate a test file, choose run settings, start a production or comparison run, run only the current changes, and open a run's details beside the test.
The drawer supports a single edited test, a selected group, or the full suite. Its run bar shows active progress and cancellation, while test tabs keep individual workbench views available. The suite view shows latest and run outcomes, including tests where models disagree. Comparison actions can use the project branch or a selected upstream branch. See Test runs and results for run orchestration, stored outcomes, comparison calculations, and detailed result inspection.
References: apps/…/test-drawer.tsx• L49-78 apps/…/test-suite-panel.tsx• L55-117 apps/…/test-workbench.tsx• L39-95 apps/…/test-run-results.tsx• L46-114 apps/…/test-suite-panel.test.tsx• L50-121 apps/…/test-suite-panel.test.tsx• L213-357 apps/…/test-run-actions.test.tsx• L104-255 apps/…/test-run-actions.test.tsx• L275-425
Agent behavior coverage
The agent test set checks the safety and task limits around analytical work. It confirms that agents use only the tools meant for their role, keep file and warehouse reads inside granted areas, apply the right SQL guidance for each connection, and preserve access rules for context fixes and stories.
These checks also cover agent support behavior. They verify that skills expose safe guidance for the available run, onboarding returns control after setup choices, and story tools describe only enabled features. Together they keep the evaluation target aligned with the actions that a real agent may take.
References: apps/…/agent-profiles.test.ts• L28-81 apps/…/agent-profiles.test.ts• L83-140 apps/…/context-fix-collector.test.ts• L12-142 apps/…/dialect-rules.test.ts• L20-126 apps/…/internal-skills.test.ts• L17-151 apps/…/load-skill.test.ts• L37-139 apps/…/onboarding-agent.test.ts• L8-23 apps/…/onboarding-step-tools.test.ts• L16-39 apps/…/storage-tools.test.ts• L47-187 apps/…/story-edit-from-another-chat.test.ts• L47-165 apps/…/story-tool.test.ts• L7-21 apps/…/user-rules.test.ts• L77-120 apps/…/user-rules.test.ts• L122-246 apps/…/user-rules.test.ts• L249-625
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the YAML test schema, the test-file validator, the CLI request schema, and the web run input aligned. A field accepted in one path but rejected in another creates different test contracts.
- Keep verdict and data-diff rules aligned with the stored result details. The result viewer must explain the same comparison that decides pass or fail.
- When model or reasoning-effort selection changes, review model capability controls, attempt totals, concurrency limits, model summaries, verification-model behavior, and comparison labels together.
- When model price sources change, check declared-price precedence and the handling of models with no known price so cost metrics remain honest.
- When context snapshot, draft, or upstream branch handling changes, check that production and alternate-context attempts still use the intended context and pair by test, model, and attempt.
- When test file identity changes, preserve the path and content hash relationship used to mark old outcomes as outdated.
- Keep project data boundaries intact for suite discovery and agent reads. Symlinks or path checks must not expose files outside the project.
- When agent profiles, tool access, skills, user rules, or context permissions change, check both the allowed action set and the access rules used during evaluation. A passing answer must not permit an unrelated edit, read, or story change.
- When warehouse connections or semantic-layer modes change, check that the prompt gives only matching SQL dialect guidance and that evaluation queries still target the enabled data path.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Reference SQL cannot run or returns a result that does not match the test's intended columns | The test fails or reports a misleading data mismatch | Validate the SQL against the warehouse and keep output names tied to value format and unit |
| A test file is invalid in the selected scope | The run does not start | Fix the YAML or select a scope that excludes the invalid file |
| A test has no reference SQL and no assertions | The verdict passes without checking answer quality | Add reference SQL or an action assertion |
| A selected model has no known price | Cost-based ranking cannot show a complete cost value | Declare the model price or treat the cost as unknown |
| A stored model setting does not match the selected model's capabilities | The request may use an invalid or misleading inference choice | Use the model capability controls and normalize settings before the run |
| A test changes after its run | The displayed outcome may describe an older test | Treat the outcome as outdated and run the current file again |
| A run loses its heartbeat or is cancelled | In-flight attempts stop and the run is failed or cancelled | Wait for the active run to settle before starting another run |
| A project test folder or agent read crosses a symlink or path boundary | The suite or agent can read another tenant's files | Resolve and verify opened files inside the project before using them |
| A draft snapshot has no applicable changes | A comparison run is rejected and its temporary snapshot must be removed | Make a supported draft change before starting comparison |
| An agent receives onboarding-only tools outside the onboarding flow | It can request setup actions in an unrelated run or fail to return control at the required step | Scope onboarding tools to the onboarding agent and require a handoff after a choice or form |
| Dialect guidance is added for the wrong connection or leaks when warehouse SQL is disabled | The agent can produce invalid SQL or use the wrong data path | Derive prompt rules from the active connections and semantic-layer mode |
| A tool bypasses file, table, or story access checks | A user can read or change data or stories outside their grant | Resolve paths and story identity before the action and enforce owner, editor, and viewer rules |
| A context fix has no linked repository or replaces content created earlier in the same recommendation | The suggested change cannot be delivered or loses an earlier edit | Require a valid repository target and merge incremental edits into the pending fix |
Key files
| File | Why to read it |
|---|---|
| apps/…/test-run.ts | Defines the shared test, model, context, verdict, and result concepts. |
| apps/…/test-suite.service.ts | Shows how project test files become a validated suite. |
| apps/…/test-runner.service.ts | Describes run planning, context variants, attempts, and persistence flow. |
| apps/…/test-evaluation.service.ts | Connects an agent result to tool checks, reference data, and a verdict. |
| apps/…/test-data-comparison.ts | Defines the data equality and tolerance behavior behind answer checks. |
| apps/…/test-comparison.ts | Defines production-versus-draft change labels. |
| apps/…/test-model-summary.ts | Defines the quality and cost measures used for model comparison. |
| apps/…/provider-meta.ts | Defines the model capabilities that shape valid run settings. |
| apps/…/model-prices.ts | Defines the price sources used for run cost measures. |
| apps/…/test-run.routes.ts | Exposes suite, run, history, draft, and result operations to the web application. |
| apps/…/test-drawer.tsx | Shows the main user entry point for the testing workbench. |
| apps/…/test-suite-panel.tsx | Shows suite search, filters, selection, and outcome views. |
| apps/…/test-run-actions.tsx | Shows how users start, compare, and cancel test runs. |
| apps/…/test-run-results.tsx | Shows how run outcomes, comparisons, and model metrics are presented. |
| skills/…/SKILL.md | States the product guidance for authoring and using an analytical benchmark. |