Usage
To use prompt caching in your Agno setup, pass thecache_system_prompt argument when initializing the Claude model:
Extended cache
You can also use Anthropic’s extended cache beta feature. This updates the cache duration from 5 minutes to 1 hour. To activate it, pass theextended_cache_time argument and the following beta header:
Multi-block caching with per-block TTL
Split the system prompt into independently-cacheable blocks withsystem_prompt_blocks. Each SystemPromptBlock controls its own cache flag and ttl. This lets you cache static instructions while leaving dynamic per-request content uncached.
cookbook/11_models/anthropic/prompt_caching_multi_block.py
system array. system_prompt_blocks may also be a zero-arg callable that returns the list, evaluated on every request, which is how you inject dynamic content into a cached prompt without reinstantiating the model.
Tool caching
Setcache_tools=True to cache tool definitions. Anthropic caches all tools as a prefix when cache_control is on the last tool.
Working example
cookbook/11_models/anthropic/prompt_caching_extended.py