Notes

Data-Analysis Agent

Ask a language model a question about your sales data and it can only talk about data in general. Give it a Python sandbox and the actual file, and the shape of the problem changes: it can load the table, look at what is really in there, and answer from the numbers. That loop — write code, run it, read the output, revise — is a data-analysis agent.

The working loop
What makes it an agent rather than a code generator is that it sees the result of every step:

  • Profile first — column types, row counts, nulls, the surprise category nobody mentioned.
  • Write a transformation or a query, execute it in a sandbox, and read the error or the output.
  • Correct from what came back: a wrong join key, a date column that arrived as text, an outlier worth asking about.
  • Produce the artefact — a chart, a table, a short written finding with the code that produced it.

Why the sandbox is the whole design
Execution is what converts plausible analysis into checkable analysis; it is also the risk. The agent is running generated code against real data, so the sandbox gets no credentials it does not need, no write access to production, and a time limit. The honest failure mode is not a crash but a confident wrong answer: a silently dropped join that halves the rows, reported as a finding. A trustworthy data-analysis agent shows its working — the query, the row counts, the assumption it made — so the number can be audited rather than believed.

A data-analysis agent is an agent that answers questions about a dataset by writing and executing code against it — profiling columns, running transformations or SQL in a sandbox, reading the output, and correcting itself before reporting a result. Execution is what distinguishes it from a model that merely describes an analysis: the numbers are computed, not recalled. The risk it must manage is a confidently reported figure produced by a subtly wrong query.

Think of a capable analyst you hand a spreadsheet to. They do not answer from memory. They open the file, see that half the dates are stored as text, fix that, run the numbers, notice something odd, check it, and then tell you what they found.

A data-analysis agent is software that works the same way. It writes code, runs it on your actual data, looks at what came back, and corrects course before giving you an answer.

That is the important bit: the answer is calculated from your data, not guessed from what similar data usually looks like. The catch is that a tidy-looking number can still come from a mistake, so good ones show their working.