Cut LLM input costs with prompt caching: design cacheable prefix layouts, place cache breakpoints, pick TTLs, measure hit rates, and run break-even cost math across Anthropic, OpenAI, and Gemini. Triggers on LLM cost optimization, caching configuration, or why a cache never hits.
./install.sh prompt-caching-strategyname: "prompt_caching_strategy" description: "Cut LLM input costs with prompt caching: design cacheable prefix layouts, place cache breakpoints, pick TTLs, measure hit rates, and run break-even cost math across Anthropic, OpenAI, and Gemini. Triggers on LLM cost optimization, caching configuration, or why a cache never hits." metadata: { "includeInPrompt": true }
Turn a repeated LLM prompt into a cache-friendly layout so identical prefixes get served cheap instead of re-encoded every call. Covers breakpoint placement (Anthropic), automatic caching behavior (OpenAI), explicit context caching (Gemini), hit-rate measurement, and the break-even math that decides whether caching pays off.
cache_control breakpoints (up to 4 per request).CachedContent API for long-lived prefixes. [tool definitions] <- cache (Anthropic: breakpoint on last tool block)
[system prompt] <- cache (Anthropic: breakpoint on last system block)
[few-shot examples] <- cache
[retrieved documents] <- cache only if reused across calls
[conversation history] <- cache up to the last stable turn
[current user message] <- never cache; changes every time
A single byte difference in the prefix invalidates everything after it. Timestamp, request id, or session token placed early in the prompt silently kills every hit.
{"type":"ephemeral","ttl":"1h"}, Gemini CachedContent) fits bursty workloads with 20-60 minute gaps. The 1-hour write costs 2x, so it needs 3+ reads to break even.cache_read_input_tokens > 0 on the second request, and cache_creation_input_tokens = 0 after the first write.usage.prompt_tokens_details.cached_tokens > 0.bin/cache_math.py to compute break-even and savings from real usage numbers. Rule of thumb: cache only prefixes reused at least twice within the TTL window.A caching recommendation states: provider, what content sits at each cacheable layer, where breakpoints go (Anthropic), the TTL and why, the break-even point in requests, and how the agent will verify hits from usage fields. If caching does not pay off for a workload, say so and recommend skipping it.
publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e
No ratings yet — be the first to rate it.