Beyond Basic NLQ: Engineering Self-Correcting Data Agents with Oracle Select AI
How we built a system that verifies its own work to deliver data answers you can trust.
Natural Language Queries (NLQ) are no longer a novelty; asking systems "What were our total sales last quarter?" is becoming standard. The real challenge? Ensuring the answer is accurate, relevant, and derived from a true understanding of the user's intent. Simple Text-to-SQL often falls short, lacking the context and reasoning to handle ambiguity.
That’s why my colleague, Shahvaiz Janjua , and I moved beyond simple Q&A. We've focused on an agentic approach: building an intelligent system that doesn't just execute a query, but autonomously reasons about, verifies, and refines its own work until the result is correct.
At the core of this powerful architecture are Oracle solutions. We leveraged the capabilities of OCI GenAI services along with Oracle Autonomous Database 23ai and its native Select AI feature. For rapid demonstration purposes, we orchestrated the agentic logic using LangChain and built a simple UI with Gradio.
The True Innovation: An Agentic, Self-Correcting Workflow
Instead of a one-shot query, our system employs a cognitive loop, ensuring you get a reliable answer, not just a fast one.
Here is a visual breakdown of how this cognitive loop functions:
This structured reasoning makes the system robust and trustworthy, moving past the brittleness of basic NLQ.
The Powerhouse: Oracle's Data and AI Foundation
Want to dive deeper and see how to enable Select AI here?
Recommended by LinkedIn
From Prototype to Production: The Road Ahead
While LangChain and Gradio were excellent for building this proof-of-concept, the goal is an enterprise-grade, Oracle-native solution. Our next step is to evolve this architecture by:
Conclusion: A New Era of Trust in Conversational AI
By combining the native data intelligence of Oracle's Autonomous Database with a sophisticated agentic framework, we unlock a new level of reliability in conversational AI. This moves us past the novelty of Text-to-SQL and into a new era where we can build data analysis tools that we don't just use, but that we can fundamentally trust.
Try It Yourself
We believe in building in the open and encourage you to explore this architecture. We have published a sample implementation on GitHub that demonstrates the core agentic workflow, integration with OCI GenAI and Select AI, and the question refinement logic discussed in this post.
Access the complete code here: 🔗 https://github.com/mrakulji/agentic_selectai
About the Authors:
Thanks for sharing, Mirjana
Simple but very smart! I was also impressed how you applied this to a Clinical Data Warehouse to enable Natural Language Scientific Queries directly into the database, potentially making a significant number of complex and expensive downstream systems obsolete! Great work Mirjana Rakuljic and Shahvaiz Janjua
You've been officially "cited" 😁 (https://www.garudax.id/pulse/natural-language-querying-clinical-data-key-learnings-sarah-jamal-vyd4f ) Excellent job, Mirjana Rakuljic and Shahvaiz Janjua. I'm so proud to see your progress on this 👏
Thanks for sharing, Mirjana
Principal AI Architect @ EMEA AI Center Of Excellence
10moThat's really cool to see how you're using SelectAI and GenAI together. Love how it makes querying data so much easier and more accurate!