Leomine: A Secure AI Agent that Delivers Trusted Insights from Your Data
Inspiration
Business leaders make decisions at the speed of thought, but enterprise data moves at the speed of IT tickets.
We realized a massive disconnect in corporate environments: Executives constantly have urgent questions ("Why did credit card revenue drop in Q1?" or "Can you plot the bad debt trend?"), but to get answers, they must wait days for the MIS team to manually write SQL, export to Excel, and build dashboards.
While GenAI can write code, giving an autonomous LLM direct access to a bank's core financial database is a security nightmare. Furthermore, executives don't just want raw tables—they want visual insights and the ability to ask follow-up questions.
We asked ourselves: How can we give business users a conversational, state-of-the-art Data Analyst that can securely fetch data, remember context, and draw charts on the fly, without compromising IT security? Leomine was born from the idea that enterprise AI shouldn't force a compromise between autonomy, visualization, and security.
What it does
Leomine is a secure, ReAct-powered AI agent that delivers trusted, visual insights from your data.
Instead of staring at static dashboards, users chat with Leomine in natural language via a Web App, Slack, or Telegram. Powered by the ReAct (Reason + Act) pattern, Leomine doesn't just guess an answer; it iteratively thinks through the problem.
- Agentic Tools & Visualization: Leomine is equipped with a specific toolset. It uses a SQL Tool to fetch data, an Analysis Tool to interpret the numbers, and a Visualization Tool to dynamically generate charts (bar, line, pie) directly in the chat based on the data it just retrieved.
- Contextual Memory: Leomine remembers the conversation. If you ask, "Show me revenue by branch," and then follow up with, "Now filter that for just the VIP segment," it remembers the context and instantly redraws the chart.
- Model Context Protocol (MCP) Layer: Leomine uses an MCP layer to seamlessly plug into disparate data sources. It understands the meaning of the business data via a Semantic Layer without needing to see the raw, sensitive records.
- Absolute Security (Human-in-the-Loop): Leomine never executes database operations blindly. It drafts the SQL and sends it to a "Pending Queue" for a human Data Steward to approve before fetching the payload to draw the chart.
How we built it
We architected Leomine with a strict separation of concerns, balancing a powerful autonomous agent loop with impenetrable backend security.
- The ReAct Agent Brain: We utilized Qwen LLM and orchestrated it using a ReAct framework. We defined strict system prompts and provided it with custom tools (
execute_sql_draft,generate_chart_config,fetch_schema). - Memory & State: We implemented session-based memory so the agent retains conversation history, enabling smooth, multi-turn data exploration.
- The MCP Layer: We engineered a custom Model Context Protocol interface. Instead of exposing raw database tables, the MCP feeds the LLM a curated Data Dictionary, allowing us to connect multiple mock data sources securely.
- Dynamic UI: The frontend is built to render dynamic JSON configurations outputted by the Agent's Visualization Tool into interactive Plotly/Echarts directly in the UI.
- The Security Gatekeeper: Our FastAPI backend explicitly blocks all DML commands (
UPDATE,DELETE,DROP), forces queries through Read-Only views, and completely suspends the Agent's ReAct loop to wait for Human-in-the-Loop (HITL) approval before proceeding.
Challenges we ran into
Our biggest hurdle was taming the ReAct loop. When building an autonomous agent with tools, LLMs sometimes get stuck in infinite thinking loops if a tool returns an error. We had to build robust error-handling mechanisms so that if a SQL draft failed, the agent could "Reason" about the error and fix its own code before asking the human to approve it.
Another major challenge was deterministic visualization. Getting an LLM to consistently output perfectly formatted JSON for charts—matching the exact columns it just retrieved from the SQL database—required highly structured prompting and output parsers.
Finally, balancing the Security vs. Autonomy paradox. Building a Human-in-the-Loop workflow that interrupts an active Agentic ReAct loop required careful backend state management. We solved this by using asynchronous Webhooks to wake the agent back up once the Admin hit "Approve."
Accomplishments that we're proud of
- True Agentic Architecture: We successfully moved beyond basic "Text-to-SQL" and built a reasoning agent that uses tools to fetch, analyze, and visualize data autonomously.
- Enterprise-Grade Security: We proved that you can safely deploy highly autonomous GenAI on top of sensitive financial data by combining MCP abstraction and a seamless HITL approval flow.
- Conversational BI: We are incredibly proud of the Follow-Up Memory feature. Watching the agent instantly pivot a chart based on a casual follow-up question feels like magic and completely redefines the BI experience.
What we learned
We learned that in agentic workflows, tools and strict guardrails are everything. An LLM is only as smart as the tools it has access to and the error messages it receives.
We also learned that in enterprise AI, trust is paramount. Giving an agent the ability to draw charts is amazing, but giving the IT team a "kill switch" and an approval portal is what actually gets the software deployed. Finally, we learned the immense power of combining the ReAct pattern with the Model Context Protocol—it creates a system that is both incredibly smart and universally adaptable.
What's next for Leomine
- Multi-Agent Debates: Introducing a "Reviewer Agent" that double-checks the primary Agent's SQL logic and chart choice before it even reaches the Human-in-the-Loop.
- Expanding the MCP Integrations: Building out the Model Context Protocol to support out-of-the-box connections to unstructured data, allowing Leomine to cross-reference SQL charts with PDF financial reports.
- Proactive Scheduled Agents: Letting Leomine run its ReAct loop in the background via Cron jobs to actively hunt for anomalies and push fully-rendered chart alerts to Slack/Telegram.
- Voice Interface: Integrating voice-to-text so executives can literally just talk to their data while commuting.
Built With
- fastapi
- mcp-tooling
- plotly
- postgresql
- python
- qwen-(llm)
- react
- react-agents
- telegram-&-slack-bots
- typescript

Log in or sign up for Devpost to join the conversation.