Database AI Agents: The Read-Only Rule

Fourth in a series on Ai and databases.

What Read-Only Advisory Actually Means

A read-only advisory system does exactly two things: it observes and it recommends. It never acts.

It can tell you a database is in a suspect state. It cannot attempt to recover it. It can tell you a backup chain is broken. It cannot re-run the job. It can identify that a transaction log is growing uncontrollably. It cannot intervene. That boundary is not a limitation. It is a deliberate design decision — and arguably the most important one when building AI for production database environments (in my opnion).

Why It Matters

Production SQL Server instances serve real applications, real users, and real business processes. A wrong action — even a well-intentioned one — can cause an outage, breach compliance, or trigger a recovery scenario nobody wanted. The only rational starting point is observation and recommendation. Let the DBA decide. Let the DBA act. The agent’s job is to make that decision faster and better informed — not to make it for them.

Trust Has to Be Structural

A trustworthy diagnostic agent is built so that the boundary between observation and action is not a setting, a configuration flag, or a prompt instruction. It is structural.

The agent should be architecturally incapable of writing to user data, running DDL, killing sessions, or executing any SQL it generated itself. Not because it has been told not to. Because the capability simply does not exist in the design. That means read-only diagnostic queries only. Pre-approved, version-controlled, human-reviewed. No runtime SQL generation reaching a cursor. The agent reasons over what it observes and hands a recommendation to a human. The human decides what happens next.

That is the only posture that earns enterprise trust — and it should be non-negotiable for any AI system pointed at a production database.

Why Database AI Agents need Layers?

Third part in my Ai series with databases.

When building AI solutions within the database realm the first thing that people do is a straightforward concept, connect the LLM endpoint to a SQL backend let it run queries and become a LLM wrapper.  It works for demos, fails in the real world.

Why is this pattern bad? Couple of reasons – It generates adhoc SQL, the model decides what it wants to code and how to query and parse the data back.  It’s a context window killer. Do you know how heavy the RAW result sets on a msdb query are when you have hundreds of jobs? I have seen token budgets get eaten up very fast. Probably the worst thing without any form of control is the hallucination connection. The model, whether Claude or GPT will absolutely make a casual link between a failed job to a breached backup RPO even when there is no link – I have even asked it why it did that it replied, apologies I just linked the two.  Most importantly, it’s a security issue. Imagine you  are sending back and forth sensitive metadata about key objects within your database system its massive area of concern.

Defence Layers

Architecturally I design to four layers to address these problems to provide a secure confident experience, these are – Entry layer, Context layer, Tool layer and the validation layer.

Each layer is a guardrail that doesn’t depending on the mood of the LLM. The model can’t run dangerous code because it never writes TSQL. It cannot flood the context window because of tool contracts, and it cannot link 2 things together just because it feels like it due to validation layer.

Key design principle?  Guardrails must be structural – NOT behavioural.

The trade off is complexity, this isn’t a something you can design and build in couple of days but how do you build trust if you don’t? The effort is absolutely needed.

AI Insights for Database Monitoring: A DBA’s Perspective

Second in a series on Ai and databases.

One Story, three signals – I have a backup of a critical database that has failed three times, the recovery point objective has been breached, the transaction log has a LOG_REUSE state I seem to have failed SQL agent jobs too. Monitoring tools could / should pickup these alerts but I still have the decipher everything. At 2am I could do with some help.

During these callouts there are many thoughts on my mind – are the databases ok (online and readable)? what’s going on in the error logs? Any issues with overnight agent jobs? Are the logs growing out of control – where are these errors coming from, these are basic DBA 101s but together they form a picture. An agent in this world forms a hypothesis after it understands the first signal, tests it with another one and connects the dots based on evidence – we don’t want the LLM to start fabricating things, do we?

Comparing to traditional monitoring tools / scripts it is the same input data but completely different output – not just what but why.

Databases and AI Agents

As part of my wider work exploring Claude Code and AI-assisted database engineering, I have been looking at how AI can support SQL Server operations.

A failed job, missed backup, full transaction log or blocking issue can quickly become business-critical. In that environment, AI needs more than good answers. It needs control.

Personally there are 4 keys things I look for when designing database centric agents.

Evidence Before Opinion

Generic AI can explain SQL concepts, but real triage needs evidence:

  • What was checked?
  • What was found?
  • How confident is the result?
  • Did it just make something up ?
  • How did it get to the conclusion?

Without evidence, AI becomes another source of risk and uncertainty, DBAs don’t like either.

Guardrails Before Automation

A proper database agent should work through approved diagnostic paths, controlled tools and clear boundaries.

Early systems should focus on read-only checks, structured outputs, validation and human review. Do I really want a fully agentic agent with sub agents loose on my live systems ? Nope !

Audit Trails Build Trust

For enterprise teams, auditability is essential.

Every diagnostic step, tool call, result and recommendation should be traceable. So if the agent tells me that my recovery pending database isn’t that bad of an issue I want to know why it thinks that. I want to see its thinking process and its end conclusion.

The Human Stays in Control

AI should not replace DBAs. It should help them reduce noise, triage faster and focus on higher-value decisions. Who knows in the future but right now, I have the final say not Claude.

The Agent Era: When “How do I…?” Replaces “Where do I click?”

After couple of years getting to grips with how we will use AI within the tech space I have been building basic chatbots, RAG systems and moving into agentic AI – I am placing a bet: agents will become the default interface for most knowledge work.

Continue reading