WhoBuilt

How Codex Works

Aug 10, 2026· 21 min· 72K views·Watch on YouTube

Speaker

Dominik Kundel of OpenAI explains how the Codex agent harness works at AI Engineer World’s Fair, with examples for engineers building agents.

Protocols connect the interface, harness, and model

Kundel describes two protocols: the app server connects a UI to the Codex harness, and the Responses API connects the harness to model inference. The app server also powers the Codex app and supports third-party projects, while compatible model providers can plug into the harness through the open Responses schema.

Context stays bounded as tools and skills grow

Context construction aims to control size, remain flexible, and support cacheability. Codex defers some tools until tool search is needed and caps the available skills list at 2% of the maximum context window, shortening descriptions when necessary.

Agents use async work, browser code, and sandboxed files

Codex can delegate to subagents, keep background terminals running, and interact with a browser through JavaScript in a persistent Node REPL. For file work, models use apply patch and shell tools; filesystem actions run through platform-specific sandboxes, including Bubblewrap on Linux and Seatbelt on macOS.

Auto review weighs authorization and risk

To reduce approval fatigue without enabling unrestricted access, Codex uses a separate read-only review subagent when an action needs escalation. It considers the conversation, user authorization, and the action’s impact; deleting a file the user explicitly asked to remove may be approved, while uploading a file is treated differently from a basic connectivity check.

Speed and long-running tasks depend on the harness

Kundel says network overhead became a bottleneck when inference ran at 1,000 tokens per second, so WebSocket mode sends changed items over a persistent connection. For long tasks, /goal injects continuation prompts until the model reports completion, and compaction carries necessary context into a fresh window.

Takeaways

  • Keep context bounded: defer rarely used tools and limit how much skill description enters the prompt.
  • Use persistent code execution for browser tasks that involve several pages or turns.
  • Make approval decisions based on user authorization and action impact, with a separate reviewer that has read-only access.
  • Measure network and tool-call overhead as well as model inference speed.
  • Write goals that are concrete and verifiable so an agent can tell when the work is done.

Mentioned in this talk

Search inside this talk

What was claimed 9

  • feature
    Codex: Open source; MIT- and Apache 2.0-licensed
    “the Codex harness and everything I'm showing you is open source. It's MIT- and Apache 2.0-licensed”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Codex integrates with Codex app server
    “you can build on top of the Codex harness using the app server protocol”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Codex integrates with OpenAI Responses API
    “The second part is the Responses API, which handles communication between the harness and inference.”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Codex integrates with Claude Code
    “I even used that same app server to put Codex into Claude Code.”
    YouTube
    Unverified1 source· Talk
  • feature
    OpenAI Responses API: Deferred tool loading through tool search, available since GPT-5.4
    “Since GPT-5.4, you can mark any tool as deferred loading.”
    YouTube
    Unverified1 source· Talk
  • feature
    Codex: Auto review assesses escalated actions against user authorization and risk
    “we built auto review to cover actions that are harder to predict an agent might take”
    YouTube
    Unverified1 source· Talk
  • feature
    OpenAI Responses API: WebSocket mode uses a persistent connection and sends only changed data
    “This saves on network overhead and provides stateful context, which means we only have to send the data that actually changed.”
    YouTube
    Unverified1 source· Talk
  • feature
    Codex: Automatically continues goal tasks until the model reports completion
    “Until then, the harness will automatically inject this continuation prompt.”
    YouTube
    Unverified1 source· Talk
  • feature
    Codex: Automatically triggers server-side context compaction
    “Codex has used it since then to automatically trigger compaction on the server side”
    YouTube
    Unverified1 source· Talk

Related talks