Data Stories
A prototype agent that finds what is worth knowing in a dataset. IBM, 2026.
Suggested questions tell people what they could ask about a dataset. They still have to pick a question, read the answer, think of a follow-up, and repeat until something interesting turns up. I built a prototype to show what could come next: an agent that explores the dataset on its own and returns two or three findings worth acting on, each with the evidence behind it. It was selected for executive review. It is a prototype, not a product feature.
TypeScript · Node.js · LLMs · Agents · SQL · Python · pandas
Why it matters
Suggested questions answer “what could I ask?”. Most people want the answer to a different question: “what should I know?”. Something surprising in the data, such as one region driving most of a loss, rarely shows up on a default dashboard, and finding it takes many rounds of questions.
A finding here is more than one number. It has:
- a headline with a specific number that makes a reader stop;
- a short explanation that connects two or more facts;
- a reason it matters: a decision to make, something to investigate, or a risk.
The problem
- No question to start from. The agent has to decide what to look at, and when it has found enough.
- LLMs are unreliable at arithmetic. Percentages, shares and ratios across many rows are exactly where a model makes mistakes, and a wrong number in a headline is worse than no finding.
- Data does not fit in a prompt. Query results can be far larger than what a model can read at once.
- Findings must be checkable. A surprising claim from an AI is only useful if a person can see how it was reached.
The solution
An agent with a few tools
The agent works in a loop: it picks a tool, looks at the result, and decides what to do next. It has four tools: run a SQL query, analyse a result with Python, propose a finding, and finish. Before it starts, it gets a profile of the dataset: its columns, what they mean, and sample values.
look at the profile → query → analyse → propose a finding → repeat or finish
The tools went through three versions, each moving the arithmetic further away from the model:
| Version | How it worked | What went wrong, or right |
|---|---|---|
| 1. The model does the maths | Query results go straight to the model, which works out the numbers itself | Results had to fit in the prompt, and multi-step calculations were often wrong |
| 2. Fixed statistics tools | The model chooses from a small set of calculations, such as a trend or an anomaly check, which code runs exactly | Numbers were right, but the model could only ask what the tools allowed |
| 3. Python | The model writes short Python analyses, which run on the full result; it only reads the printed output | Exact numbers, and any analysis the model can express |
Every finding comes with its trail
Every step is recorded: the purpose of each query, the SQL, a preview of its result, the Python code and its output. A finding must cite the analyses its numbers come from, and the trail is shown with it. A reader can follow exactly how each number was produced.
Findings must be different from each other
Before a finding is accepted, the agent has to explain how it differs from the ones already found, so the result is not three versions of the same insight.
Knowing when to stop
- Each run has a budget of model calls, queries and time, in a few sizes from quick to deep.
- The run ends when the agent finishes, the budget runs out, or the agent stops making progress.
- Tools never crash the run. A failed query comes back as a clear error the agent can read and recover from, or a nudge to wrap up when the budget is nearly spent.
Running code the model writes
In the prototype, Python runs in a separate process with a time limit. Running code written by a model is a security risk, so a production version would need a proper sandbox, with no network access and strict limits on memory.
Results
On test datasets from different domains, a standard run took about three minutes and returned a few findings, each traceable from its headline back to the queries and analyses behind it. The prototype was selected for executive review.