# How to Test Whether a Text-to-SQL Agent Counts the Right Customers

Use a small, synthetic orders table to catch timezone, duplicate and test-account mistakes before your AI analyst answers real business questions.

By Paras Madan | 2026-12-01


An AI analyst can run valid SQL and tell you that three customers were active in April. Finance can run valid SQL and say two. If they used different timezones or one included test accounts, the database won't flag either result.

[Vuon's November 30 funding announcement](https://www.prnewswire.com/news-releases/vuon-founded-by-stripe-alums-raises-10m-so-ai-agents-stop-getting-company-numbers-wrong-302952854.html) puts a name to that problem. The company uses a catalog to give agents the business definition and a separate check to compare their SQL with it. You can test the underlying idea without using Vuon or connecting a model to your warehouse.

## Write the definition before the prompt

Use one business question: “How many active customers did we have in April 2026?”

For this example, an active customer is a distinct external customer with at least one completed order in April in Asia/Kolkata. Cancelled and test orders don't count. Assume the table stores order timestamps in UTC. April starts at March 31, 18:30 UTC, inclusive, and ends at April 30, 18:30 UTC, exclusive.

Put that definition somewhere the team can review independently of the agent prompt. A [semantic layer](https://docs.getdbt.com/guides/sl-qs) can do this across tools; a reviewed metric file is enough to start the test.

## Use data that catches plausible mistakes

All rows here are synthetic. The timestamps are UTC strings in one sortable format, so you can also try the reference on local SQLite.

| Customer | Timestamp (UTC) | Status | Test order |
| --- | --- | --- | --- |
| A | 2026-03-31 18:29:59 | completed | 0 |
| A | 2026-03-31 18:30:00 | completed | 0 |
| A | 2026-04-01 10:00:00 | completed | 0 |
| B | 2026-04-30 10:00:00 | completed | 0 |
| B | 2026-04-30 18:29:59 | completed | 0 |
| C | 2026-04-30 18:30:00 | completed | 0 |
| D | 2026-04-15 09:00:00 | completed | 1 |
| E | 2026-04-16 09:00:00 | cancelled | 0 |

Assume an `orders` table with columns `customer_id`, `ordered_at_utc`, `status` and `is_test`. Here's a reference query for that fixture:

```sql
SELECT DISTINCT customer_id
FROM orders
WHERE status = 'completed'
  AND is_test = 0
  AND ordered_at_utc >= '2026-03-31 18:30:00'
  AND ordered_at_utc < '2026-04-30 18:30:00'
ORDER BY customer_id;
```

The expected result is exactly A and B. Switching to an April UTC calendar admits C, and counting completed external order rows in the correct window gives four. The boundary rows show you which assumption changed.

## Compare three setups

Keep the model, data and question fixed. Give it the schema alone, then give the same model the versioned metric definition. In the third setup, independently check the returned IDs and count before accepting the answer. Use a read-only local database for the fixture and review any generated query before execution.

Save generated SQL and the answer separately. A correct count with the wrong IDs fails the test, as does correct SQL followed by an incorrect summary. Add a version of the prompt that says “customers who had a completed order” to check whether a wording change sends the agent back to a different definition.

## Keep the pass condition outside the model

Have a metric owner review and bless the expected result. Don't let the model under test write its own answer key. In later fixtures, add real business complications using synthetic rows, such as a refund or duplicate customer record, then check the same answers again when you swap models or change the catalog.

[Vuon's benchmark](https://vuon.ai/benchmarks) is vendor-reported and uses 93 questions on synthetic BigQuery data. It compares a combined catalog-and-checker setup against a schema-documented baseline, so it doesn't isolate the effect of checking. The fixture above is a way to find out what breaks in your own definition, rather than borrowing a benchmark score.

I'm Paras. I can help you turn a data-agent demo into a test your data team can sign off on. [Book a 30-minute call](https://cal.com/paras-madan/30min).
