Rolling chat summary at the top of the prompt busted prompt caching — here's the simple fix
npmBROKE · reddit · 2026-12-03
An indie developer of a Spanish practice bot traced two bugs to one wiring mistake: a tester's "Mexican Spanish" preference kept reverting, and API costs stayed high.
Root cause: a rolling chat summary sat at the top of the system prompt, ahead of the long correction rubric and few-shot examples. A background job rewrote the summary every 15 turns, shifting the byte prefix and busting the cache on everything below; four rounds of summarization had also blurred two explicit rules into "prefers casual practice."
Fix (no agent framework needed):
- Put the frozen shared rules and examples first as a stable prefix;
- Move long-term learner preferences to a memory store (MemoraX API keyed by userid), retrieved once per session and appended as a user message after the static prefix;
- Keep SQLite for accounts and raw logs; the summary never touches the prompt prefix.
Result: cache hit rate recovered, and the bot reliably stuck to Mexican Spanish without dumping grammar tables.
More from coding & agent
- A Year-Old Bet on SQL as Context Engine Has Paid Off Significantly — teodorio · 2026-12-03
- Automated purchasing with n8n and local Qwen: which supplier quote format works best in practice? — Syosse-CH · 2026-12-03
- Two-hour workshop teaches live prompt-injection attacks and defenses for AI agents — Al_Grigor · 2026-12-03
- OpenClaw adds PostgreSQL storage backend for enterprise Gateway deployments — vincent_koc · 2026-12-03
- Dev adds remote MCP to workout app: read-only tools, app-side approval for any changes — Damian-Gymfile · 2026-12-03
- Telling Claude "I'm going to bed" stops it from blocking with questions — paul_cal · 2026-12-03