The Unified 'Corporate Brain': Orchestrating SQL and Text with Agents
There’s a frustration I hear from almost every executive.
In a board meeting, someone asks a simple, reasonable question:
“Why did our profit margin drop in Q3?”
Answering it is anything but simple.
First, someone opens a PowerBI dashboard to confirm what happened (structured data).
Then, emails go out to department heads to understand why it happened (unstructured context).
Then, someone digs through PDFs or incident reports from the supply chain team.
The executive ends up acting as a human translator—bridging SQL on one side and documents on the other.
Enterprise AI was supposed to eliminate this friction. Instead, many organizations ended up with two disconnected solutions:
- Text-to-SQL chatbots
- Document chatbots (RAG)
The future of Enterprise AI isn’t choosing between these two.
It’s building a Unified Corporate Brain—a system that speaks both languages fluently.
Here’s how to architect a Supervisor Agent on Databricks that orchestrates SQL and text into a single, coherent answer.
The Data Silo Problem
Every organization’s knowledge lives in two hemispheres.
The Left Brain (Structured)
ERPs, CRMs, transaction logs. Precise, numerical, and stored in tables.
The Right Brain (Unstructured)
Emails, PDFs, incident reports, strategy documents. Nuanced, narrative, and stored as vectors.
LLMs can sound confident in both worlds. But sounding right isn’t the same as being right—especially when math is involved.
The solution isn’t forcing one model to do everything.
Instead, we build a compound AI system: specialized tools for each data type, coordinated by a Supervisor that knows when—and how—to use them.
The “Supervisor Agent” Pattern
At the center of the architecture is a single orchestrator: the Supervisor.
Its role is simple but powerful—delegate work to the right specialist.
Tool A: The Analyst (Structured Data)
For questions like “How much,” “When,” or “Compare,” we rely on SQL-native tools. On Databricks, there are two strong options:
- Unity Catalog Functions
- Databricks Genie
Tool B: The Researcher (Unstructured Data)
For questions like “Why,” “How,” or “Summarize,” we use Mosaic AI Vector Search.
It retrieves relevant emails, PDFs, and reports to provide narrative context.
The Code Implementation
The Supervisor Agent—implemented with a framework like DSPy or LangGraph—acts as the router.
It decides which tool to call based on the user’s intent, and when to combine results.
def tool_genie(question: str) -> str:
"""
Use Genie for KPI/SQL asks (metrics, time windows, aggregates).
Returns SQL query results and a data preview.
"""
return genie_response
def tool_rag(question: str) -> str:
"""
Use the Vector Search KB to answer qualitative questions.
Returns narrative text with citations.
"""
return rag_response
class AgentQA(dspy.Signature):
"""
You are a Supervisor Agent.
- If the user asks "How much" or "When", use 'tool_genie'.
- If the user asks "Why" or "How", use 'tool_rag'.
- If the user asks BOTH, use BOTH tools and synthesize the answer.
"""
answer: str = dspy.OutputField()
The code isn’t the point.
The architecture is.
The Scenario: Anatomy of an Answer
Let’s return to the boardroom question:
“Why did sales drop in Q3?”
When this query reaches the Supervisor Agent, it doesn’t guess. It executes a plan.
Reasoning
“I need to confirm the drop (data) and understand the cause (context).”
Action 1 — Structured
tool_genie("Show total sales decline Q2 vs Q3 2024")
Observation
Genie runs SQL against the ERP.
Result: Sales dropped by $2.4M (12%).
Action 2 — Unstructured
tool_rag("Reasons for Q3 2024 sales performance")
Observation
Vector Search retrieves the Q3 Supply Chain Incident Report.
Finding: Shipments were delayed due to the August port strike.
Synthesis
The Supervisor combines both signals into one answer.
Final Output
“Sales dropped by $2.4M (12%) in Q3 compared to Q2.
This decline correlates with the August port strike, which delayed inventory shipments by three weeks
(Source: Q3 Supply Chain Incident Report).”
This is the real goal of enterprise analytics:
quantitative facts explained by qualitative context.
Unified Governance via Unity Catalog
At this point, every CISO asks the same question:
“If we connect AI to our data, what stops it from dumping the payroll table?”
The answer is governance—built into the platform.
We don’t give agents access to raw data.
We give them access to governed Unity Catalog functions.
RETURNS TABLE
RETURN
SELECT * FROM revenue
WHERE region = get_sales_metrics.region;
The agent’s service principal receives EXECUTE permission on this function—nothing more.
Even if the LLM tries something reckless, the data platform enforces the boundary.
The agent is sandboxed by design.
Managerial Takeaway: Compound Systems Beat Chatbots
The era of the simple chatbot is ending.
The systems that win are compound AI systems—combinations of:
- structured analytics,
- unstructured retrieval,
- and intelligent orchestration.
So stop asking:
“Which model should we use?”
Start asking:
“How do we connect our structured truth with our unstructured context?”
When you get that right, you stop building demos.
You start building a real Corporate Brain—one that answers the questions that actually matter.
Comments
Post a Comment