---
topic: ai-technology
author: Crashtech Editorial
published: Nov 17, 2026 · read: 3 min
---

How OpenAI Built Its Internal Data Agent Across 90,000 Tables

Why OpenAI bypassed complex multi-model routers and fine-tuning, using a single frontier model and rich metadata context to query 1.5 exabytes of data.

– –

At enterprise scale, the hardest part of business analytics is not writing SQL syntax. The hard part is knowing which table out of 90,000 to query, which column represents the true active subscriber count, and which deprecated table stopped updating three months ago.

OpenAI manages over 1.5 exabytes of data across more than 90,000 datasets and tables. When OpenAI’s internal employees ask questions in Slack: such as “What was the week-over-week API token growth for Enterprise tier customers in Europe?”: they rely on an internal autonomous Data Agent.

While many engineering teams overcomplicate AI agents with intricate multi-agent hierarchies, specialized fine-tuned models, and fragile router swarms, OpenAI took the opposite approach: a single frontier model operating inside a strict harness, powered by an exhaustive metadata context layer.

The Pitfall of the Complex Multi-Agent Swarm

When companies attempt to build text-to-SQL agents, they often produce over-engineered architectures:

  • A “Router Agent” classifies the question.
  • An “SQL Specialist Agent” writes candidate queries.
  • A “Critic Agent” reviews the query.
  • A “Synthesizer Agent” formats the final response.

In production, each hop introduces latency, context dilution, and compounding failure probabilities. If the router misclassifies a business term, the downstream agents fail completely. Furthermore, fine-tuning smaller models on SQL syntax usually backfires: SQL grammar is trivial for frontier LLMs, but business domain context (knowing that mrr_v2_final is preferred over mrr_v1) changes weekly and cannot be baked into static model weights.

Architecture of OpenAI’s Data Agent

OpenAI structured the Data Agent as a simple, high-signal loop connecting Slack to their distributed Trino and Snowflake data warehouses.

+-----------------------------------------------------------------------+
|                       OpenAI Data Agent Flow                          |
+-----------------------------------------------------------------------+
|                                                                       |
|  [ Employee Question in Slack ]                                       |
|        | ("What was Europe enterprise API growth last week?")         |
|        v                                                              |
|  [ Agent Harness Orchestrator ]                                       |
|        |                                                              |
|        v                                                              |
|  [ Context Layer: Metadata & Semantic Catalog ]                   |
|        | - Table Schemas & Lineage Graphs                         |
|        | - Curated dbt Metrics & Verified SQL Snippets            |
|        | - Deprecated Table Blacklists                                |
|        v                                                              |
|  [ Single Frontier Model (GPT-4o) ]                                   |
|        | (Receives question + top 5 relevant table schemas)           |
|        |                                                              |
|        v (Emits structured tool call: `execute_sql`)                  |
|  [ Sandboxed SQL Execution Engine ]                                   |
|        | (Trino / Snowflake Query Federation with Read-Only Limits)   |
|        |                                                              |
|        +---> SQL Error? -> Feed traceback into model context (Retry)  |
|        |                                                              |
|        v (Query succeeds)                                             |
|  [ Result Synthesis & Visualization Generator ]                   |
|        |                                                              |
|        v                                                              |
|  [ Post to Slack: Answer + Chart + Exact Executed SQL + Sources ]     |
+-----------------------------------------------------------------------+

1. The Context Layer Does the Real Work

The true secret of OpenAI’s agent is not prompt engineering; it is data foundation engineering. An offline pipeline constantly indexes metadata into a semantic catalog:

  • dbt Model Documentation: Descriptions, primary keys, and column meanings verified by analytics engineers.
  • Query History & Popularity: The agent knows which tables are queried by human data scientists and which tables are stale remnants.
  • Verified SQL Snippets: A repository of golden queries showing exactly how metrics like Active Users or Token Run-Rates are canonically calculated.

When an employee asks a question, the agent retrieves the schemas of only the 3 to 5 most relevant tables and injects them into the prompt. The model never sees all 90,000 tables at once.

2. The Single Model with Sandboxed Execution

Rather than passing tokens through multiple specialized models, OpenAI feeds the enriched prompt to a single frontier model. The model reasons through the schema and generates a structured tool invocation:

{
  "tool": "execute_query",
  "arguments": {
    "engine": "trino",
    "sql": "SELECT region, SUM(tokens) FROM analytics.daily_api_usage WHERE tier = 'enterprise' AND region = 'EU' GROUP BY 1"
  }
}

The harness executes the query in a read-only sandboxed database proxy. If the database engine returns an error (such as a missing column or division by zero), the error traceback is captured and fed back to the model. The model analyzes the exception, adjusts the SQL syntax, and re-executes.

3. Radical Transparency in Output

A data agent must build human trust. If the bot simply outputs: “European enterprise token growth was 14.2%”, no engineer will rely on it for critical roadmap planning.

OpenAI’s Data Agent always outputs three components:

  1. The Executive Answer: Direct natural language summary with interactive charts.
  2. The Exact SQL Query: Full, copy-pasteable SQL formatted with proper joins and filters.
  3. Lineage and Sources: The specific tables and documentation links utilized to generate the result.

Key Engineering Takeaways

  • Invest in data foundations, not complex agent trees: An LLM cannot query a messy data lake. Clean dbt schemas, documented metrics, and semantic catalogs provide the real accuracy boost.
  • Skip fine-tuning for text-to-SQL: Frontier models already understand SQL grammar perfectly. Spend your effort retrieving relevant schemas dynamically into context.
  • Always show the executed SQL: Transparency is essential. Outputting executable queries allows human analysts to verify assumptions and catch edge cases.
Advertisement

/* Comments */