Problem
OpenAI's data platform serves more than 3.5k internal users and holds over 600 petabytes in 70k datasets. Many tables look alike: some include logged-out users, some do not, and fields overlap. Finding the right table eats much of an analysis. Even with the right table, many-to-many joins, filter pushdown errors and unhandled nulls can silently give wrong numbers, and a 180+ line SQL statement is hard to check by eye.
Example from the article: a user asks which NYC taxi pickup-to-dropoff ZIP pairs are most unreliable, with the largest gap between typical and worst-case travel times, and when the variability occurs.
Solution in brief
OpenAI built an internal agent on GPT-5.2 that reasons over the warehouse. Six layers of context ground it: table usage, human annotations, code-derived table definitions from Codex, institutional documents, saved memory and live runtime queries. A daily offline job embeds the table-level context for retrieval, and continuous evaluation against golden SQL guards quality.
Questions this case answers
- How to ground an LLM agent that writes queries over tens of thousands of near-duplicate tables when schemas and query logs do not reveal what each table actually contains
- How to measure and protect the answer quality of an always-evolving data-querying agent when correct SQL can differ syntactically
- How to make an LLM agent pick the right table among tens of thousands of similar datasets?
- How to ground a text-to-SQL agent in what a table really contains, not just its schema?
Tools and methods
- GPT-5.2 (GPT-5) — the reasoning model behind the agent.
- Codex — crawls the codebase to derive what each table contains.
- OpenAI Embeddings API — indexes the enriched context for retrieval.
- Retrieval-augmented generation (RAG) — pulls only the relevant context at query time.
- OpenAI Evals API (OpenAI API) — grades generated SQL and its results against golden queries.
- Memory — keeps corrections and filters across conversations.
Google or a one-time email code. No password.