r/SQL • u/Extreme-Soil-3800 • Aug 25 '26
Discussion How are folks QA’ing AI agents?
Lots of folks at my company use Claude Code to do analysis. When I ask whether the query is right, I get wishy washy responses at best. Anybody have good tools or processes? Or every person for themselves?
10
Upvotes
42
u/Rumborack17 Aug 25 '26
I mean how do you QA manual written SQL Queries/objects? And why do you need a different process for AI written ones?
11
u/mikethomas4th Aug 25 '26
Read it?
AI isn't inventing a new language, its coding in SQL. Just read it and see what its doing. This is an odd question.
9
u/fauxmosexual NOLOCK is the secret magic go-faster command Aug 25 '26
I think you're asking the wrong question: your agents should be querying semantic models, really the only way to solve this is to make sure the agent is using a nearly bulletproof model with fixed definitions and measures, and doing iterative improvements as you check what is/isn't working and build out libraries of skills or a knowledge base for the agent to use. Getting it to do raw SQL to run without QA is not going to be reliable.
16
u/Thefuzy Aug 25 '26
SQL QA has been a joke long before AI
6
u/Large_Hedgehog2416 Aug 25 '26
Create a code review skill
Have your coding standards as steering files
Use your code-review skill to review the code against your coding standards?
3
u/Upper-Raspberry4153 Aug 25 '26
What do you mean, I just put ‘don’t mess up’ at the end of all my prompts.
2
u/decrementsf Aug 25 '26
Along side new tools drill fundamentals the slow boring way enough to also build intuition for QA. We are all supervisors and perform technical review now.
2
u/shougaze Aug 25 '26
It’s sql
2
u/vintagegeek Aug 25 '26
I know my data, and I usually know when something is off. I never ask for UPDATE or DELETE queries from Claude EVER. Display only, and then I check what's being displayed for accuracy. Never take it at face value.
2
u/reditandfirgetit Aug 25 '26
I went throught this about 2 months ago. New agent, customer facing. For ours, the dev created an MCP that uses existing APIs and is narrowly focused to a specific set of tools
2
u/ArielCoding Aug 25 '26
Layer it: automated checks block for obviously dangerous stuff (like a DELETE with no WHERE clause) before it can run, then test on staging copy, and a human reviews anything that changes data.
3
u/az987654 Aug 25 '26 edited Aug 25 '26
Evaluate the output, is it what you expect?
You know, do your job the same way you did before you had AI write a query.
1
u/kiwi_bob_1234 Aug 25 '26
Keep code changes small like you would with a normal PR
1
u/Prestigious_Bench_96 Aug 25 '26
(Depressingly?) domain knowledge has become the primary safeguard - given the failure modes of agents they are reasonably good at ironing out inconsistencies and syntax issues; so - an analysis that spans multiple queries is usually off more in a fundamental miss on data source, business context, etc.
You can make this more systemic with some reference outputs to benchmark queries against.
1
u/konoo Aug 25 '26
Easy ask the AI to do it!
lol is joke...
1
u/MatsuDano Aug 25 '26
At my current employer, the way is to restrict who has access to agents and restrict even further who can submit merge requests.
A tool is only as good as its wielder. People should not be presenting as fact information that they cannot understand.
1
u/aardw0lf11 Aug 25 '26
Check the results it gives you without using AI assistance. If something in the results doesn’t look right then it probably isn’t. Being able to recognize that when it happens (because it WILL) is going to be an important skill to have for the foreseeable future.
1
u/Fine-Ad-1732 Aug 26 '26
Ja fiz alguns exercícios onde após terminar minhas analises pedi p o Claude fazer a analise por ele, brifando o que eu queria, e ele consegue ser mais amplo e pensar em coisas que eu não falaria ali mas porque eu teria o contexto que ele não tinha, mas foi boa a experiencia porque os mesmos valores que eu calculei no meu exercício ele também apresentou, então minha experiencia tem sido boa porem tem que conferir o que ele faz eu também ja vi ele errar.
1
u/groversnoopyfozzie Aug 26 '26
Ever heard the phrase,” Can’t see the Forrest for the trees?” I find that using AI to thin the trees helps to comprehend and edit the rest of the project.
1
u/mschmitt1217 Aug 26 '26
More of a data governance issue than anything else. These type of questions should have been answered upfront and only "certified" datasets used in analysis. If the data is clean, then you would be having the same exact issues if they didn't use AI and just created their own queries.
1
u/ProfessionalDirt3154 Aug 26 '26
An agent is - mutatis mutandis - same as a junior to mid dev. What do you expect when you ask the same question of one of the humans? You should expect ~same from the AI. Or, if you're letting junior/mid manage junior/mid you have problem analogous to A people hire A people, B people hire C people. And if you're allowing someone to do stuff they can't explain, no matter how they did it, that's another different problem again.
1
u/HercHuntsdirty Aug 26 '26
1
u/theseyeahthese #TempTables ally Aug 25 '26
AI is pretty good at accelerating QA as well. The trick is to not just ask “does this query look right”, you have to come up with the conceptual test cases that you want to verify given your knowledge of the requirements. Then, explain those requirements, test cases, and schema to the AI, and it can help you very quickly generate relevant test data as insert statements, as well as the expected result given that test data + the requirements. Run the test data insert statements, run the actual query against it, and compare the actual query result vs the expected result.
As long as you specify the requirements yourself and don’t provide it with the actual query ahead of time, it can’t “cheat” by using the actual query as the source of truth.
Once you get into a groove as to how to do this, you can find ways depending on your sql software and your team’s workflow to build a “library” of these QA checks for regression testing, and then ultimately automate the running of them on some schedule if you wanted.
0
u/murdercat42069 Aug 25 '26
Here's the fun thing, they aren't!
-1
u/FinickySerenity Aug 26 '26
Claude can run an explain query and analyze the results. This is not a serious question.