InsightMesh: A Multi-Agent Business Intelligence Engine
Inspiration
We've all been there - sitting in a meeting when someone asks, "How many employees do we have by department?" and suddenly you're 20 minutes deep into Excel filters or waiting for a data analyst to run a query. Business intelligence shouldn't require a degree in SQL or hours of dashboard configuration.
The inspiration for InsightMesh came from watching non-technical stakeholders struggle with traditional BI tools. They have brilliant questions about their business, but the tools demand they learn complex query languages or navigate convoluted dashboard builders. We asked ourselves: What if you could just ask your data a question, like you'd ask a colleague?
With Claude's advanced reasoning capabilities and the power of multi-agent orchestration, we saw an opportunity to build something that bridges this gap - making enterprise data accessible through natural conversation.
What it does
InsightMesh transforms natural language questions into actionable business insights with both textual analysis and interactive visualizations. Users simply type questions like:
- "Show me employee distribution by gender"
- "What's our headcount by job position?"
- "Plot revenue trends for Q4"
Behind the scenes, a coordinated team of specialized AI agents powered by Claude APIs:
- Interprets the user's intent - Understanding what they're really asking, even with ambiguous phrasing
- Generates accurate SQL queries - Converting natural language to precise database operations
- Analyzes the results - Providing context and insights beyond raw numbers
- Creates visualizations - Automatically selecting and generating the most appropriate charts
- Handles errors gracefully - Re-attempts queries with corrections when issues arise
The system provides transparency by showing its reasoning process, so users can trust and understand how insights were generated.
How we built it
Architecture
We implemented a streamlined multi-agent architecture using Claude's API, where three specialized agents work in harmony:
Orchestration Agent: Acts as the intelligent coordinator that understands user intent, decides which agent to invoke, manages the workflow between agents, and ensures smooth information flow throughout the pipeline
SQL Query Generation Agent: Converts natural language questions into optimized SQL queries, handles database schema understanding, implements error correction when queries fail, and ensures syntactically and semantically correct database operations
Response Agent: Processes query results to generate insights, creates contextual explanations beyond raw data, selects and generates appropriate visualizations (bar charts, line graphs, etc.), and formats responses for maximum clarity
This lean three-agent architecture proved more efficient than complex multi-agent systems, with clear separation of concerns: orchestration, data retrieval, and insight generation.
Tech Stack
- Frontend: Streamlit for rapid prototyping of an intuitive chat interface
- AI Engine: Claude API (Anthropic) for natural language understanding and code generation
- Data Processing: Pandas for data manipulation, SQL for database queries
- Visualization: Matplotlib and Plotly for interactive charts
- Backend: Python with SQLite for the demo database
Development Process
- Started with a simple question-answer loop
- Added SQL generation capabilities with
COUNT()andDISTINCT()for accurate aggregations - Implemented error handling with automatic retry logic
- Built the multi-agent coordinator to orchestrate specialized tasks
- Created the visualization layer that automatically selects chart types
- Developed the Streamlit UI showing both chat history and visual outputs
Challenges we ran into
1. SQL Generation Accuracy
Early iterations would generate syntactically correct but semantically wrong queries. For example, when asked "number of employees by gender," it would initially use COUNT(DISTINCT EmployeeID) which gave incorrect results when grouping.
We solved this by:
- Creating more specific prompts with example schemas
- Implementing validation checks on query structure
- Adding a feedback loop where errors inform the next attempt
2. Error Recovery Without Infinite Loops
When queries failed, we needed intelligent retry logic that wouldn't just keep making the same mistake.
We built error handling that:
- Parses error messages to understand the root cause
- Modifies the approach rather than just regenerating
- Implements a maximum retry limit with escalation
3. Context Management Across Agents
Each agent needed relevant context without overwhelming Claude's context window.
We implemented:
- Selective context passing (only sending what each agent needs)
- Result caching to avoid redundant processing
- State management to track conversation history
4. Visualization Selection
Determining the right chart type automatically was tricky. A bar chart for gender distribution makes sense, but time series data needs line charts.
We built logic that analyzes:
- Data dimensionality (categorical vs continuous)
- Query intent (comparison vs trends vs distribution)
- Number of data points (aggregate vs detailed views)
5. Real-time Response Balance
Balancing between fast responses and thorough analysis required optimization:
Our approach:
- Streaming responses where possible
- Parallel agent execution for independent tasks
- Caching frequently accessed data patterns
Accomplishments that we're proud of
Built a working multi-agent system that genuinely demonstrates how specialized AI agents can collaborate to solve complex problems
Achieved high query accuracy - Our system correctly handles grouping, aggregations, and joins that often trip up basic NL-to-SQL systems
Intelligent error recovery - The system doesn't just fail when something goes wrong; it learns from errors and adapts its approach
Automatic visualization selection - Users get the right chart type without specifying it, making insights more accessible
Transparent reasoning - Unlike black-box BI tools, users can see how their question was interpreted and executed, building trust
Hackathon-complete MVP - In limited time, we built something that actually demonstrates real business value, not just a proof of concept
What we learned
Technical Learnings
Prompt engineering is critical: Small changes in how we structured prompts to Claude dramatically affected SQL generation accuracy
Agent specialization > general purpose: Having focused agents (one for SQL, one for visualization) outperformed single-agent approaches
Error messages are valuable training data: Parsing and learning from errors made our retry logic much smarter
State management complexity: Coordinating multiple agents while maintaining conversation context is harder than it looks
Product Learnings
Users want transparency: During testing, people trusted insights more when they could see the reasoning process
Natural language is ambiguous: The same question can mean different things in different business contexts - domain knowledge matters
Visualization matters as much as accuracy: A correct answer presented poorly is less useful than a good visualization
Claude API Insights
- Claude excels at understanding nuanced business questions
- Its code generation is remarkably accurate when given proper context and schema information
- The API's consistent performance makes it reliable for production-grade applications
- Structured outputs help maintain coordination between agents
What's next for InsightMesh: A Multi-Agent Business Intelligence Engine
Immediate Roadmap
1. Multi-database Support
- Currently works with SQLite; expanding to PostgreSQL, MySQL, Snowflake, BigQuery
- Universal connector architecture for plug-and-play database integration
2. Conversational Follow-ups
- "Show me the same data for last quarter"
- "Break that down by department"
- Maintaining context across multi-turn conversations
3. Custom Agent Training
- Allow organizations to train agents on their specific business logic
- Domain-specific terminology and metric definitions
- Company-specific data relationships and hierarchies
4. Advanced Visualizations
- Interactive dashboards that users can drill into
- Comparative analysis across time periods
- Predictive trend lines and forecasting
Long-term Vision
5. Collaborative Intelligence
- Multi-user sessions where teams can explore data together
- Annotation and insight sharing
- Automated report generation from conversation history
6. Proactive Insights
- Agents that monitor data and surface anomalies automatically
- "You usually have 10% more sales in Q3, but this year it's down 15%"
- Scheduled insight delivery based on user interests
7. Integration Ecosystem
- Slack/Teams integration for insights in workflow
- API for embedding InsightMesh into existing applications
- Webhook support for automated workflows
8. Security & Governance
- Role-based access control for sensitive data
- Audit logging of all queries and insights
- Data anonymization for sensitive fields
- Compliance with GDPR, HIPAA, SOC 2
The Ultimate Goal
Transform InsightMesh from a hackathon project into a production-ready platform where every employee becomes a data analyst. No SQL required. No dashboard building. Just questions, answers, and insights - powered by Claude's intelligence and multi-agent orchestration.
We envision a future where business intelligence is as simple as having a conversation, where data democratization isn't just a buzzword but a reality, and where the barrier between questions and insights disappears entirely.
Want to try InsightMesh? Check out our demo and let us know what business questions you'd ask your data!
Log in or sign up for Devpost to join the conversation.