Problem
IDinsight built Ask-a-Metric, a WhatsApp assistant that answers questions about a SQL database in plain language for governments and NGOs. The first "simple" pipeline was fast to build but its answers were not accurate enough. Tuning a prompt for one set of questions made another set worse, and the steps were so tightly coupled that every change rippled through the whole chain. A CrewAI agent fixed accuracy but was too slow and expensive for partners to use.
Example from the article: a user asks "How many beds are there in hospitals in Chennai?" and the system must find the right tables and columns, write the SQL and return a readable answer.
Solution in brief
Run an agent on your own questions as an experiment, not as the production system. The agent picks the same steps, tools and prompts every time, so you copy that sequence into a fixed, modular pipeline. This "pseudo-agent" kept the agent's accuracy while cutting response time and cost by about an order of magnitude.
Questions this case answers
- How to turn a slow, expensive but accurate LLM agent into a fixed pipeline that keeps its accuracy at a fraction of the cost and latency
- How to choose the number of steps, the tools and the prompts of a multi-step LLM pipeline when manual prompt tuning on one question set breaks another
- How to get accurate answers from an LLM that writes SQL over a company database?
- How to keep the accuracy of an LLM agent while cutting its cost and response time?
Tools and methods
- CrewAI — open-source multi-agent framework used to build the experimental manager and data-analyst agents.
- FastAPI — Python backend where the pipeline runs.
- Text-to-SQL with an LLM — the LLM writes SQL from the question and schema.
- Pseudo-agent pipeline — fixed multi-step flow that replays the agent's observed steps and prompts.
Google or a one-time email code. No password.
