中文

Pattern Index

Reading Contract: Use this reference as a decision checklist. Start from the problem you are solving, then jump back to the chapter that explains the pattern and its failure mode.

Reusable agent pattern index connecting typed boundaries, queue-pair runtime, tools, approvals, sandboxes, extensions, and shared surfaces
The pattern index turns recurring design moves into a checklist that stays attached to the chapters and source evidence.

This page collects the reusable design patterns that appear across the book. They are not Codex-only tricks. They are architectural moves that matter whenever an LLM product can inspect files, run commands, call external tools, or serve multiple clients.

The Patterns

Typed Boundary First

Read enums and structs before long functions. In Codex, `Op`, `Submission`, `Event`, and app-server requests reveal the product contract.

Chapter 4

Queue Pair Runtime

Clients submit operations and listen for events. That shape lets TUI, exec, and app-server clients share one core runtime.

Chapter 5

Turn as Control Unit

A turn is the unit where context, model sampling, tools, hooks, compaction, and completion come together.

Chapter 6

Tools as Product Contracts

A tool is not just a function. It carries schema, mutability, hooks, cancellation, output formatting, and user-visible effects.

Chapter 9

Patch Instead of Blind Write

Structured patches make edits reviewable, approvable, diffable, and easier to attribute to a turn.

Chapter 11

Approval as Control Plane

Approval policy, permission hooks, Guardian review, and network amendments sit above individual tools instead of being scattered through them.

Chapter 12

Sandbox as Runtime Transform

Codex treats sandboxing as a transformation of execution requests, selected by platform, policy, permissions, and retry semantics.

Chapter 13

Extension by Injection

Skills, plugins, app mentions, and MCP inventory become turn-scoped context and tools rather than separate agent loops.

Chapter 17 / Chapter 18

One Runtime, Many Surfaces

The TUI and app-server differ at presentation time, but both consume structured events from the same session model.

Chapter 14 / Chapter 16

Reading the Patterns Safely

Patterns are only useful when they stay attached to evidence. For each pattern, the chapter provides an evidence map with pinned source links, an explanation for beginners, and a small reading exercise. If you want the complete map in one place, use the Source Atlas.