The --prompt-caching flag enables prompt caching to reduce costs when using repeated or long system prompts.
Quick Start
Usage
Basic Prompt Caching
Expected Output:
Combine with Metrics
Supported Providers
How It Works
- Enable: The
--prompt-caching flag activates caching
- Hash: System prompt is hashed for cache lookup
- Check: Provider checks if prompt is cached
- Reuse: Cached prompts skip re-processing
- Save: Reduced token costs for cached portions
Cost Savings
Prompt caching can significantly reduce costs for:
Examples
Long System Prompt
Document Analysis
Multi-Query Session
Programmatic Usage
Best Practices
Use prompt caching when you have long system prompts or make repeated calls with the same context.
Caching is most effective for stable prompts. Frequently changing prompts won’t benefit from caching.
Cache Behavior
Beyond the CLI Flag
The --prompt-caching flag controls whether caching is requested on the wire, but Praison now automatically arranges memory and tools cache-friendly for supported models — even without the CLI flag.
In code, your agent’s system prompt, memory context, and tools are automatically organized to maximize cache hits:
- Deterministic tool order: Tools sorted by function name
- Stable memory prefix: Memory sections emitted in fixed order
- Reserved boundary constant: A
CACHE_BOUNDARY marker is defined for future structured-cache metadata; today the caching benefit comes entirely from stable ordering above
See Prompt Cache Optimization for the complete pipeline integration.