Skip to content

Prompt caching

Prompt caching lets a model provider reuse the parts of a request it has already processed, such as the tools, the system prompt, and earlier messages, instead of processing them again on every call. It is a common way to cut the cost and latency of an agent, which resends that content on every model call. Model providers cache in one of two ways: some let the request carry explicit cache points, while others support only implicit caching and decide on their own what to reuse. This page covers how Strands caches on each, and where caching falls short today. For pricing on cache writes and reads, see your model provider’s documentation.

These models take explicit cache points:

  • Anthropic Claude, on Amazon Bedrock and through the Anthropic API.
  • Amazon Nova on Amazon Bedrock.
  • OpenAI GPT-5.6 and later on the Responses API, through OpenAI or Bedrock Mantle.

To use them, set a cache configuration on the model with the auto strategy, which is also the default. Strands then places the cache points for you:

from strands import Agent
from strands.models import BedrockModel, CacheConfig
# The default Bedrock model is Anthropic Claude.
model = BedrockModel(cache_config=CacheConfig(strategy="auto"))
agent = Agent(model=model)

Strands puts the static content (tools, system prompt, and messages) before the cache point. Ephemeral content, such as the text a context injector adds for one model call, goes after it, so the injected text never enters the cache and the static prefix still reads from it on the next call. For per-provider options, see Amazon Bedrock prompt caching and OpenAI Responses.

If your model supports only implicit caching, the model provider decides what to cache. Strands can’t put dynamic content after a cache point, because there isn’t one. Content that changes between calls changes the prefix the provider compares, so some of the harness’s default settings break the cache through normal use.

Strands relies on Gemini’s implicit caching and doesn’t use its explicit cached-content API. See Gemini context caching. OpenAI GPT and xAI models through the Amazon Bedrock Converse API support only implicit caching, and Strands doesn’t cache gpt-oss there. Amazon Bedrock lists which APIs take explicit cache points for each OpenAI model in Prompt caching for models from OpenAI.

In the following cases, caching silently does nothing or costs more than leaving it off. Some are provider limits and some are current Strands limitations; each section says which.

A context injector, the context manager, and the memory manager all add ephemeral content to the latest message before a model call. On a model with explicit caching, Strands keeps that content after the cache point. On a model with implicit caching, Strands removes the earlier injected content from history on the next call, so the new request differs from the previous one at the point of the first earlier injection:

  • Providers that cache each request as a whole, such as OpenAI models on Converse, read nothing.
  • Providers that match the longest prefix they have seen lose everything after that point, which in a long conversation is often all but the tools and system prompt.

This is a current Strands limitation. To keep the cache, use a model with explicit caching.

OpenAI models on Converse support only implicit caching, so the injection gap above applies: with a context injector that fires on every model call, every call writes to the cache and none reads from it. On GPT-5.6 and later, writes cost 1.25 times the input rate. To cache these models, use the Responses API through OpenAIResponsesModelOpenAIModel with Bedrock Mantle and a cache configuration.

Converse rejects cache points for these models with an AccessDeniedException, so don’t place them by hand or use the "anthropic"'anthropic' strategy. The default auto strategy places none. To stay on Converse without paying for writes that are never read, turn implicit caching off:

from strands import Agent
from strands.models import BedrockModel
model = BedrockModel(
model_id="us.openai.gpt-6-luna",
# Converse forwards this to the model; with no cache points it caches nothing.
additional_request_fields={"prompt_cache_options": {"mode": "explicit"}},
)
agent = Agent(model=model)

This also turns off the reads you get when a request does extend the previous one, so use it only when your agent’s context changes on every call.

Each model provider sets its own limits on caching, such as which models cache, the minimum prompt size that is cached, the maximum number of cache points per request, and how long a cache entry lasts. Strands doesn’t change these limits. For the limits that apply to your model, see the model provider’s documentation: