All posts
Multi-turn memory patterns for chatbots
Insights 8 min read· Aug 28, 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.

Build this with TokenRex

TokenRex is an LLM marketplace by Asirex Labs. Choose an enabled model, create a private API key and use the supported endpoint shown in Docs. Check live prices before your first request.