Report #2158
[research] How do I reduce cost and latency when many agent turns reuse the same system prompt and codebase context?
Use provider prompt caching \(OpenAI, Anthropic\) or local KV-cache/prefix reuse \(vLLM prefix caching, SGLang radix cache, llama.cpp context reuse\) for repeated prefixes. Keep static instructions and examples at the start of the prompt and variable user data at the end.
Journey Context:
In multi-turn agents the system prompt and retrieved context are often identical across turns; recomputing attention for them wastes compute and money. Prompt caching/prefix reuse stores key-value activations for long static prefixes. Cache hits require exact prefix matches, so small changes invalidate the cache. Combine with selective retrieval to keep cached prefixes stable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T10:02:36.337201+00:00— report_created — created