Cache Playbook: ChatGPT / Codex Edition
by Mark Laursen
$14
68% of agent input tokens served from cache across a multi-turn Codex CLI session. Measured. n=3, variance under 1%.
For developers running Codex CLI agents whose usage is token-metered or credit-billed.
The ChatGPT/Codex companion to the Claude Edition: the same measurement methodology, run on Codex CLI.
The headline, measured: a code-review agent reloading a ~40K-token identity across a 5-turn Codex CLI session. When you resume a thread, the stable prefix is replayed and OpenAI's automatic prompt caching serves it from the backend cache. Result: 68% of input tokens came back cached (mean of 3 runs, standard deviation 0.75%), climbing from a cold fresh-prefix turn 1 to 80%+ by turn 5. On token-metered or credit-billed usage, where cached input is charged at roughly 10% of standard input, that is about a 61% lower input-token cost.
Inside v1.0:
How OpenAI's automatic prompt caching actually works: exact-prefix matching, the 1024-token minimum, and what `resume` replays into the cacheable prefix
Identity and instruction structuring so the cacheable prefix stays stable across turns
The within-session climb: why a fresh-prefix turn 1 is cold and how caching compounds as the prefix repeats
Cache retention reality: exact-prefix + routing locality, the ~5-10 minute inactivity window, and why hits are best-effort not guaranteed
Where the savings are real: token-metered and credit-billed usage. Plain-English note on why caching cuts token charges but does not change flat-rate plan limits
Failure modes: prefix drift, what evicts the cache, and what kills your hit rate
Reproducibility bundle: the exact harness, raw per-turn token telemetry, and aggregator behind the numbers above
Honest about scope: these are cached-input token reductions from OpenAI's automatic prompt caching, observed during resumed Codex CLI sessions on a synthetic agent-identity-reload workload. The cost benefit applies to token-metered or credit-billed usage; it does not expand flat-rate Plus/Pro rate limits. Output tokens are unaffected. The harness is yours to re-run against your own workload.
Written by Mark Laursen. 18 months of production AI agent work behind it. Published by Marathon Variety.
Format: PDF + reproducibility bundle (harness scripts, raw telemetry, aggregator).