Hierarchical summarization stacks coarser summaries over finer ones so detail decays with distance, while a single flat summary is forced to smear all of history into one budget.
Picture how you remember your week. Yesterday you can recall hour by hour. Three days ago you remember the highlights of each day. A month ago you remember the week as a sentence. A year ago, just a season. Your memory is layered: fresh stuff is detailed, old stuff is summarized, and very old stuff is summarized again on top of that. A long-running agent works the same way. The most recent few steps stay verbatim. A bit older, the steps get grouped into mini-summaries. Older still, those mini-summaries get grouped into bigger summaries. The agent sees a stack that tapers from sharp to fuzzy, instead of one flat block trying to hold everything at once.
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.
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.
Hour-scale agents are a 2026 production reality. Coding agents like Devin and Cursor agent mode, research agents like Anthropic's deep-research, and operations agents that orchestrate long tool chains can easily run for hours and produce thousands of turns of trajectory. None of that fits in a context window, even a million-token one, when you account for the cost of paying for it on every call.
The naive answer is to compress old history into a running summary. That works for a chat that lasts ten minutes. It does not work for an agent that runs for ten hours, because a flat summary block has a fixed token budget and the trajectory it must encode keeps growing. Hierarchical summarization is the production response: stack summaries at multiple time scales so that detail decays with distance instead of being uniformly smashed.
Why a flat summary breaks at long horizons
A flat summary block has one budget, often a few hundred to a few thousand tokens. On a 30-turn conversation, the summarizer comfortably preserves who said what, what was decided, and which open questions remain. The compression ratio is mild, and most specifics survive.
As the trajectory grows, the input to the summarizer grows but its output budget does not. By turn 300, the summarizer is squeezing ten times more history into the same space. Compression ratio rises monotonically, and the things that fall out first are the rarest signals: a specific number the user mentioned once, the name of a file the agent touched five hundred turns ago, a contradiction the model noticed and parked.
Worse, this is a recursive process. Each refresh of the summary is a lossy encoding of the previous lossy encoding. Information that was already approximate gets approximated again. Over enough cycles, the summary reads cleanly but no longer corresponds to what actually happened. The agent operates on a fiction it wrote about itself.
The failure shape is predictable enough that production teams stopped using flat summaries past a few dozen turns. The replacement is hierarchical.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- LangGraph state can hold multiple memory channels with different roll-up reducers per channel, which operationalizes hierarchical summarization.
- Claude Opus 4.7 agent runs over very long contexts in 2026 typically pair recent-turn verbatim with two roll-up tiers.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow do you pick the roll-up cadence between levels?
Start from the per-level token budget. If level-1 holds 1,500 tokens and each level-1 entry averages 300 tokens, then five level-1 entries fit, so a roll-up to level-2 fires when the sixth would push the budget over. The cadence is whatever keeps each level within its cap, not a magic number.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Treating a single growing summary as a budget-bounded solution. As the trajectory grows, the summarizer is forced to compress more into the same space and quietly drops the early specifics.
60 second bullets to scan on the way to the call.
Define hierarchical summarization in one sentence
Explain why a flat summary degrades as the trajectory grows
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.