Zenaique

Compare sliding window history with rolling summary history

Flashcard·Easy·4.0 · 0·~30s·Asked atHclJasperZepto
Attempt it
TL;DR

Sliding window is cheap and deterministic but drops everything past its cutoff; rolling summary keeps long-range continuity at LLM-call cost and risks detail drift.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture two ways to remember a long phone call with a friend. Option one: only remember the last five minutes word for word, forget anything before. Option two: keep a rough summary of the whole call updated in your head, plus the last five minutes word for word. Option one is fast and lazy but you lose anything the friend said early in the call, like the address they wanted you to visit. Option two preserves the big picture but the summary gets blurrier each time you update it, and exact details quietly disappear. Most production chatbots cheat: they run option two, plus they jot the address down separately in a notebook so it never gets lost.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Sliding window and rolling summary are the two canonical patterns for bounding conversation-history tokens in chat and agent applications. Newcomers to context engineering tend to ask "which one should I use," and the right answer in 2026 production is almost always "both, plus an extracted-memory store." But understanding why requires understanding what each technique actually does and where it fails.

This deep dive walks through each pattern in isolation, then shows the composition that has become the 2026 default.

Sliding window: deterministic, simple, hard cutoff

A sliding window keeps the last N turns (or last K tokens) verbatim and drops everything older. It is a FIFO queue over the conversation. There is no compression, no LLM call beyond the main generation, no drift, no smoothing. The token count is bounded by construction. The behavior is deterministic: the same conversation history produces the same model input every time.

The operational wins are real. Implementation is trivial (a list slice). Debugging is easy (the model input is exactly the last N turns). Cost is fixed per turn, with no surprise spikes for summarization refreshes. For applications where conversations are short, transactional, or where old facts genuinely do not recur, sliding window is the right answer.

The loss is also real. Anything older than the window is gone. A user who tells the bot at turn three "I am vegetarian" loses that fact the moment turn three slides out of the window. The bot does not approximate the fact, does not infer it from later turns, does not have a chance to recover. It simply behaves as if the fact were never stated. For chat or agent applications where user-stated preferences, constraints, or identifiers might recur, this failure mode is catastrophic.

The window size N is the only parameter, and it controls a clear trade-off: larger N preserves more context at higher token cost; smaller N is cheaper but loses more. Typical values land between 5 and 20 turns, depending on the application's reference distance (how far back pronouns and definite references typically point).

Rolling summary: graceful decay, drift risk
Why production combines both with an extracted-fact store
Observability and the triage path
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
PropertySliding windowRolling summary
Per-turn LLM costZero (just generation)Adds summarizer call on refresh
DeterminismFully deterministicDepends on summarizer model
Long-range infoLost beyond N turnsPreserved at lower fidelity
Exact numericsPreserved within window, lost outsideDrift on every refresh
Code/structured artifactsPreserved within window, lost outsideParaphrased away
Failure shapeHard cutoffSoft drift
Implementation complexityTrivialModerate (prompt design matters)

Real products, models, and research that use this idea.

  • LangChain's ConversationBufferWindowMemory is the canonical sliding-window implementation.
  • LangChain's ConversationSummaryBufferMemory is the canonical rolling-summary implementation.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QIf you can only pick one, which do you pick, and what is the failure mode you accept?
A

Depends on whether your application can tolerate the hard cutoff of a sliding window. If old facts genuinely do not recur in your workload, take the window for its operational simplicity. If they do recur, take the rolling summary and accept the drift risk, mitigated by structuring the summarizer prompt with a protected facts section.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating sliding window and rolling summary as mutually exclusive choices. The 2026 production default uses both, plus an extracted-fact store for durable specifics.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Describe the sliding-window policy in one sentence

  • Describe the rolling-summary policy in one sentence

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Pick the most effective intervention when an agent's context grows by 8KB every iteration
MCQ·Medium