Accessing and analysing enterprise data typically requires SQL expertise and reliance on data analysts to derive business insights, causing delays and increased costs. These barriers make it challenging for non-technical users to interact with the enterprise data effectively. This paper presents a transformative approach leveraging agent-driven Text-to-SQL solutions powered by fine-tuned Small Language Models (SLMs), Retrieval-Augmented Generation (RAG), and Agentic AI to revolutionise enterprise database interactions. Our key novelty lies in the orchestrated use of specialized agents, each focusing on specific sub-tasks like entity recognition, query decomposition, self-correction, and step-by-step explainable results to achieve high accuracy in complex real-world enterprise settings.
Our solution employs specialized intelligent agents to detect domain-specific entities, resolve ambiguities, and understand enterprise jargon. An Entity Detection Agent enhances context understanding by identifying key entities, synonyms, and acronyms in user queries. The agent decomposes user queries after augmenting them with domain entities to retrieve results from different databases. A Self-Correction Agent refines SQL queries by validating schema alignment, business logic, and query accuracy through iterative feedback loops. An Analytics Agent performs comprehensive analysis on the retrieved data. An Explainable Agent provides step-by-step exploration, helping users understand the query generation process and results. Additionally, interactive agents enable workflows for user clarification and query validation, while visualization and natural language summaries improve result interpretability. The system integrates with enterprise role-based access controls to validate users’ access to relevant databases before generating results. The solution was successfully rolled out in a phase-wise manner to 700 business users of a pharmaceutical company over a 6-month period.
When evaluated on 1,000 business user queries, the agent-driven approach achieved an impressive accuracy of 87% for response generation, reduced SQL query generation effort by 70%, improved data accessibility for non- technical users by 90%, and decreased operational costs by 50%. By facilitating conversational, explainable self-service analytics, this solution enhances data access for business stakeholders. This work highlights the transformative potential of agent-driven approaches in enterprise data ecosystems, offering a scalable, intuitive, and efficient framework for database interactions.