How It Works
Quick Start
1
Simple Usage
Automatic on supported models when memory is enabled:
2
With Configuration
Make prompt caching explicit:
How It Works
CACHE_BOUNDARY is a reserved marker constant ("--- CACHE_BOUNDARY ---") on praisonaiagents.memory.memory for future structured-cache metadata. No current provider consumes it, so it is intentionally not appended to the outgoing system prompt. Providers hit the cache because the prefix is deterministic — not because of any marker.Configuration Options
Set via
Agent(caching=True) or Agent(caching=CachingConfig(...)).
The include_cache_boundary flag on build_cache_optimized_context() controls whether the returned dict contains the marker; it does not affect what is sent on the wire.
Best Practices
Use supported models
Use supported models
OpenAI, Anthropic, Bedrock, and Deepseek support caching — local models like Ollama do not.
Keep instructions stable
Keep instructions stable
Changing system prompts between turns breaks the cached prefix.
Enable memory for full optimisation
Enable memory for full optimisation
Without memory, only tool sorting applies —
memory=True activates the cache-optimised context path.Let the SDK sort tools
Let the SDK sort tools
Do not manually reorder tool lists — the SDK sorts deterministically by name.
Related
Prompt Caching
Deterministic memory ordering for cache hits
Prompt Caching CLI
Enable caching from the command line

