If an LLM can write SQL, analyze results and recommend actions, what makes its output trustworthy enough to support real business decisions?

Trustworthy agentic BI is not achieved by making language models more autonomous. It requires clear business definitions, reliable data, verifiable queries, restricted permissions, honest uncertainty and accountable human decisions.
A manager asks a perfectly ordinary question:
Which stores lost the most sales last week?
An AI copilot can turn that sentence into SQL, run a query, and return a polished answer. That is genuinely useful. A question that once needed an analyst can now begin in plain English.
There is just one small ✨problem✨
Lost compared with what? The previous week? The forecast? And are we talking about gross sales or net sales?
A query can execute without a single error and still answer the wrong business question. That is the uncomfortable part of bringing generative AI into business intelligence: plausible language and correct arithmetic are not the same thing as a correct decision.
From Predicting Outcomes to Generating Answers
Business intelligence was using AI long before anyone called it a copilot. Data mining and OLAP helped people find patterns; recommendation systems suggested products; machine-learning models scored churn, fraud, and default risk. These systems generally delivered a prediction or an analysis for someone else to interpret.
Large language models changed the interface. Instead of selecting a report or reading a score, we could ask a question and receive an explanation.
The trick is what happens under the hood. An LLM breaks text into tokens, turns them into numerical representations, passes them through attention layers, and predicts the next token. Then it repeats. This makes it surprisingly capable at interpreting messy questions, producing SQL, DAX, or Python, and explaining charts.
But the model does not automatically know today’s transactions, your organisation’s definition of revenue, or how to compute exact aggregates over a huge table. Its confidence is not evidence that those things are correct.
So the tempting plan — paste business data into a prompt and ask the model to figure everything out — has a hidden assumption: that a system good at generating an explanation is also the authority on the underlying facts.
It isn’t.
The LLM Writes the Query. The Database Does the Maths.
Consider the question about stores losing sales. Before generating SQL, a trustworthy copilot needs the database schema, the certified sales measures, known synonyms, relationships, and perhaps examples of correctly answered questions.
Only then should it generate SQL or DAX. The query must be checked for validity, permissions, and cost before the database executes it. The result should come back with the query, so an analyst can inspect how the number was produced.
Notice the division of labour. The LLM handles language and query construction. The database handles joins, filters, and arithmetic. Neither gets to quietly invent what sales means.
That definition belongs somewhere more deliberate.
A Semantic Layer Is Not Optional Business Vocabulary
A semantic layer defines the meaning of the data: certified metrics, relationships, synonyms, and row-level security. If gross margin is a certified measure, the copilot should use that measure instead of assembling its own plausible interpretation from raw transaction rows.
This can sound like extra architecture for a tool that already writes SQL. But consider the alternative. If one question produces gross sales and another produces net sales, the system might look consistent while quietly changing definitions between answers.
Grounding prevents the model from being the sole authority on meaning.
The wider grounding stack includes an experience layer where people ask questions, orchestration that assembles context and calls tools, the semantic layer, a retrieval layer for documents, and the underlying warehouse or lakehouse with freshness checks. The model is one component, not the whole business intelligence system.
Documents need a different kind of grounding. Policies, product documents, and meeting notes are not necessarily rows in a sales fact table. Retrieval-augmented generation, or RAG, makes their relevant passages available when a question is asked.
The details matter. Retrieval must respect document versions and access rights; otherwise, a beautifully cited answer can still be based on an obsolete policy or a document the user should never have seen.
The database supplies the numbers. The semantic layer supplies their meaning. RAG supplies relevant documentary evidence. The model helps connect them, but it doesn’t get to replace them.
A Copilot Answers. A Data Agent Investigates.
Once questions can be grounded, another idea becomes attractive: why wait for someone to ask?
Suppose weekly sales fall below forecast. A copilot can explain the dashboard when prompted. A data agent can monitor the metric, plan an investigation, run read-only queries, inspect stock and promotion data, verify its findings, and prepare evidence for a manager.
That requires more than an LLM. The agent needs a planner, tools such as SQL and APIs, access to certified definitions, memory for relevant context, guardrails on permissions and budgets, an audit log, and a human approver for consequential actions.
Its workflow is not simply think, then do. It is a loop:
Here, act means using investigative tools; it does not mean changing prices or ordering stock without permission. That distinction is easy to blur when an agent can do both.
And before an agent searches for business causes, there is an even less glamorous question it should ask.
Is the data complete?
The Sales Drop That Was Partly a Data Problem
Take an illustrative retail group with 120 supermarkets. On Monday morning, a monitor reports that last week’s sales are LKR 42 million, roughly 9%, below forecast. A read-only agent investigates ahead of an afternoon trading meeting.
The obvious instinct is to look for poor-performing stores, stock shortages, or competitor promotions. Those may matter. But investigating business performance before checking the pipeline risks explaining an error as if it were reality.
The agent’s illustrative breakdown is revealing:
The apparent gap of LKR 42 million can be attributed to the following factors:
- Late POS files (data issue): LKR 18 million
- Stock-outs at Kandy distribution-centre stores : LKR 11 million
- Competitor promotion in Colombo : LKR 7 million
- Rain in Southern Province : LKR 3 million
- Unexplained gap : LKR 3 million
Total apparent gap : LKR 42 million
More than 40% of the reported shortfall came from late point-of-sale files. That portion was a data-freshness problem , not evidence that customers had stopped buying.
The remaining findings point toward business conditions worth reviewing, but even then the investigation leaves LKR 3 million unexplained.
That last line matters. An answer generator is tempted to make a complete story. A trustworthy agent must be allowed to say, this part is not explained by the available evidence. Forcing the causes to add up to a confident narrative would make the report tidier, not truer.
The agent can draft proposed responses. Managers still decide which actions to approve.
Trust Needs Tests, Not Just a Convincing Explanation
A fluent answer can hide a wrong number. A correct number can hide a faulty query that happened to work for one week. And an answer can be both accurate and unauthorised if it exposes information the user was not allowed to see.
So a BI copilot or agent needs more than a demo where The Origami Software Engineer asks three friendly questions and nods along.
It needs to be evaluated against known answers and deliberately awkward questions. Compare numbers with a ground-truth query. Review the generated SQL or DAX and test it on other periods. Repeat and rephrase questions to check consistency. Trace claims to data or citations. Include questions that cannot be answered and check whether the system refuses. Test permissions using users from different roles and regions.
These tests examine six different things: answer accuracy, query correctness, consistency, faithfulness, appropriate refusal, and access and safety. Passing one does not imply passing the others.
The risks are just as distinct. Sensitive data can leak into an unsuitable chatbot. Instructions hidden in a supplier PDF can attempt prompt injection. The model can hallucinate a cause, repeat bias, or invite over-reliance when staff stop checking its work.
The most unsettling risk may be the quiet one: a reassuring summary that filters out the warning.
The investigation into the 2003 Space Shuttle Columbia disaster identified organisational failures alongside the physical damage, including barriers to safety communication and reliance on past successes. Engineers had raised concerns, yet the weak signal was not acted on. An AI summary that treats repeated past outcomes as reassurance could reproduce that kind of decision blinder rather than expose it.
Good business intelligence must make inconvenient evidence visible, not merely make a report readable.
Autonomy Is a Decision Right, Not a Model Feature
It is tempting to respond to every risk by requiring human approval at every step. That is safe in one sense, but it can erase the value of automation. Requiring someone to approve every routine report or stale-data alert gives the human more clicks, not necessarily better control.
The useful distinction is between the volume of decisions and the cost of a wrong decision.
Routine alerts and report delivery can be automated and monitored. High-volume but consequential choices, such as replenishment orders or credit-limit changes within defined thresholds, can be proposed by the system and approved by a person. Major pricing policy, lending strategy, and branch closures deserve direct human judgement, with AI informing the analysis rather than owning the decision.
This does not mean trusting an agent less because it is unintelligent. It means placing authority where its consequences can be accounted for.
Every AI action needs a named owner, an approval rule, a limit, and an audit trail. Permissions can expand as the system demonstrates reliable behavior, but autonomy is earned through evidence, not through how confident its language sounds.
We began with an assistant that could produce SQL from a sentence. We end with something more useful, and considerably more constrained: a system that knows where its definitions come from, checks its data, exposes its working, admits uncertainty, and leaves consequential decisions with an accountable human.
The surprising lesson is that making AI useful for business intelligence doesn’t eliminate the older disciplines of data modelling, information integration, governance, and judgement. It makes them harder to ignore.
That’s not failure.
That’s evolution.
The “I liked this” Starter Pack:
Don’t let your fingers get lazy now.
- Like : It tells me this was worth writing.
- A Comment: Tell me your thoughts, your favorite snack, or a better title for this blog.
- Boost it: Especially with that one developer who definitely needs this.
Thanks for being here. It genuinely helps more than you know!
— Aaroophan Varatharajan
Find me elsewhere:
- Professional stuff: linkedin.com/in/Aaroophan
- Code stuff: github.com/Aaroophan
- UI stuff: aaroophan.dev/Aaroophan
- Life stuff: instagram.com/Aaroophan
![flowchart TD Q(“Which stores lost the most sales last week?”) → C[“Gather schema, certified metrics, synonyms and examples”] C → L[“LLM generates SQL or DAX”] L → V{“Valid and permitted query?”} V →|Yes| D[“Database executes the query”] V →|No| X[“Clarify or reject”] D → O[“Return result and query”] classDef C fill:#EAF1FF,stroke:#6495ED,stroke-width:8px,color:#172B4D,padding:1px 250px classDef Q fill:#FFF4DB,stroke:#D69E2E,stroke-width:8px,color:#533F13,padding:1px 250px](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkqq76oez5sf8gaasy9md.png)
![flowchart TD P[“Policies, reports and notes”] → C[“Chunk passages”] C → E[“Create embeddings”] E → I[“Index with owner, version and access”] Q[“User question”] → R[“Retrieve permitted, relevant passages”] I → R R → A[“Answer from evidence and cite sources”]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fegj9e7ujtpcbw1fsje8n.png)
![flowchart TD S[“Sense: sales below forecast”] → R[“Reason: check freshness, then decompose”] R → A[“Act: query sales, stock and promotions”] A → C{“Check evidence and limits”} C →|More work needed| R C →|Supported findings| P[“Report to human approver”]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fynl8iuh7dpejmszt1yw1.png)
Top comments (0)