AI Development
Featured

Prompt Caching and Warm Context for Coding Agents, Explained

How prompt caching works for Claude Code, Codex and Gemini, what makes a cache go cold, how to keep context warm, and why a warm cache is not the same as team context.

Short answer: prompt caching lets a model provider reuse the unchanged beginning of a request (the prefix) so a coding agent pays a much lower rate for context it has already sent. A cache is "warm" while that prefix is still inside its lifetime, typically 5 minutes to 1 hour, and "cold" after it expires or after something changes the prefix, such as switching models. Warm cache saves money and time within a session, but it is not memory: when it expires, everything has to be sent again. Durable team context (decisions, specs, standards and a map of the codebase) is a separate layer that survives every cache expiry.

Facts below come from Anthropic, OpenAI and Google's official documentation, checked on 28 November 2026. Prices and lifetimes change often; check the provider's page before relying on a number.

Why coding agents depend on caching

A coding agent does not send one prompt. A single "fix the failing test" task can be dozens of model requests, and each one resends the system prompt, tool definitions, project instructions and the conversation so far. Without caching, a long session pays full price for the same tokens again and again. With a warm cache, the repeated prefix is billed at a fraction of the normal input rate, and responses start faster.

How the major providers cache

ProviderHow it is enabledDefault lifetimeCost of a cache readCost of a cache write
Anthropic (Claude API)Opt in with cache_control, automatic or explicit breakpoints5 minutes (refreshed free on each read); 1 hour optional0.1x base input on most models; lower on the newest1.25x (5 minutes) or 2x (1 hour)
Claude CodeAutomaticMain conversation: 1 hour on a subscription within plan usage, otherwise 5 minutesAs aboveAs above
OpenAI APIOn by defaultModel-dependent; newest models default to a 30-minute minimum, 12 hours optionalDiscounted up to 95%1.25x or 2.5x on the newest models; none on older models
OpenAI Codex (credits)ImplicitNot documentedCached-input rateNo separate cache-write charge
Google GeminiImplicit caching on by default; explicit caching on some modelsExplicit: 1 hour unless setDiscounted cached-input rateExplicit caching adds a storage fee

Anthropic's own break-even rule is useful: a 5-minute cache write pays for itself after one cache read, and a 1-hour write after two. Each provider also has a minimum prefix length below which nothing is cached, ranging from about 500 to 4,000 tokens depending on the model.

What makes a cache go cold

Caches match exact prefixes, so anything that changes the early part of the request starts a new cache. Claude Code's documentation lists the common causes:

  • Switching models: each model has its own cache.
  • Turning fast mode on or off: each speed has its own cache.
  • Adding or removing an MCP server or plugin that changes the tool definitions (unless tools are deferred through tool search).
  • Compacting the conversation, and upgrading the agent.
  • Waiting past the lifetime, for example during a long test run or a lunch break.

Editing files in the repo, editing CLAUDE.md mid-session, running skills or changing permission mode do not break the cache. In Claude Code, /usage shows the prompt cache hit ratio and the likely cause of the last miss.

How to keep context warm

  • Stay on one model per session and avoid toggling settings that change the prefix.
  • Use the longer lifetime (1 hour on Anthropic, longer options on OpenAI) for sessions with long pauses, where the higher write cost pays off.
  • Load tools lazily so connecting tools mid-session does not rewrite the prefix.
  • Fork rather than restart for parallel work: in Claude Code a fork inherits the parent's cache, while a fresh subagent does not.
  • Measure it: track cache read and cache creation tokens per session, not just total spend.

Warm cache is not team context

A warm cache only lasts minutes to hours and belongs to one session, often on one machine. It does not help the next developer, the next agent or next week's session. What makes agents consistent across a team is durable context that is reloaded every time: the decisions the team made, the approved spec, the coding standards and an up-to-date picture of how the codebase fits together. Caching makes resending that context cheap; it does not replace it.

This is the layer SignalsAI provides. In the SignalsAI workspace, the team's decisions, PRD and specs are attached to every developer's build context, whichever coding agent they use. The SignalsAI Gateway's repo-aware policies inject each repository's standards into every prompt routed through it and keep a map of how the code's modules connect warm, so new prompts reuse it instead of re-walking the repository. Together, durable context plus a warm cache means agents start informed and stay cheap.

“Knowing where our AI spend goes is going to be critical. Signals shows me that, and where each team is on the way to fully AI-native, with the data to get them there.”

— VP Engineering, unicorn quick commerce company

Related: shared context and standards for coding agents and context engineering for coding agents.

#prompt-caching #coding-agents #context-engineering

Curious what this looks like for your team?

Every engineering team has hidden efficiency gains waiting. Let us find yours together.

Free exploration · Zero pressure

Related Articles

AI Development6 min

Shared Context and Standards for Coding Agents: Stop Re-Explaining Context to AI

Shared decisions, standards that travel with every prompt, and warm codebase context: which tools share context across a team and its agents, and which actually enforce it.

AI Development6 min

Context Engineering for Coding Agents: The Missing Layer in AI-Native Development

Context engineering is not dumping more files into an agent. It is deciding what context matters, when it applies, and which decisions are authoritative.

AI Development7 min

The Best Multiplayer AI Workspaces for Software Teams (2026)

SignalsAI, Superconductor, Coshell, Cursor Projects, Nimbalyst, Slack Code, Claude Tag and more, compared by what the team actually shares: live sessions, context, artifacts or review.