Company
OpenAI
Title
Building and Scaling Codex: OpenAI's Production Coding Agent
Industry
Tech
Year
2025
Summary (short)
OpenAI developed Codex, a coding agent that serves as an AI-powered software engineering teammate, addressing the challenge of accelerating software development workflows. The solution combines a specialized coding model (GPT-5.1 Codex Max), a custom API layer with features like context compaction, and an integrated harness that works through IDE extensions and CLI tools using sandboxed execution environments. Since launching and iterating based on user feedback in August, Codex has grown 20x, now serves many trillions of tokens per week, has become the most-served coding model both in first-party use and via API, and has enabled dramatic productivity gains including shipping the Sora Android app (which became the #1 app in the app store) in just 28 days with 2-3 engineers, demonstrating significant acceleration in production software development at scale.
## Overview and Use Case OpenAI's Codex represents a comprehensive production implementation of LLMs for software engineering, developed and led by Alexander Emiros. Codex is positioned as more than just a code completion tool—it's designed to be a software engineering teammate that participates across the entire development lifecycle. The system serves internal OpenAI teams while also being offered as an external product through IDE extensions (primarily VS Code) and CLI tools, making it a multi-tenant production system at massive scale. The case study is particularly valuable because it demonstrates LLMOps principles applied at the frontier of AI capabilities, with tight integration between research and product teams. Since the GPT-5 launch in August, Codex has experienced 20x growth and now serves many trillions of tokens per week, making it OpenAI's most-served coding model both internally and via API. ## Architecture and Technical Infrastructure Codex employs a three-layer architectural stack that represents a sophisticated approach to production LLM deployment. The first layer is the model itself—GPT-5.1 Codex Max—which is specifically trained for coding tasks with particular focus on working within the Codex harness environment. This model demonstrates approximately 30% faster task completion compared to GPT-5.1 and supports extended reasoning at higher reasoning levels for tackling complex bugs. The second layer is a custom API that provides specialized functionality beyond standard LLM inference. A key innovation here is the "compaction" feature, which allows Codex to work continuously for extended periods (24+ hours) by managing context windows intelligently. When approaching context limits, the system can prepare the model to transition to a new context window seamlessly, enabling long-running autonomous tasks without human intervention. This compaction capability requires coordination across all three layers of the stack. The third layer is the harness—the execution environment where the model actually operates. Unlike other coding agents that might use semantic search, bespoke tools, or accessibility APIs, Codex operates primarily through shell commands. This design decision reflects a philosophical choice: if models are going to become general agents that can use computers effectively, code execution via shell is the most powerful and generalizable interface. To make this safe and secure, Codex uses sandboxed execution environments that isolate model actions while providing access to necessary dependencies. ## Model Training and Specialization The training approach for Codex reflects tight coupling between product and research teams. Rather than training a general-purpose model and adapting it for coding, the team trains models specifically for use within their first-party harness. This allows them to optimize for the specific interaction patterns, tool usage, and workflows that their system supports. The training data distribution aligns with real-world language usage, meaning Codex supports virtually all mainstream programming languages effectively. A particularly interesting aspect is that Codex models natively understand PowerShell as of the most recent release, reflecting the team's attention to Windows development workflows. The model is also trained to understand concepts like compaction and knows how to prepare itself when approaching context windows—demonstrating how model capabilities can be co-designed with system architecture. The team's approach to model development emphasizes empirical validation over theoretical planning. Because model capabilities evolve rapidly and unpredictably, the organization operates with what Emiros describes as "fuzzy aiming" at year-plus timelines, but remains highly empirical and bottoms-up for shorter timeframes. This allows them to discover and capitalize on emergent capabilities quickly. ## Deployment Strategy and Product Evolution Codex's deployment strategy reveals important lessons about bringing advanced AI agents to market. The initial version, Codex Cloud, offered asynchronous delegation where users could run many tasks in parallel on cloud-based computers. This proved more effective for internal power users at OpenAI (who routinely work with reasoning models and long-running processes) than for the general market. The team discovered through user feedback that while this represented the future vision, it required too much upfront configuration and prompted a different mental model than most developers were ready for. The breakthrough came from what Emiros describes as "landing with users" through more intuitive interfaces: IDE extensions and CLI tools that work locally on developers' computers within sandboxes. This approach removes setup friction—the agent has access to local dependencies and can ask for credentials or permissions as needed—while still maintaining security through sandboxing. Users can build trust incrementally by working side-by-side with Codex before delegating longer-running tasks. This follows a natural progression analogous to onboarding a human teammate: initial collaboration establishes context and preferences, which then enables autonomous work later. This evolution demonstrates a critical LLMOps principle: even when building for technically sophisticated users (software engineers), the adoption path must match users' existing workflows and mental models. The team actively monitors both praise and complaints on Reddit and Twitter, with particular attention to Reddit for its voting mechanics that surface genuinely important issues. This feedback loop drives rapid iteration on both model and product. ## Production Use Cases and Impact The impact of Codex on internal OpenAI operations provides compelling evidence of production-ready LLM systems. The Sora Android app exemplifies this: a fully functional application that became the #1 app in the App Store was built in just 18 days to internal launch and 28 days to public release, primarily by 2-3 engineers using Codex extensively. The team leveraged Codex's strength at porting implementations—having it analyze the iOS app and generate plans for Android, then implement those plans while referencing both codebases simultaneously. For the Atlas browser project, engineers report that tasks previously requiring 2-3 weeks for 2-3 engineers now take one engineer one week, representing dramatic productivity gains. These aren't trivial implementations—Atlas is a full browser, and the team needed to build complex systems to make it work. The fact that such ambitious projects can be executed at this velocity demonstrates Codex's production readiness for sophisticated software engineering. Beyond traditional engineering, Codex has enabled workflow compression across roles. Product managers at OpenAI now make string changes directly from Slack and update documentation without engineering support. Designers use Codex to build animation editors for creating animations, then use those tools to produce assets that ship in products—a form of "vibe coding" that generates throwaway tools for immediate tasks. The design team maintains a standalone Codex-built prototype of the product that they iterate on rapidly, then either land PRs themselves or work with engineers to finalize changes. Internal usage has grown to encompass essentially all technical staff at OpenAI with increasing sophistication in how they leverage the system. Codex itself writes much of the code that manages its own training runs and has caught configuration errors through automated code review. The team is exploring having Codex be on-call for its own training—monitoring training run graphs and taking corrective action autonomously—which would represent a significant milestone in AI systems managing their own development infrastructure. ## Context Management and Long-Running Tasks One of Codex's most impressive capabilities is handling extended autonomous operation. Users routinely report Codex running overnight or for 24-hour periods on complex tasks. This requires sophisticated context management since these durations exceed model context windows. The compaction system addresses this by allowing the model to prepare a compressed representation of relevant context when approaching limits, then continue in a fresh context window with that compressed state. For longest-running tasks, users have discovered patterns like "plan-driven development" where they collaborate with Codex to create a detailed markdown plan with verifiable steps, then delegate execution. When the plan includes concrete validation criteria, Codex can work for much longer periods autonomously. This represents a higher level of abstraction than prompt-to-patch workflows, though still grounded in executable artifacts rather than pure specifications. The emphasis on verification and validation reflects the team's recognition that writing code is often the enjoyable part of software engineering, while reviewing AI-generated code can be tedious. This has driven product focus toward features that help validate AI work and build confidence, including a code review feature and capabilities for agents to validate their own work before requesting human review. ## Instrumentation and Monitoring While the transcript doesn't detail specific metrics infrastructure, it reveals the team's approach to production monitoring. They track Day 7 retention closely as a key health metric, recognizing the risk of optimizing excessively for power users while neglecting the onboarding experience. The product lead regularly creates new accounts to experience the signup and initial use flows authentically. Social media monitoring serves as a real-time feedback mechanism, with Reddit particularly valued for its voting system that surfaces issues that matter to multiple users. This qualitative signal complements quantitative metrics and helps identify specific interaction patterns that work well or poorly. Internal dogfooding provides extensive signal given OpenAI's scale and the variety of codebases and use cases. However, the team learned that internal users (who work with reasoning models constantly) have different tolerance for async delegation and longer-running processes than typical developers. This required conscious effort to weight external user feedback appropriately alongside internal usage patterns. The team uses public benchmarks but emphasizes that the most valuable validation comes from giving Codex genuinely difficult tasks—hard bugs, complex implementations in large codebases. This reflects a design philosophy that Codex should be the tool you reach for when problems are hardest, rather than for trivial tasks. ## Safety and Control Mechanisms Sandboxing represents the primary safety mechanism for Codex's shell-based execution model. The sandbox provides isolation while allowing the agent to perform necessary operations, with the ability to request permissions for operations outside sandbox boundaries. This creates a security boundary while maintaining the flexibility that makes shell-based operation powerful. The interaction model also embeds safety through user control. Users can interrupt, redirect, or adjust Codex's work without disabling the agent entirely—analogous to how Tesla's self-driving allows drivers to maintain control through acceleration, steering, or speed adjustments without exiting autonomous mode. This "mixed initiative" design keeps humans in the loop meaningfully while still providing substantial acceleration. For future autonomous operation, the team is exploring configuration systems where teams can define guidelines, preferences, and constraints that persist across sessions. This would allow users to progressively configure agents to be more autonomous as trust builds, while maintaining guardrails around what agents can do unsupervised. ## Scaling Challenges and Solutions The 20x growth since August presents significant scaling challenges. Serving many trillions of tokens per week requires robust infrastructure, though specific implementation details aren't discussed in the transcript. The fact that Codex has become the most-served coding model both for first-party use and via API suggests successful scaling of both the inference infrastructure and the integration points that make the model useful. The team structure itself—a tightly integrated product and research team—represents an organizational approach to scaling that differs from many production ML systems. Rather than separating model development from application development, Codex co-develops the model, API, and harness together. This enables rapid experimentation with how these components interact but requires close collaboration and shared understanding across traditionally separate functions. ## Future Directions and Agent Vision The long-term vision for Codex extends well beyond code completion or even autonomous coding. The team sees coding as a fundamental competency for any general agent because code is the most powerful way for AI to interact with computers and accomplish tasks. This suggests Codex is positioning itself not just as a developer tool but as infrastructure for agentic AI more broadly. The concept of "proactivity" represents a key frontier—moving from reactive systems that respond to prompts to agents that identify opportunities to help based on context. The Atlas browser integration exemplifies this: by understanding web content the user is viewing, Codex can surface contextually relevant capabilities rather than waiting for explicit prompts. This addresses what Emiros identifies as a critical limitation of current AI products: users must constantly think about when AI can help rather than receiving help by default. The vision of "chatter-driven development" suggests a future where agents infer work from team communications, customer service channels, and other ambient signals rather than requiring explicit specifications or tasks. This would require agents to develop better understanding of team contexts, priorities, and working styles—essentially becoming more like human teammates who pick up on implicit cues. The team is also exploring composability through code artifacts. When agents write code to accomplish tasks, those scripts can be saved, shared, and imported by other agents or users. This creates a form of learned organizational knowledge where common patterns become reusable capabilities. Teams could build libraries of agent-written tools that make subsequent agent work more effective—a form of institutional learning through code. ## Broader Implications for LLMOps Several themes from Codex's development have broader implications for production LLM systems. The importance of landing with users where they are—even if that means deploying a less ambitious version initially—demonstrates that adoption paths matter as much as capabilities. The three-layer stack (model, API, harness) shows how production LLM systems often require capabilities beyond raw model inference, particularly for long-running or autonomous operation. The emphasis on empirical validation and rapid iteration, enabled by tight product-research integration, suggests organizational structures that differ from traditional ML development. The recognition that reviewing AI output is becoming a bottleneck points to an emerging category of problems in LLMOps: not just making AI more capable, but making it easier to verify and trust AI work. Finally, Emiros's observation that human typing speed and multitasking ability may be the current limiting factor on AGI progress—rather than model capabilities—suggests that LLMOps concerns around deployment, integration, and human-AI collaboration may be critical path items for realizing the full value of advancing models. The hockey stick in productivity will come not just from better models but from systems that allow those models to operate with less human intervention for validation, which requires careful attention to the full stack of concerns that constitute LLMOps in production.

Start deploying reproducible AI workflows today

Enterprise-grade MLOps platform trusted by thousands of companies in production.