Skip to content
Tino Trangia
Go back

Database Reporting Agent: a multi-agent text-to-SQL pipeline

I built a text-to-SQL reporting agent that takes a natural language question and returns a validated SQL result and summary, reasoning over a 15+ table enterprise database. The pipeline is implemented in LangGraph with a Chainlit front-end and runs against Postgres.

Architecture

The agent is structured as a graph of specialist nodes rather than a single monolithic prompt:

Evaluation

I built an evaluation suite alongside the agent so changes to prompts, retrieval, or the graph could be measured rather than vibe-checked. It covers schema-resolution accuracy, SQL execution correctness, numeric agreement with ground-truth answers, and summary faithfulness. Running the suite on every change made it much easier to tell whether a new prompt actually helped or just moved failures around.

What I’d do differently

The biggest lesson was how much RAG quality dominates final accuracy. Early iterations over-invested in the generator prompt and under-invested in retrieval; swapping in better semantic-layer mappings and tighter few-shot examples moved the needle more than any generator change.



Next Post
Data extraction from fine-tuned LLMs: a replication of a NeurIPS 2025 attack