| Name | Type | Description |
|---|---|---|
type | Literal['ephemeral'] | Default: 'ephemeral'The type of cache to use, only |
ttl | Literal['5m', '1h'] | Default: '5m'The time to live for the cache, only |
min_messages_to_cache | int | Default: 0 |
unsupported_model_behavior | Literal['ignore', 'warn', 'raise'] | Default: 'warn' |
Prompt Caching Middleware.
Optimizes API usage by caching conversation prefixes for Anthropic models.
Requires both langchain and langchain-anthropic packages to be installed.
Applies cache control breakpoints to:
cache_control so static system prompt content is cached.cache_control so tool
schemas are cached across turns.Learn more about Anthropic prompt caching here.
The minimum number of messages until the cache is used.
The behavior to take when an unsupported model is used.
'ignore' will ignore the unsupported model and continue without
caching.
'warn' will warn the user and continue without caching.
'raise' will raise an error and stop the agent.