
Engineering 8 min read· 28 Aug 2026· By Engineering
Multi-turn memory patterns for chatbots
Window, summary, and hybrid memory — with sample code.
Naïvely appending every message eventually blows your context window and your bill. Three patterns solve this.
Window#
Keep the last N messages. Simple, cheap, forgets everything older.
Summary#
On every Nth turn, ask the model to summarize the conversation so far. Replace old messages with the summary.
Hybrid#
Keep the last N messages verbatim + a running summary of everything older. Best of both worlds.