8-Part Deep Dive

Anatomy of an
AI Coding Agent

Dissecting the OpenAI Codex CLI

How does an AI coding agent actually work? This series tears open the Codex CLI and walks through every layer — from the architecture and protocols to sandboxing, tools, safety, and the SDK.

The Series — 8 Articles
Article 01 header
ARTICLE 01
The 10,000-Foot View
Four modular buildings, one shared core, and the queue that powers everything. The complete architecture overview.
Article 02 header
ARTICLE 02
The Nervous System
The SQ/EQ protocol: submission queues, event queues, and the async channels that decouple every component.
Article 03 header
ARTICLE 03
The Brain
The orchestrator, session management, prompt assembly, model communication, and the relentless tool-call loop.
Article 04 header
ARTICLE 04
The Vault
Multi-layered sandboxing — Bubblewrap, Seccomp, Landlock on Linux; Seatbelt on macOS. How every command is contained.
Article 05 header
ARTICLE 05
Four Windows
One core engine, four interfaces — TUI, headless executor, JSON-RPC server, and MCP bridge. Same brain, different hands.
Article 06 header
ARTICLE 06
The Swiss Army Knife
Shell exec, file patches, web search, and MCP servers. How Codex transforms into a universal integration platform.
Article 07 header
ARTICLE 07
The Safety Net
Six layers of defense — ExecPolicy DSL, approval chains, lifecycle hooks, secret detection, and shell escalation guards.
Article 08 header
ARTICLE 08
Building on the Giant
TypeScript & Python SDKs, custom MCP servers, architecture patterns worth stealing, and what comes next.