By Bonnie Xu, Aravind Suresh, and Emma Tang
Overview
OpenAI built a bespoke internal AI data agent powered by GPT-5.2 that enables employees across Engineering, Data Science, Go-To-Market, Finance, and Research to go from question to insight in minutes instead of days. The agent reasons over OpenAI's 600-petabyte data platform spanning 70,000 datasets, using six layers of context including table usage metadata, human annotations, Codex-enriched code analysis, institutional knowledge from Slack/Docs/Notion, a self-learning memory system, and live runtime queries. The article covers the architecture, context enrichment pipeline, evaluation strategy using OpenAI's Evals API, security model, and key lessons learned from building the agent.
What You'll Learn
How to architect a multi-layered context system for AI data agents using table metadata, code enrichment, institutional knowledge, memory, and runtime queries
Why code-level understanding of data pipelines is critical for agents to distinguish between similar-looking tables
How to build a self-learning memory system that retains corrections and non-obvious constraints for improved data accuracy over time
How to evaluate AI agent quality using curated question-answer pairs with golden SQL queries and OpenAI's Evals API
When to use high-level guidance versus prescriptive prompting for AI agents to improve robustness
Prerequisites & Requirements
- Understanding of SQL and data warehousing concepts including joins, CTEs, and query optimization
- Familiarity with AI/ML concepts including LLMs, embeddings, and retrieval-augmented generation (RAG)
- Understanding of data platform architecture including metadata services, data pipelines, and schema management
- Experience with building or using AI agents or LLM-powered tools(optional)
Key Questions Answered
How does OpenAI's internal data agent handle context for accurate query generation?
Why did OpenAI build a custom data agent instead of using off-the-shelf tools?
How does the data agent's memory system improve over time?
How does OpenAI evaluate the accuracy of their data agent's responses?
What role does Codex play in OpenAI's data agent architecture?
What are the key lessons from building an enterprise AI data agent?
How does OpenAI's data agent handle security and access control?
Where is OpenAI's data agent available to employees?
Key Statistics & Figures
Technologies & Tools
Some links below are affiliate links. We may earn a commission if you make a purchase.
Key Actionable Insights
1Build multiple layers of context rather than relying on schema metadata alone when creating data agents. Combine table usage patterns, human annotations, code-level enrichment, institutional knowledge, persistent memory, and runtime queries to ground agent reasoning in both technical and business context.OpenAI found that without rich context, even strong models produce wrong results like vastly misestimating user counts or misinterpreting internal terminology. Each layer addresses a different failure mode.
2Implement a self-learning memory system that captures corrections and non-obvious constraints from user interactions. Scope memories at both global and personal levels, and prompt users to save learnings during conversations rather than relying solely on pre-built context.Memory proved crucially important for retaining specific details like exact string patterns for experiment filtering that couldn't be inferred from other context layers. Without memory, identical queries took 22+ minutes versus 1 minute 22 seconds with memory.
3Use Codex or similar code analysis tools to enrich data catalog entries by crawling the source code of data pipelines. Extract table purpose, grain, primary keys, downstream usage patterns, alternate table options, and data freshness directly from the code that produces each dataset.Schemas and query history describe a table's shape and usage, but the true meaning lives in the pipeline code that produces it. This code captures assumptions, freshness guarantees, and business intent that never surface in SQL or metadata.
4Consolidate and restrict overlapping tool capabilities when building AI agents. Redundant functionality that seems helpful for manual use creates confusion for agents, leading to unreliable behavior and degraded results.OpenAI initially exposed their full tool set and quickly encountered problems with overlapping functionality. While redundancy can help humans making deliberate choices, it confuses agents that must choose between similar options.
5Prefer high-level goal-oriented guidance over highly prescriptive step-by-step prompting for AI agents. Let the model's reasoning capabilities determine the appropriate execution path rather than rigidly scripting the analysis flow.OpenAI discovered that prescriptive prompting degraded results because while many data questions share a general analytical shape, the details vary enough that rigid instructions pushed the agent down incorrect paths.
6Build continuous evaluation pipelines using curated question-answer pairs with golden SQL queries, and compare both the generated SQL and the resulting data using model-graded evaluation rather than naive string matching.Generated SQL can differ syntactically while still being correct, and result sets may include extra columns that don't affect the answer. OpenAI runs these evals as unit tests during development and as canaries in production to catch regressions early.