Agentic Patterns in OpenAI's Codex
Origin Story
This project started from a gap that shows up repeatedly when learning agentic systems.
On one side, there is a design-patterns book on agentic systems—clean abstractions, conceptual primitives, and a structured way to think about planning, execution, memory, tools, and control loops.
On the other side, there is OpenAI’s Codex—a large, production-grade agentic system implemented under real-world constraints.
What was missing was the bridge.
This repository was created by taking the patterns from the book and locating them inside the Codex implementation—not as diagrams or toy examples, but as concrete modules, control flow, and engineering decisions. The result is a lesson plan for learning agentic patterns by reading real code.
Sources of inspiration:
- Design-patterns book by Antonio Gulli: link
- OpenAI Codex based on 7 Oct 2025 version
This project exists to connect the two.
What It Is Broken Down Into
The material is organized as a pattern-to-code curriculum, not a narrative book.
Each section follows a consistent structure:
- The agentic pattern (as defined in the book)
- Where it appears in Codex (files, modules, control paths)
- The problem the pattern is solving
- The constraints shaping the implementation (state, permissions, cost, latency, safety)
- What breaks if the pattern is removed or simplified
The breakdown focuses on:
- Planning vs execution boundaries
- State and memory handling
- Tool invocation and arbitration
- Safety and permission layers
- Failure handling, fallbacks, and observability
- How patterns compose—and where composition introduces fragility
The goal is not to document Codex exhaustively, but to make agentic patterns legible when encountered in a real system.
Project repository:
https://github.com/artvandelay/codex-agentic-patterns