Day 18 — Codex CLI: A Real Rust AI Agent
Before extending Forge, study a real system. OpenAI’s maintained Codex CLI is a Rust implementation
distributed as a native executable. Its public repository contains a Cargo workspace rather than one
giant main.rs.
Official source: openai/codex and its Rust CLI README.
Run the product surface
Section titled “Run the product surface”If Codex is installed:
codex --versioncodex --helpcodex exec --helpList behaviors rather than flags: interactive session, non-interactive execution, configuration, model selection, approvals, sandbox mode, structured output, resumption, and event output.
Read source with questions
Section titled “Read source with questions”Clone or browse the official repository and answer:
- Where is the Cargo workspace declared?
- Which crate owns the terminal interface?
- Which types represent requests, events, and configuration?
- Where are tool execution and sandbox policy separated?
- How do tests avoid depending entirely on a live model?
- Which boundaries are operating-system-specific?
Record file links and a commit SHA. The repository changes; your architecture note must identify what you actually inspected.
Draw the system, then compare with Forge
Section titled “Draw the system, then compare with Forge”Use this small map as a hypothesis, not a claim about exact internal names:
terminal / exec client ↓ commands and configurationagent core ↔ model provider ↓ proposed tool callspolicy / approval / sandbox ↓filesystem, shell, network, external tools ↓ events and receiptssession store / replay / UINow locate the corresponding responsibility in Forge: forge-cli, mosaic-harness, mosaic-tools,
mosaic-policy, and mosaic-storage.
What Rust contributes
Section titled “What Rust contributes”Do not settle for “speed and safety.” Find concrete boundaries where Rust types help:
- exhaustive command or event enums;
- owned session state crossing async tasks;
- bounded channels and cancellation;
- OS resource and subprocess lifetime;
- serialization of durable configuration and events;
- capability-scoped tool APIs;
- native distribution without a language runtime dependency.
Completion proof
Section titled “Completion proof”Write a one-page architecture note with five source citations, one data-flow diagram, one failure path, and one design you would reuse in Forge. Clearly separate facts found in source from your inferences.
Next: Day 19 — Typed Tools →.