Oleksandr Kuzmenko, EditorPublished 6 min readAI-assisted · editor-reviewed
TL;DR
- Codex CLI adds ~9,400 tokens of system framing, tool definitions, and metadata to initial prompts.
- AGENTS.md files are merged hierarchically from repo root to the execution working directory.
- Large command outputs are truncated but still increase payload size significantly before triggering history compaction.
Payload Decomposition and Initial Baseline
Capturing raw JSON HTTP requests from Codex CLI 0.145.0 reveals significant prompt wrapping. A basic 16-character user input (Reply with pong.) produces a raw request body of 42,980 bytes. When encoded using o200k_base, the payload estimates at approximately 9,435 tokens. The wrapped prompt accounts for roughly 25 tokens (~0.3% of the request payload), while system framing, permissions, context metadata, and bundled tools make up the remaining 99.7%.
Instruction Chaining across AGENTS.md Files
Codex builds instruction chains by scanning upward from the working directory to the repository root:
- Starting in a child directory automatically aggregates
AGENTS.mdfrom the root down to that child folder. - Executing file listing commands like
ls childfrom the root does not trigger automatic loading ofchild/AGENTS.mdinto the instruction chain. - Synthetic markers demonstrate that instruction text is passed verbatim in subsequent requests, directly impacting the prompt baseline.
Output Truncation and History Compaction
Command execution output is appended directly into execution history. While a 10,000-line log is pruned to head-and-tail samples, payload size still spikes from ~9,584 tokens to 25,835 tokens. Compaction triggers when approaching configured limits (e.g., a 12,000 token threshold), executing a dedicated summary request (68,375 bytes / ~21,408 tokens) before rebuilding conversation history around retained messages.
