Changing reasoning level results in cache miss
What issue are you seeing?
Within a codex session, changing the effort level to a new value causes a significant cache miss to occur. The order of change does not matter, e.g. low -> medium -> high vs medium -> low. Returning to a previously set reasoning level does not cause a severe cache miss.
The legacy [Prompt Caching 201 (https://developers.openai.com/cookbook/examples/prompt_caching_201#5-troubleshooting-why-you-might-see-lower-caching) guide lists "Changes to reasoning effort" as a potential cause of lower caching (it says, "why you might"). However, that guide states that it applies only to models before GPT-5.6.
The newer Prompt caching guide does not mention anything about reasoning levels and their effect on caching effectiveness.
It is unclear if this behavior is expected or not.
What steps can reproduce the bug?
Begin a Codex session and get a warm cache by sending two short messages. Change to an unused reasoning level, send another message, and observe a cache miss. Change to another unused reasoning level and observe another cache miss. Go back to a previously used reasoning level and observe no regression.
I've attached a simple script below that prints out data from the most recent codex session, for ease of data. Here are two examples showing how a new reasoning level results in cache miss. The second example shows that returning to a prior level does not see a cache invalidation.
The cache miss is essentially a full miss, as the cached value after a reasoning change is the same value from the first turn's cache hit (likely codex's system prompt being cached). Using opencode I observed a 100% miss.
<details>
<summary>low -> medium -> high</summary>
❯ ./tools/codex-session-debug.sh
Session: /Users/danclark/.codex/sessions/2026/07/25/rollout-2026-07-25T19-19-09-019f9b93-4d0b-7de1-8589-13db3be77d82.jsonl
Model: gpt-5.6-luna
T.C ACTION THINKING INPUT CACHE MISS HIT D_INPUT D_CACHE LOST OUT RSN FLAG
1.1 final response low 15048 9984 5064 66.3% - - - 17 0 -
2.1 final response low 15074 14080 994 93.4% +26 +4096 - 17 0 -
3.1 final response medium 15101 9984 5117 66.1% +27 -4096 4096 14 0 CACHE_REGRESSION
4.1 final response medium 15122 14080 1042 93.1% +21 +4096 - 10 0 -
5.1 final response low 15142 14080 1062 93.0% +20 +0 - 8 0 -
6.1 final response low 15157 14080 1077 92.9% +15 +0 - 6 0 -
7.1 final response high 15171 9984 5187 65.8% +14 -4096 4096 20 12 CACHE_REGRESSION
9.1 final response high 15253 14080 1173 92.3% +82 +4096 - 28 0 -
</details>
<details>
<summary>medium -> low -> medium (no miss) -> xhigh</summary>
❯ ./tools/codex-session-debug.sh
Session: /Users/danclark/.codex/sessions/2026/07/25/rollout-2026-07-25T19-22-09-019f9b96-0ab8-78e3-8f64-63771c2c98b2.jsonl
Model: gpt-5.6-luna
T.C ACTION THINKING INPUT CACHE MISS HIT D_INPUT D_CACHE LOST OUT RSN FLAG
1.1 final response medium 15244 9984 5260 65.5% - - - 12 0 -
2.1 final response medium 15264 15104 160 99.0% +20 +5120 - 6 0 -
3.1 final response low 15278 9984 5294 65.3% +14 -5120 5120 16 0 CACHE_REGRESSION
4.1 final response low 15302 15104 198 98.7% +24 +5120 - 11 0 -
5.1 final response medium 15323 15104 219 98.6% +21 +0 - 8 0 -
6.1 final response medium 15339 15104 235 98.5% +16 +0 - 19 0 -
7.1 final response xhigh 15368 9984 5384 65.0% +29 -5120 5120 102 74 CACHE_REGRESSION
8.1 final response xhigh 15477 15104 373 97.6% +109 +5120 - 5 0 -
</details>
What is the expected behavior?
I would not expect reasoning changes to affect the cache hit rate. If prompt caching is affected by the reasoning level, explicit documentation would be useful. A warning in the cli would be helpful too.
For example, claude code displays a warning with some newer models that changing effort means “the full message gets re-read on your next message.” With haiku 4.5, that warning is not displayed, and I did not observe a corresponding cache miss.
This suggests that the relationship between reasoning and prompt caching may be model specific. I am not sure if the observed behavior with gpt 5.6 is a bug or undocumented behavior.
Additional information
Script for generating the above
codex-session-debug.sh
Possibly related unexpected cache misses for images: https://github.com/openai/codex/issues/32613
1 Comment
The likely explanation is that the reasoning effort is buried somewhere at the beginning of the conversation, e.g. system prompt. As long as this is the case, I agree that both the docs and the GUI should mention that a reasoning change will invalidate the prompt cache.