English reading guide
Codex Source Code Guide: Inside a Production Coding Agent
A source-based guide to the open-source openai/codex repository. Follow a request through the model loop, tool execution, approval and sandbox boundaries, conversation persistence, and recovery. The chapters explain why these mechanisms exist and what breaks when their assumptions do not hold.
Source version: rust-v0.144.6
What you will learn
- Trace a user request through the model loop and tool calls.
- Understand approvals, sandbox restrictions, and execution boundaries.
- Follow session state, context management, persistence, and recovery.
- Study extension protocols, multiple agents, and the verification system.
The complete chapters are written in Chinese and include source references, implementation walkthroughs, and failure cases. This page is an English introduction, not a translation of the full book.
Chapters in Chinese
- 不要从目录开始读 Codex
- 同一个 codex,为什么会启动几套不同的系统
- Codex 启动时,哪一份配置说了算
- 配置能覆盖,Requirements 不能绕过
- 登录身份不等于 Agent 身份
- 模型不是一个字符串:Provider、目录与 ModelInfo
- 你按下回车后,谁接管这次任务
- 模型收到的指令从哪里来
- History 为什么不能直接拿去做 Prompt
- Prompt 怎样变成一份 Responses 请求
- Codex 为什么有两层循环
- 一条 Responses 流怎样变成下一步行动
- 断流、限流和 401:Codex 分别从哪里恢复
- 模型为什么能调用工具:两张表,一个闭环
- 一份补丁怎样落盘,又怎样成为 TurnDiff
- 模型返回的 Shell 参数,为什么还不是一条进程
- 审批、Permission Profile 与沙箱各自拦什么
- 命令返回以后,进程为什么还活着
- 网络访问为什么另有一条决策链
- Skills 不是工具:从目录发现到渐进注入
- 外部 MCP Server 的工具怎样进入 Codex
- Dynamic Tools 为什么把执行权交回宿主
- Code Mode 为什么仍然绕不开同一张工具表
- 一个 Plugin 怎样变成一组可安装能力
- 同一段对话,为什么同时存在三种状态
- 上下文快满时,Codex 到底压缩了什么
- Resume 与 Fork:恢复的不是同一件事
- Memory 不是更长的 History
- Goal 为什么必须活在 Turn 之上
- App-server 如何把 Core 变成一套可消费协议
- TUI 如何把事件流还原成一个稳定界面
- 一个子 Agent 为什么需要独立 Thread
- 多个 Agent 怎样通信、等待与中断
- 普通 Responses 与 Realtime 为什么是两套会话
- Hooks 为什么不是一条统一回调链
- 没有证据的“跑通”不算跑通