Skip to slide
Chapter 5 · Context Engineering and Memory
44 / 191

CHAPTER 05 · Context Engineering and Memory · 7 / 11

Managing long histories

Conversations grow past the context budget. Strategies, in rough order of preference:

  • Recent-window: include the last N turns verbatim. Simple, and often enough.
  • Summarise-and-prepend: periodically compress older turns into a running summary, keep recent turns verbatim. Preserves the gist while bounding tokens.
  • Selective recall: store all history in the database and retrieve only the turns relevant to the current message (semantic search over history). More complex; useful for very long-lived conversations.
  • Event-log replay with selective inclusion: store rich turn events durably, but include in context only what the current turn needs.

Whatever you choose, the principle holds: history lives in durable storage; you load a curated slice into context.

← → arrow keys work too