Codex CLI 0.172.0 source snapshot
Codex Internals
Run a task with Codex. Then follow how the harness builds model requests, runs tools, and carries results into the next decision.
- Model returns a tool call
exec_command - Codex runs the command
echo tool harness - Next model request carries the result
function_call_output
Choose a reading path
Section titled “Choose a reading path”Use CodexStart with a small CSV task. Reuse it to learn project instructions, permissions, skills, and MCP.
Read the implementationFollow a turn through the model client, tool runtime, and context manager.
Verify and experimentRead an upstream assertion, choose a measurable outcome, and turn a chapter question into a small pilot.
Explore by module
Section titled “Explore by module”| Module | Start with | What you’ll trace |
|---|---|---|
| Model and prompt | Prompt Construction · Response Streaming | Request fields, tool schemas, and streamed event identity. |
| Tools and policy | Tools and Approvals · Tool Failures | Execution, argument validation, approval replies, and hook outcomes. |
| Turn control | Steering an Active Turn | How steering reaches a later request and interruption resolves a pending approval. |
| Context, history, and memory | Compaction and Resume · Session History and Memory | What survives a checkpoint, what resume restores, and how local memory contributes to a new thread. |
| Workflow and extensions | Subagent Handoffs · Configuration and Skills · MCP Integration | Child results, reusable instructions, and external tools. |
Check the evidence
Section titled “Check the evidence”Read the assertion next to the claim it supports. The Source Map points to the exact revision and gives commands for the upstream fixtures. The CLI guides record which examples were checked on the installed client.
Codex Internals is an independent handbook for the public Codex implementation.