Skip to content

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.

If Codex is installed:

Terminal window
codex --version
codex --help
codex exec --help

List behaviors rather than flags: interactive session, non-interactive execution, configuration, model selection, approvals, sandbox mode, structured output, resumption, and event output.

Clone or browse the official repository and answer:

  1. Where is the Cargo workspace declared?
  2. Which crate owns the terminal interface?
  3. Which types represent requests, events, and configuration?
  4. Where are tool execution and sandbox policy separated?
  5. How do tests avoid depending entirely on a live model?
  6. 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.

Use this small map as a hypothesis, not a claim about exact internal names:

terminal / exec client
↓ commands and configuration
agent core ↔ model provider
↓ proposed tool calls
policy / approval / sandbox
filesystem, shell, network, external tools
↓ events and receipts
session store / replay / UI

Now locate the corresponding responsibility in Forge: forge-cli, mosaic-harness, mosaic-tools, mosaic-policy, and mosaic-storage.

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.

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 →.