Case study · Kowane evals
How do you know
the agent is right?
Kowane answers a bank's questions about its own books. The first time I asked it something and the figure was just off from what the data said, and it said it confidently, it hit me. If a bank manager makes a decision off that, they're cooked. And them being cooked makes me more cooked.
What I built
- A LangGraph text-to-SQL agent with schema retrieval from ChromaDB, foreign keys stated rather than searched, and a sqlglot validator with a bounded retry loop
- An eval harness: 34 cases across 14 categories, execution-match scoring, repeat runs for flakiness and a baseline that fails on regressions
- Totals computed in code and quoted by the model, never calculated by it
01
It doesn't look wrong
Sometimes the AI doesn't understand the question, or where you're coming from, and it just confidently answers what it assumes you meant.
Ask what the exposure is on overdue loans and you get a number and a chart. If it joined the wrong table or quietly dropped a filter, you still get a number and a chart. No error, nothing to notice. That's what makes it dangerous.
02
Search for the tables. Don't search for the joins
Which tables matter for “how many customers are overdue” is a judgement call, so that's what the vector search is for. Which tables can actually join isn't a judgement call. It's a fact, so it's never searched for. The foreign keys are given to the model as the only relationships that exist, and the prompt and the validator load them from the same place, so they can't disagree.
The gap I know about: a table that sits between two others, named in neither the question nor the search results. One hop of following the foreign keys fixes it, and it's on my list.
03
Queries that run but don't mean what they look like
Every generated query is parsed properly, not pattern-matched, so things like aliases inside subqueries don't confuse it. A join between tables with no real relationship gets rejected before it runs. The rejection goes back to the model as something it can fix, three tries max, and after that it just says it couldn't.
04
The AI doesn't do the maths
All the calculations happen in the system, in code, not in the AI. The model sees a sample of the rows so it can describe them, but any total is worked out in code and handed to it, with instructions to quote it, not redo it.
Think of it like this. You've got one guy calculating in his head, and another guy punching it into a scientific calculator. Which one are you trusting with a bank's numbers?
AI is the guy calculating in his head. Kowane is the guy with the calculator.
05
Why not just unit tests?
Unit tests check that your app does what someone already decided it should do. They don't tell you what's missing. Evals show you the things you didn't see before, the edge cases unit tests won't catch, and they give you a score, so you know where you are and how to improve.
And whether Kowane answers right depends on the prompt, the schema documents, the validator and the model itself. Any of those can change without a single unit test going red. So the suite runs real questions through the real agent and scores what comes back.
06
Compare the results, not the SQL
Two completely different queries can both be right. So instead of comparing SQL text, the harness runs both the generated query and the correct one, and compares what came back. Row order only counts when the question asked for an order, and numbers are normalised so a decimal and an integer of the same amount match.
The same question takes two paths. Everything interesting happens where they meet.
07
Some answers should be “I don't have that”
Not every case is a lookup. There are joins, negation, rankings, dates, and then the ones I care about most: traps, refusals, safety, and questions the data simply can't answer. Ask about collateral when there's no collateral in the data, and the tempting thing is to sum the loans and call it collateral. An agent that answers everything hasn't passed. It's failed in a way the other cases can't see.
08
People have to believe the results
If the model provider is down or rate-limited, that case is marked broken, not failed. Otherwise someone spends an afternoon hunting a bug that was never there, and after that nobody trusts a red run.
And the number that matters isn't the pass rate. You save a run you're happy with as the baseline, and every run after that tells you which cases went from passing to failing.
09
I don't trust the corrections either
When someone flags a wrong answer, the correction doesn't go straight in. It has to pass the same checks as anything the model writes: read-only, real relationships, and it has to actually run. And it only gets saved if it teaches something the schema can't, like a bank's own slang for an active loan.