Skip to content

[FEATURE] Caching support for all models #1140

Open
1 of 10 issues completed
Open

Description

@dbschmigelski

Goal

Every model provider supports prompt caching. strategy="auto" picks the best mechanism for each provider×model using one documented resolution table, in both SDKs. CacheConfig stays backward compatible.

Mechanisms

The different mechanisms that we vend as strategies:

  • A: provider caches the prefix on its side (implicit)
  • B: client places cache points
  • C: provider places the cache point
  • D: pre-created cache resource. Modifiers: cache_key, ttl.

Already landed

#3681 #3949 #3985 #4186 #3986 #4055 #4127 #4232 #4083 #4080 #4193 #4219 #4617

1. Core

2. Provider gaps

3. Correctness

4. Caching on by default

  • Turn on caching by default

Activity

  1. changed the title [-][FEATURE] Prompt caching support for all models[/-] [+][FEATURE] Caching support for all models[/+] on Mar 2, 2026
  2. chosw1029 commented on Apr 19, 2026

    @chosw1029

    Hi — we're hitting this on the direct Anthropic API path and have a working patch that adds parity with BedrockModel:

    • AnthropicModel.stream() / format_request() now accept system_prompt_content and emit the system field in Anthropic list-form with cache_control: {"type": "ephemeral"} on the text block immediately preceding a cachePoint.
    • format_chunk() metadata events expose cacheReadInputTokens / cacheWriteInputTokens (matching BedrockModel's field names so existing observability code works unchanged).

    Verified against a live Claude Sonnet 4.5 run: subsequent requests with an identical system prefix now report cache_read_input_tokens > 0 where the pre-patch code reported 0.

    Opening a PR shortly. Happy to adjust scope if you'd like anything trimmed or staged differently.

  3. joshwand commented on May 19, 2026

    @joshwand
    Contributor

    Is this ticket limited to system prompt caching, or does it include arbitrary cache points for multi-turn conversations?

  4. added
    area-modelRelated to models or model providers
    pythonPull requests that update python code
    on May 27, 2026
  5. removed
    pythonPull requests that update python code
    on Jun 9, 2026
  6. added
    pythonPull requests that update python code
    on Jul 10, 2026
  7. added theissue type on Jul 10, 2026
  8. 6 remaining items

  9. removed their assignment
    on Oct 20, 2026
  10. moved this from Intake to We're Working On It in Strands Agents Roadmapon Oct 28, 2026
  11. mkmeral commented on Nov 2, 2026

    @mkmeral
    Member

    Related #5700

  12. removed their assignment
    on Nov 3, 2026
  13. joshwand commented on Nov 4, 2026

    @joshwand
    Contributor

    @maxmilian It's good to see at least one provider supporting it, but my question was more one of intent/scope—would arbitrary and/or automatic cache points be supported across all models, with a uniform interface? A few data points I notice:

    • Last-user-message auto-injection exists in Python only on BedrockModel and AnthropicModel, each implemented separately with different handling of user-placed points; TS messagesTTL covers more providers, but in neither SDK is placement configurable, and Python has no messages_ttl. [FEATURE] Move cache_config onto BaseModelConfig #5130 moves cache_config onto BaseModelConfig, but not the placement logic
    • With cache_config set, AnthropicModel strips all cache points except the first in the last user message, so manual placement and automatic caching are mutually exclusive there
    • LiteLLMModel inherits OpenAIModel's message formatting, which drops cachePoint blocks outside the system prompt, regardless of the target model

    Seems like there's several different levels at which it could be supported:

    1. A provider-agnostic uniform API for inserting arbitrary cache points (e.g. a cachePoint block in any message is honored or reported identically on every provider, instead of rendered, stripped, or silently dropped depending on the model class)
    2. Uniform interface/support for provider-specific "automatic" cache point insertion (e.g. Anthropic, OpenAI, LiteLLM)
    3. A Strands-side implementation of automatic cache point insertion for providers without an automatic strategy or where the user wants to tune the strategy themselves (e.g. every N messages/tokens)

    (cc @joshwand-aws)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-modelRelated to models or model providersenhancementNew feature or requestpythonPull requests that update python codeready for contributionPull requests welcome

Fields

Language

Python

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions