Enum Class AnthropicCacheStrategy

java.lang.Object
java.lang.Enum<AnthropicCacheStrategy>
org.springframework.ai.anthropic.AnthropicCacheStrategy
All Implemented Interfaces:
Serializable, Comparable<AnthropicCacheStrategy>, Constable

public enum AnthropicCacheStrategy extends Enum<AnthropicCacheStrategy>
Defines the caching strategy for Anthropic prompt caching. Anthropic allows up to 4 cache breakpoints per request, and the cache hierarchy follows the order: tools -> system -> messages.
Since:
1.1.0
Author:
Mark Pollack, Soby Chacko
  • Enum Constant Details

    • NONE

      public static final AnthropicCacheStrategy NONE
      No caching (default behavior). All content is processed fresh on each request.
    • TOOLS_ONLY

      public static final AnthropicCacheStrategy TOOLS_ONLY
      Cache tool definitions only. Places a cache breakpoint on the last tool, while system messages and conversation history remain uncached.
    • SYSTEM_ONLY

      public static final AnthropicCacheStrategy SYSTEM_ONLY
      Cache system instructions only. Places a cache breakpoint on the system message content. Tools are cached implicitly via Anthropic's automatic lookback mechanism.
    • SYSTEM_AND_TOOLS

      public static final AnthropicCacheStrategy SYSTEM_AND_TOOLS
      Cache system instructions and tool definitions. Places cache breakpoints on the last tool (breakpoint 1) and system message content (breakpoint 2).
    • CONVERSATION_HISTORY

      public static final AnthropicCacheStrategy CONVERSATION_HISTORY
      Cache the entire conversation history up to (but not including) the current user question. Places a cache breakpoint on the last user message in the conversation history, enabling incremental caching as the conversation grows.
  • Method Details

    • values

      public static AnthropicCacheStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static AnthropicCacheStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null