CH 01 · What Is an Agent Harness? · 05/12
Read as one pageReal code: Codex splits the harness into crates
The six-layer table in "How it works: two mental maps" names the jobs around the model: input, knowledge, execution, integration, multi-agent, and observability. Codex, OpenAI's coding agent, puts each job in its own Rust crate, one library or program. codex-rs/Cargo.toml, at this commit, lists 157 of them. The request that reaches the model is codex-api, one dependency of core. Most of the other names are harness: permissions, hooks, sandboxing, memory, session files, telemetry, and tools.
"skills",
"core", # [1]
"core-api",
"core-plugin-common",
"core-plugins",
"diagnostics",
"guardian-context",
"hooks", # [2]
"history",
"http-client",
"secrets",
"exec",
"file-system",
"exec-server-protocol",
"exec-server",
"exec-server/tests/support",
"execpolicy", # [3]
"ext/agent",
Source: openai/codex, codex-rs/Cargo.toml (Apache-2.0)
"linux-sandbox", # [4]
"lmstudio",
"login",
"codex-mcp",
"memories/read",
"memories/write",
# ... (5 lines)
"ollama",
# ... (6 lines: process hardening, voice, the protocol crate, prompts)
"rollout",
"rollout-trace",
# ... (3 lines)
"sandboxing",
# ... (1 line)
"otel",
# ... (4 lines: a trace websocket, the TCP tunnel, the terminal UI, user verification)
"tools",
Source: openai/codex, codex-rs/Cargo.toml (Apache-2.0)
What to notice
- [1]
coreis the business logic the Codex UIs call, which its readme says in the first paragraph. In the six-layer table, this is the execution layer, the loop. The model call is the separatecodex-apiclient. - [2]
hooksruns your code at named moments, including before a tool runs. TheHarnessclass later in this chapter has no such pause: the model asks, and that class runs the tool.historyholds the types for model history and for persisted rollout records.rolloutstores the session files. - [3]
execpolicyis the permission check that class stores inpermissions. A rule matches the start of a command, written in Starlark, a small configuration language, and the decision isallow,prompt, orforbidden. That is the input layer.skillsloads skill folders, and it notices when a command reads a skill document or runs a skill script. - [4]
linux-sandboxconfines a command on Linux. Its readme says bubblewrap for filesystem and namespace isolation, and seccomp to filter system calls.sandboxingis the shared policy for Linux, macOS, and Windows.memories/readinjects saved notes into the prompt.otelexports logs, traces, and metrics.toolsbuilds the tools the model may call.
Read it yourself: Open codex-rs/core/Cargo.toml and find codex-api, codex-execpolicy, and codex-hooks. Then read the three decision values in codex-rs/execpolicy/README.md.
Finished this idea?
Your learning progress stays in this browser.