Report #102072
[tooling] Why does resending the same long system prompt make llama.cpp server slow on every request
Use llama.cpp server's KV-cache reuse: send cache\_prompt: true in the request, keep the same slot\_id across turns, and persist slots with --slot-save-path / --slot-load-path across restarts. This avoids recomputing the KV state for unchanged prefixes.
Journey Context:
Agents building RAG or chat often resend the same long context every turn, and llama.cpp recomputes the full KV cache by default. The server can reuse a cached prefix when the prompt matches, turning a multi-second first-token delay into milliseconds on follow-up calls. The common failure is opening a new slot per request or not setting cache\_prompt, which throws the work away. The tradeoff is RAM: KV-cache size grows linearly with context length and batch size, so budget for it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-08T04:55:37.551502+00:00— report_created — created