Inside OpenAI’s in-house data agent
# Inside OpenAI's In-House Data Agent OpenAI built a bespoke, internal-only AI data agent to help employees go from a data question to an insight in minutes rather than days. Built on GPT-5.2 and the same developer tools OpenAI offers externally (Codex, the Evals API, and the Embeddings API), the agent reasons over OpenAI's data platform, which spans more than 600 petabytes across roughly 70k datasets. The post argues that a capable model alone is not enough: reliable answers depend on layered context, persistent memory, and systematic evaluation. ## Why a Custom Tool Was Needed - At this scale, finding the right table is often the most time-consuming step, since many tables look similar but differ in critical ways, such as whether they include logged-out users. - Even with the right tables, common SQL failures such as many-to-many joins, filter pushdown errors, and unhandled nulls can silently produce wrong results. - The goal is to let analysts focus on defining metrics and making decisions rather than debugging SQL semantics. ## How the Agent Works - It is available wherever employees work: as a Slack agent, through a web interface, inside IDEs, in the Codex CLI via MCP, and through an MCP connector in OpenAI's internal ChatGPT app. - It handles the full analytics workflow: discovering data, writing and running SQL, and publishing notebooks and reports. - It evaluates its own intermediate results. If a query returns zero rows, for example, it investigates, adjusts, and retries while carrying learnings forward. - When a request is ambiguous, it asks clarifying questions, but if no answer comes, it applies sensible defaults such as a 7- or 30-day window. - Recurring analyses, such as weekly business reports and table validations, are packaged as reusable workflows. ## Layered Context The post describes six layers of context that ground the agent's reasoning: - **Table usage:** Schema metadata and lineage show how tables relate, and ingesting historical queries reveals which tables are usually joined. - **Human annotations:** Domain experts curate descriptions that capture business meaning and known caveats. - **Codex enrichment:** Code-level analysis of how each table is produced reveals uniqueness, update frequency, scope, and whether a table includes only first-party ChatGPT traffic. This context refreshes automatically. - **Institutional knowledge:** Slack, Google Docs, and Notion content on launches, incidents, codenames, and metric definitions is embedded with permissions metadata and retrieved at runtime. - **Memory:** Corrections and non-obvious filters are saved globally or per user. In one case, the agent learned how to filter a specific experiment by matching a string defined in an experiment gate, rather than guessing with fuzzy string matching. - **Runtime context:** When information is missing or stale, the agent queries the warehouse live and consults metadata, Airflow, and Spark. A daily offline pipeline aggregates the first three layers into normalized embeddings. At query time, retrieval-augmented generation pulls only the most relevant context, keeping latency low across tens of thousands of tables. ## Evaluation and Trust - Evals are built from curated question-answer pairs, each with a manually written "golden" SQL query. - Grading does not rely on string matching. The system compares both the generated SQL and its result data, and an Evals grader produces a score with an explanation. - The evals run continuously as unit tests during development and as canaries in production to catch regressions. ## Security and Transparency - The agent acts purely as an interface layer and enforces existing permissions, so users can query only the tables they are already authorized to access. - It summarizes its assumptions and execution steps with each answer and links to underlying results so users can verify the analysis. ## Lessons Learned - **Less is more:** Overlapping tools confused the agent, so the team consolidated tool calls. - **Guide the goal, not the path:** Highly prescriptive prompts degraded results. High-level guidance let GPT-5's reasoning choose better execution paths. - **Meaning lives in code:** Schemas and query history miss assumptions and freshness guarantees that are visible in pipeline code, so crawling the codebase with Codex improved the agent's understanding of what each table contains. The team plans to make the agent handle ambiguous questions better, add stronger validation, and integrate it more deeply into existing workflows so it feels like part of how people already work, rather than a separate tool.