How OpenAI’s Performance Factory keeps ChatGPT fast
# How OpenAI's Performance Factory Automates Performance Engineering OpenAI built the Performance Factory, an autonomous cloud system built on Codex that finds, diagnoses, and fixes performance regressions with minimal manual effort. Its first workflow, the Regression Workflow, has tracked over 1,700 investigations and root-caused more than 600 cases in just over three months, about 17 automated investigations per day. The authors argue that as agentic development accelerates, performance engineering must become similarly automated and self-improving, with engineers focusing on decisions rather than manual investigation. ## Evolution from Manual Investigation to an Agent Factory The team describes a progression in how they used Codex for performance work: - **Pre-Codex:** Engineers manually read metrics and logs, compared traces, profiled live machines, and read code. The team built over 30 performance tools to ease repeated investigations, but knowing where to look still required deep service knowledge. - **Codex as partner:** Engineers asked questions like "Why did this get slower?" and worked with Codex to search code, correlate metrics and traces across services, and profile systems, lowering the expertise needed. - **Reusable skills:** The team captured its investigation process in a shared `perf-forensics` skill that describes available tools and a playbook: find when the slowdown began, identify affected requests, and check deployments or config changes. Evals based on past regressions let Codex produce a diagnosis from a single alert. - **Human proxy:** Engineers were copying alerts into Codex and pasting results back into Slack, acting as the link between the two. - **Automated investigations:** Alerts started cloud-based Codex sessions that posted findings to Slack, but engineers still had to develop fixes and verify them. - **The factory:** The Performance Factory tracks each task's state and findings, assigns agents when a step is ready, and lets work pass between agents and engineers. ## The Four Components of the Performance Factory - **Task service with configurable workflows:** Workflows are defined by a `config.toml` file that lists states, allowed transitions, and steps requiring an engineer, plus Markdown prompts for each state. All tasks are visible in a shared UI. - **Dispatch loop:** A periodic process finds tasks ready for their next step and starts a Codex turn with that state's instructions. The agent records progress and advances the task when the step completes. - **Cloud execution:** An internal API runs Codex turns in an environment inside OpenAI's network with access to code repositories and observability tools (metrics, logs, traces, CPU profiles, memory snapshots). Agents run under a service identity, so permissions are scoped and actions are attributable, and work runs in parallel without relying on engineers' laptops. - **Subscriptions:** Tasks waiting on people or deployments subscribe to events such as PR review comments or failed CI checks. A matching event makes the task ready again, so agents don't need to run while waiting. ## The Regression Workflow A regression moves through four stages: needs investigation, root caused, fix proposed, and resolved. The workflow opens a task when a configured alert fires, and agents advance it through these stages, recording findings in the task so any agent or engineer can resume the work. ### Root Cause Analysis - The agent determines which metrics degraded, when the change began (alerts fire after a threshold is crossed, so the regression may have started hours earlier), and which requests were affected. - It distinguishes between requests that became slower and a shift toward already-slow requests, since these point to different causes. - It examines deployments and feature flag changes, checks when they reached affected requests, and uses logs or traces to test whether the code explains the behavior. ### Adversarial Review Early agents sometimes accepted the first plausible explanation, and some were wrong. A separate Codex session now tries to disprove each diagnosis by testing counterfactuals. For example, it checks whether unexposed requests stayed healthy after a rollout. In one case, the reviewer caught that an image-download diagnosis did not explain failures that continued after the underlying service had recovered, and reopened the investigation. In a manual review of 100 root cause suggestions, 70% were graded accurate, and the rest needed refinement or did not fully establish causality. ### Fixes and Handoff - Once the diagnosis passes review, Codex implements a fix and opens a pull request. Each task includes an automatically generated report covering the regression, its impact, root cause, and proposed fix, with metric time series, CPU flame graphs, and traces as evidence. - Engineers can edit the PR, write their own fix, or comment, which wakes an agent to respond. - After deployment, an agent checks whether performance returned to baseline. Partial recovery yields a new task for the remaining slowdown; no improvement sends the regression back for investigation. - Fixes are harder than diagnoses. Agent-proposed changes are sometimes overly complex or introduce new bugs, so each fix also gets an adversarial review. Architectural tradeoffs, such as a cache that adds stale data, still need engineer judgment. - The team is building an evaluation loop comparing agent proposals with the changes engineers ultimately merge, along with synthetic performance tests so agents can measure fixes before review. ## Lessons from Running Agent Workflows ### Protect Engineers' Attention Raw agent output is often hard to parse, and agents can produce more findings than a team can read. The first UI simply displayed findings, which still left engineers to decide what mattered. The workflow now links related incidents across alerts, groups them by metric, and ranks estimated impact. ### Evaluate Changes Before Shipping Them Updating a skill or model can improve some diagnoses while degrading others, so the team tests two things separately: - **Investigations** are backtested against past production incidents. Each case starts with a fresh investigator and the original signal, with answer-revealing details removed. Test validity depends on controlling what evidence the agent could see, since telemetry expires and post-recovery data can leak the answer. Timing, impact size, affected requests, and root cause are scored separately. - **Handoff summaries** are tested with snapshots of saved tasks, which avoids dependence on expiring metrics. A grader checks whether an unfamiliar engineer can understand the issue, whether useful charts were kept, and whether the next step is supported by evidence. ### Turn Recurring Failures into Self-Repair Broken profilers or missing permissions can silently prevent agents from verifying causes. A daily agent scans logs and messages from recent runs for tool and access failures. When one error blocks several investigations, the system creates a repair task, and engineers review the resulting changes. ## What's Next The Regression Workflow is one example of a general pattern: explicit task states, agents that advance work, separate reviewers that challenge conclusions, and engineers who step in for judgment calls. Future directions include: - **Proactive detection:** Agents could compare fine-grained profiles, heap dumps, and request traces across releases to find small regressions or optimizations that alerts miss, then open tasks in the Regression Workflow. - **Known-pattern workflows:** Patterns such as over-provisioned autoscaling (handled by a service rightsizing skill) could be turned into workflows that run across all services. - **Greater autonomy:** The current bottleneck is engineer review and merging, and the team is exploring whether low-risk fixes can ship without a human in the loop. The authors conclude that as Codex accelerates product development, performance systems must become increasingly autonomous and self-improving to keep ChatGPT fast.