Developer Tools & APIs

OpenAI extends prompt caching to 12 hours for long-running agents and coding workloads

OpenAI's 12-hour prompt cache cuts repeated-context costs in the API, Codex, and ChatGPT Work for agents that go quiet between turns.

developer tools apis category

On 20 October 2026, OpenAI shipped day 16 of its “28 Days of Quality of Life Improvements” programme with two related updates: a 12-hour prompt cache option for the Responses API, followed shortly by the same extended caching arriving in Codex and ChatGPT Work. The previous maximum was 30 minutes. That gap sounds small, but for anyone building agents or doing long coding sessions, it has a meaningful effect on cost.

What prompt caching is and why the window matters

When you send a request to the API, OpenAI can store a prefix of that prompt so that subsequent requests reuse the cached version rather than processing the same tokens from scratch. Cached reads are charged at a fraction of the ordinary input rate: 0.1x on most models, and 0.05x on GPT-6.1 Sol. The catch has always been that the cache only lives for 30 minutes by default. If your agent goes quiet for longer than that, say waiting on a human review, a CI pipeline, or a scheduled job, the cache expires and you pay full price again on the next wake-up.

A 12-hour window changes that calculation for most working-day scenarios. An agent that wakes up every hour or two throughout a day can now reuse the same cached system prompt, tool definitions, and shared context across all of those turns rather than paying to process them fresh each time.

How to use it in the API

The new option is available on GPT-5.6 and later models via the Responses API. You set it with a single parameter:

prompt_cache_options.ttl: "12h"

The default remains "30m". You can also mix both values in a single request: put material that stays constant throughout the day, such as your system prompt and tool list, at the start with "12h", and use "30m" for session-level context that changes more often.

One thing worth noting: the minimum prefix that can be cached is 1,024 tokens, so very short prompts will not benefit. Also, “12h” is a minimum lifetime, not a hard expiry. OpenAI may retain the cache entry for longer, and equally, a valid lifetime does not guarantee every request will hit the cache. It is a probabilistic saving, not a billing guarantee.

The cost trade-off

The write rate for a 12-hour cache entry is 2.5x the ordinary input-token price for GPT-5.6 and later. The 30-minute write rate is 1.25x. These are total write rates, not surcharges on top of standard input pricing. Cache reads are the same cheap rate regardless of which lifetime you chose.

The maths works in your favour once you know the agent will come back to the same context more than a couple of times across a day. A single long system prompt cached at 2.5x and then read four times at 0.1x costs considerably less than paying full price on each of those four reads. The break-even point depends on your prompt length and how often requests hit the cache, so it is worth running the numbers against your specific workload before switching everything to 12 hours.

What this means for Codex and ChatGPT Work users

For logged-in users of Codex and ChatGPT Work, the Codex lead at OpenAI stated on X that the cache is kept indefinitely, meaning there is no penalty for returning to an old conversation after several hours. You pick up where you left off without the model reprocessing the full context at full cost.

That “cache forever” claim has not been formally documented yet, so treat it as a stated intention rather than a contractual commitment. The practical effect, though, is that long Codex sessions and Work conversations should feel more continuous and less expensive to resume.

The broader context

This is part of OpenAI’s 28-day campaign of incremental improvements to Codex, ChatGPT, and the API. Earlier days in the programme brought things like GPT-6.1 Sol’s context length rising to 500k tokens by default (day 7), free Auto-Review (day 2), and the ability to edit any user message in Codex (day 14). The format is deliberately modest: one clear improvement per day for the people who use these tools regularly, without the fanfare of a major launch event.

The timing also puts OpenAI in direct competition with DeepSeek, which simultaneously open-sourced DeepInfer, its production inference stack, with support for up to 72-hour prompt caching. Both are clearly targeting the same problem: persistent agents that need to reuse context across long gaps. OpenAI’s approach stays within its managed API model; DeepSeek’s is self-hosted. Different audiences, same underlying pain point.

What this means for you

If you are building agents that have idle periods between turns, 12-hour caching is worth evaluating. The write cost is higher, but if your agent shares a large system prompt or tool list across many calls in a day, the read savings compound quickly. The mixing option is particularly useful: no need to choose one lifetime for everything. Stable context at the top gets "12h", dynamic context lower down keeps "30m".

If you are a Codex or ChatGPT Work user rather than an API developer, the change is largely invisible to you. Sessions should just be cheaper to run and smoother to resume, with less repeated processing in the background when you return to a task after a break.

For older models using the separate prompt_cache_retention parameter, nothing changes. The new prompt_cache_options.ttl setting is only for GPT-5.6 and later on the Responses API.