Auditing 20 open-source LLM apps reveals how most silently break their own prompt cache
protrener · reddit · 2026-11-27
The author of leanprompt (free, Apache-2.0) audited open-source LLM apps like gpt-researcher, anything-llm and bilingualbookmaker and found recurring cache killers:
- Volatile content at the top — a per-second timestamp on line one of the system prompt makes everything after it uncachable (6.7M cacheable tokens wasted per 1,000 calls in one example app).
- Sliding history windows — trimming the oldest message each turn changes the prefix, re-reading the whole conversation.
- No cache marks on Anthropic — with no marks, 0 cached tokens over 29 replayed turns; with 3 marks, 92% of prompt tokens hit cache.
- Gateway caching off by default in one app's default path.
- Cost meters ignoring cache fields — 3 of the first 4 apps read only inputtokens, so dashboards were wrong.
- Paying twice for output — retrying truncated answers from scratch or truncated batches (one fix merged upstream in bilingualbookmaker #590).
A reverse lesson: moving the date to the end of the prompt to protect the cache dropped correct date answers from 10/12 to 1/12 without helping the cache — meaning comes first, then cache.
Smaller finds: toggling thinking on/off between turns on a hybrid-thinking model lost 47% of the reusable prefix; tools built from unsorted dicts change order between calls.
How it works: leanprompt ships skills for coding agents — /leanprompt audit ranks token waste, fix proposes diffs, measure proves changes with before/after numbers; install via npx leanprompt install. Audit numbers are estimates; measure turns them into measurements.
More from coding & agent
- AWS open-sources Context Ontology Accelerator for more accurate, explainable AI agents — adnan_hashmi · 2026-11-28
- The most underrated LLM eval: did the model do what it said it did — sophiamyang · 2026-11-28
- Dev builds niche pixel RPG with Perplexity Teammates orchestrating art and story subagents — cameronstow · 2026-11-28
- Neon agent runs a single task for 49 straight hours — seanmcdonaldxyz · 2026-11-28
- New "banger" model incoming, says AI evaluator who'll test it on vision agent harness — mervenoyann · 2026-11-28
- Do Codex and Claude Already Count as AI Agents? User Says They Cover Most Needs — Electrical_Pen_4989 · 2026-11-28