Back

Teaching a data agent the rules of the data.

A life-sciences team wanted its researchers to ask plain-English questions of real-world oncology data and get patient counts back. Most of the time the agent got them right. When it was wrong, nothing about the answer said so.

DOMAINReal-world data · HEOR
OUR ROLEDesign and build
DATALicensed oncology data products, inside the client’s own warehouse
STATUSAgent built; safeguards tested on synthetic data
2 → 16
Questions right out of 16 once the agent was given checked rules instead of bare column names
14
Wrong answers in the first round that came back with no error at all
yes ≠ True
One mismatch between a vendor manual and the data made whole queries return zero
600
Synthetic patients and 16 questions, with every right answer known in advance
TRY IT · BREAK THE AGENT, THEN FIX IT

Pick a question, then change what the agent is given. These are the real results from our test on synthetic data.

How many breast cancer patients are in the dataset?
AGENT ANSWERED440
CORRECT ANSWER384
VERDICTWrong, and no error shown

It also counted patients found only through insurance claims codes, and patients whose breast cancer was not their primary cancer.

WHAT WE DID
01
Read the sources

Each licensed data product comes with a data dictionary and a usage manual. We read both and turned them into short, single-statement rules, each pointing back to its page.

02
Test every rule against the data

Before a person approves a rule, it is run against the real tables. Do the columns exist? Do the values match what is stored? Is it really one row per patient? This step is where the disagreement between the manual and the dictionary over values like yes and True turned up.

03
Give the agent only what is approved

For each question the agent gets the approved rules and the real column values for the tables it needs, and nothing else. A query that returns zero rows goes back as a failure, not as an answer.

Writing the SQL was never the problem. The agent did not know how this particular dataset records things: which values mean yes, which dates count, which rows to leave out. Once it did, 16 of 16 test questions came back right, with no retries.