Back office ops · Production

IDinsight builds pseudo-agent Text-to-SQL pipeline for WhatsApp-based data access (Ask-a-Metric)

The problem

IDinsight's simple pipeline for Ask-a-Metric produced insufficiently accurate LLM responses, suffered from brittle prompt engineering where improving one query set hurt another, and had a tightly coupled sequential architecture that made iteration slow.

First attempt

The CrewAI agentic pipeline answered all test questions correctly but was prohibitively slow and expensive for production: response times exceeded one minute per query and cost approximately USD 0.3 per query, both well above the production targets of under 30 seconds and under USD 0.03.

Workflow diagram · grounded in source
1
User submits natural language question
trigger
“Ask-a-Metric collects a user's question–say, 'How many beds are there in hospitals in Chennai?'”
2
Identify tables and columns
ai_action
“identify tables, find the best columns, extract sample column values, etc., each as separate steps”
3
Guardrails check
validation
“breaking down the pipeline into different components - processing user queries, guardrails, and tools”
4
SQL query execution
ai_action
“analyzes the SQL database it is connected to”
5
Answer returned to user
output
“synthesize all of it to return an appropriate response”
Reported outcome

The pseudo-agent pipeline achieves response times under 15 seconds and costs below USD 0.02 per query while maintaining accuracy, combining the low cost and quick response time of the simple pipeline with the better accuracy of the agentic approach.

Reported metrics
CrewAI response time per querymore than a minute
CrewAI cost per queryapproximately USD 0.3
Target response timeless than 30 seconds
Target cost per queryless than USD 0.03
Show all 7 reported metrics
CrewAI response time per querymore than a minute
CrewAI cost per queryapproximately USD 0.3
target response timeless than 30 seconds
target cost per queryless than USD 0.03
pseudo-agent response timeless than 15 seconds
pseudo-agent cost per queryless than USD 0.02 per query
CrewAI test accuracyanswer all questions from our test database correctly
Reported stack
LLMsFastAPICrewAILangchainRAGWhatsApp
Source
https://idinsight.github.io/tech-blog/blog/aam_pseudo_agent/
Read source ↗

Frequently asked questions

What did this team achieve with this AI workflow?

The pseudo-agent pipeline achieves response times under 15 seconds and costs below USD 0.02 per query while maintaining accuracy, combining the low cost and quick response time of the simple pipeline with the better a…

What tools did this team use?

LLMs, FastAPI, CrewAI, Langchain, RAG, WhatsApp.

What results were reported?

CrewAI response time per query: more than a minute; CrewAI cost per query: approximately USD 0.3; Target response time: less than 30 seconds; Target cost per query: less than USD 0.03 (source-reported, not independently verified).

What failed first in this deployment?

The CrewAI agentic pipeline answered all test questions correctly but was prohibitively slow and expensive for production: response times exceeded one minute per query and cost approximately USD 0.3 per query, both we…

How is this back office ops AI workflow structured?

User submits natural language question → Identify tables and columns → Guardrails check → SQL query execution → Answer returned to user.