Building with AILesson 44 of 80

Module 5 · Conversation, memory and the interface

Compacting history: sliding windows, summaries and what gets lost

In this lesson

  • 9 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 2 of 9 in this chapter

This chapter’s goalBuild the stateful, user-facing half of an AI feature: a conversation store with a trimming and compaction policy, cross-session memory a user can inspect and delete, clarifying questions only where they pay for themselves, a chat or inline interface whose controls match what the model can and cannot do, a voice path with a stated latency budget, an upload pipeline with limits, and feedback capture whose numbers you can interpret rather than merely collect.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 7Free · no account needed
Lesson steps

Why dropping the oldest is not enough

The previous lesson trimmed from the oldest turn. For a support chat that is fine. For a long working session it is not. At turn three the user said “the budget is under 20,000 rupees”. By turn thirty that message is gone, the model suggests something at 35,000, and the user, who can see turn three on their own screen, concludes the product does not listen.

The cost side pushes the same way. A conversation whose turns average 300 tokens sends 15,000 tokens at turn fifty. Summed across the conversation that is roughly 375,000 input tokens for fifty answers: the quadratic growth the agent-loop lesson warned about, now in a chat.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Python, from Zero, for AI exam.

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘Compacting history: sliding windows, summaries and what gets lost’, in Building with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-with-ai/compacting-history (Accessed: 29 November 2026).