AI Coding Agents
How to read Codex CLI prompt cache hit rates
In Codex CLI Responses API usage, cached_tokens counts input tokens served from cache, billed at the cached-input rate on API keys. Some Codex session logs expose cached_input_tokens. Compare a normal continuation with a fork or resume under the same model and sign-in mode, then inspect writes and request shape before attributing a drop to expiry or a client change.
In Responses API usage for Codex CLI, cached_tokens counts input tokens served from cache. On API keys, those tokens are billed at the cached-input rate. Some Codex session logs expose cached_input_tokens. Compare a normal continuation with a fork or resume under the same model and sign-in mode, then inspect writes and request shape before attributing a drop to expiry or a client change.
What Codex keeps stable across turns
OpenAI’s archived cookbook describes the Codex CLI’s design before GPT-5.6. System instructions, tool definitions, sandbox configuration, and environment context keep the same content and order between requests. The agent loop appends messages when runtime configuration changes, with a new working directory or approval mode given as examples. Appending leaves an existing cache boundary where the next request can still match it. See Prompt Caching 201.
That design gives you a baseline to test. When the session continues and the agent appends a user turn or tool result, check how much of the earlier input is read from cache. When a fork inherits the transcript, check whether the rendered prefix it sends also matches. The current OpenAI API guide lists tool order, schemas, and request settings that affect rendering. A matching conversation transcript gives you only part of that comparison.
The OpenAI API guide as of November 30, 2026 says GPT-5.6 and later handle cache routing automatically. An older Codex report about a thread-derived key on GPT-5.5 gives you a historical comparison for that model and client. Compare the OpenAI API guide and the OpenAI caching changes guide.
What the Codex issue reports show
Issue states below are as of November 30, 2026. The table describes what each user reported or requested. The cited client, authentication, endpoint, and model place limits on comparisons across rows.
| User report | State and open date | Reported behavior or request |
|---|---|---|
| #62312 | Open, Nov. 18, 2026 | In tests with GPT-6.2 Sol and Astra, repeated top-level instructions returned zero cache reads and writes for that content, while the same text in a leading developer message reused cache after the first step. The report shows this on API-key and ChatGPT sign-in paths and records diagnostics returning cache_hit despite zero read and write counters in the instructions runs. |
| #59977 | Open, Nov. 6, 2026 | Codex App forks sent 13 tool definitions absent from their parents. The reporter measured this with a custom Responses-compatible provider serving Claude models and attributed the first fork’s rewrite to the changed tools. |
| #24704 | Open, May 27, 2026 | On Codex CLI 0.133.0 with GPT-5.5, the reporter says a forked subagent got a child-specific prompt_cache_key despite inheriting context. They suspected the key change prevented the child from reusing the parent’s cache. |
| #35300 | Open, July 25, 2026 | The reporter said Codex could not emit prompt_cache_breakpoint and compared replays with distinct final user messages. The unmodified requests showed 0% hits, while adding a breakpoint to the stable developer prefix produced 98.6% hits in the reporter’s test. Their same-session append-only turns already reached roughly 98%. |
| #30425 | Open, June 28, 2026 | The user observed zeros despite a stable cache key and repeated or same-prefix requests. They list successful replays that still had zero cached tokens after they addressed a local timeout. |
| #60379 | Open, Nov. 9, 2026 | The reporter saw usage.input_tokens_details.cached_tokens intermittently drop to zero and recover on a persistent WebSocket. Their direct Codex comparison used subscription authentication and sent requests serially on one connection. |
| #63587 | Closed Nov. 24, 2026, opened Nov. 24, 2026 | A GPT-6.2 Sol tool-output continuation on the same socket reported zero cached tokens despite a continuation ID and unchanged tools. The next request read 46,848 cached tokens. |
| #59649 | Open, Nov. 5, 2026 | A feature request asks for a visible lifetime policy and predictable reuse after a 55-minute pause in signed-in Codex. The gap is the reporter’s planning question. |
| #20301 | Open, Apr. 30, 2026 | A Codex CLI 0.125.0 user on WSL2 reported seeing cached_input_tokens less frequently with GPT-5.5 than with GPT-5.4. The user also described stronger reuse with GPT-5.5 in OpenCode. |
The current OpenAI guide gives a documented explanation for one part of #62312. Models starting with GPT-6.2 render top-level instructions after input, outside eligible breakpoints, and bill those instruction tokens as ordinary input. The guide puts reusable instructions in a leading developer message. The issue’s discrepancy between diagnostics and usage belongs to the reporter’s test. When you control an API integration, use the usage counters to estimate billed cost.
The two fork reports give you two variables to compare. #24704 concerns a key on an earlier model. #59977 concerns the list of tools on a Codex App fork with a different provider setup. If a fork misses on your setup, compare both its available tools and request settings with the parent before attributing the result to the thread identifier. For the intermittent WebSocket reports, look at the turns immediately before and after each zero. Recovery on the next turn is a different observation from a prefix that never gets a cache read.
Measure a continuation, fork, and idle return
- Create a warm baseline. Start a test thread with a model and sign-in mode you normally use. Keep the working directory, configured tools, and sandbox setup steady. Build a useful stable context and send a short follow-up inside the same thread. Note which responses have nonzero cached input.
- Take a matched comparison. Compare a short normal continuation with a short task on a fork made from a similar point. If you use inherited-context subagents and your session logs look like the ones in #24704, inspect the forked child’s
input_tokensandcached_input_tokensin the usage events. Record the first request and a later request in the child. They distinguish a one-time rebuild from low reuse throughout the fork. - Check each source of usage at its own level. Where you have raw Responses API usage, read
usage.input_tokens_details.cached_tokensand, on supported models,cache_write_tokensin that same object. Useusage.input_tokensfor total input. Compare per-response counts or deltas between cumulative samples. Aggregate a token hit rate as total reads divided by total input for the selected requests, so a short turn receives proportionate weight. - Test a break separately. Once the baseline has cached reads, write down the elapsed time before continuing after a break. Hold the model and setup steady. Compare the first response after the gap with the next one. Use that result for your own workflow. #59649 asks what policy applies to a signed-in thread, so an API retention setting alone cannot answer the product question.
- Log an intermittent miss with surrounding turns. Record the client version, model, authentication mode, and response ID when exposed. Note whether the request followed a fork, resume, tool change, or transport reconnect. If a sanitized request comparison is available, find the earliest changed tool, instruction, or conversation item. Include the previous and next input and cache counters to show whether caching recovered.
Suppose an ordinary continuation reads 30,000 of 32,000 input tokens. A first fork response reads zero of 32,000, and the next fork response reads 32,000 of 34,000. These are illustrative counts. The two fork requests together read 32,000 of 66,000 tokens, or about 48.5%, even though the second request by itself reads about 94%. If your workflow routinely starts a fork for a single action, the first response deserves its own line in your comparison. If you run multi-turn forks, include all the child’s turns and the cost of its first write if that counter is available. For either workflow, retain the normal continuation as a reference and track the shares over comparable workloads before concluding that a changed configuration improved reuse.
Record the first turn of a fresh thread separately from later turns, too. If you see a write after an established run of cache reads, compare it to the preceding turn’s history and write count. Group results by startup, ordinary continuation, fork, or idle return before calculating a session-wide read share.
Estimate the API cost of a zero-read turn
Use the committed GPT-6.2 Sol API rates per million tokens. Input costs $2, output $10, reads $0.10, and 30-minute writes $2.50. Assume one turn sends a 48,000-token reusable prefix plus 2,000 tokens after the last eligible breakpoint, such as top-level instructions on GPT-6.2, then produces 500 output tokens. Price each bucket independently. Ordinary input equals total input minus cached reads and writes, so a zero in the read counter still leaves the write counter to check.
| Assumed prefix outcome | Token-rate calculation divided by 1,000,000 | Estimated turn cost |
|---|---|---|
| Read all 48,000 | 48,000 × 0.10 + 2,000 × 2 + 500 × 10 | $0.0138 |
| Process all input at ordinary rates, as in explicit-only mode with no breakpoints | 50,000 × 2 + 500 × 10 | $0.1050 |
| Write all 48,000 with a 30-minute TTL | 48,000 × 2.50 + 2,000 × 2 + 500 × 10 | $0.1290 |
In implicit mode, the breakpoint advances to the end of the latest eligible message. If the 2,000 new tokens are in an eligible user message or tool response, assume the new tail is written at the 30-minute rate. The warm turn then costs an estimated (48,000 × 0.10 + 2,000 × 2.50 + 500 × 10) / 1,000,000 = $0.0148. Writing the entire 50,000-token input costs an estimated (50,000 × 2.50 + 500 × 10) / 1,000,000 = $0.130.
Both zero-read outcomes in the table have the same token hit rate. The write outcome costs an estimated $0.024 more on this turn and can support cheaper reads on later turns. Record whether those later reads happened before pricing the effect of a fork or a series of misses. Use the list-price API estimates for token billing and the signed-in plan meter for plan allowance. See current ByteCosts model rates.
Choose the next comparison
- The parent hits and the fork misses. Compare the ordered tools and settings at the fork point. See cache-safe subagent forking.
- New requests reuse instructions but diverge at the final question. If you own the API integration, measure a supported explicit breakpoint under the newer OpenAI caching regime. Treat the replay in #35300 as a comparison to test with your own payload.
- A similar turn suddenly reports zero. Save the surrounding usage and compare the earliest changed part of the request. See debugging a prompt cache miss with a prefix diff.
- You’re comparing two workflows over several sessions. Report billed read and write totals beside the weighted read ratio, using the same measurement scope for each. See measuring prompt cache hit rate.
Sources
- Prompt Caching 201, archived cookbook (OpenAI, accessed 2026-11-30)
- OpenAI API prompt caching guide and usage fields (OpenAI, accessed 2026-11-30)
- Codex report on GPT-6.2 instructions (GitHub, accessed 2026-11-30)
- Codex report on forked subagent lineage (GitHub, accessed 2026-11-30)
- Codex report on explicit breakpoints (GitHub, accessed 2026-11-30)
- Codex report on intermittent WebSocket usage (GitHub, accessed 2026-11-30)
- Codex request for cache lifetime visibility (GitHub, accessed 2026-11-30)
How this note was produced
Drafted with AI assistance from committed ByteCosts pricing snapshots and deterministic cost formulas. Figures are grounded in the linked sources (last updated 2026-11-30). Read our editorial & automation policy, inspect the methodology, or report a discrepancy.
How to read Codex CLI prompt cache hit rates. ByteCosts. Updated 2026-11-30. https://bytecosts.com/blog/codex-cli-prompt-cache-hit-rate/