Once a tool result has been consumed by a downstream reasoning step, replace the raw bytes with a compact summary or pointer and free the budget, keep-forever bloats context, drop-immediately loses recall,
Imagine doing research with sticky notes. Every time you look something up, you stick the full webpage on the wall. After ten lookups, the wall is covered and you can no longer see the question you started with. The fix is not to throw away every note the moment you read it, sometimes you need to refer back. The fix is to read each note, jot the one useful sentence onto a small index card, and pull the big sticky off the wall. The wall stays readable, the index cards preserve what you learned, and the big sticky is still in your folder if you ever truly need the raw page again. Summarize then evict is doing exactly that with tool outputs in an agent loop.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Walk the four options and explain why three fail. Keep-everything: bloat plus lost-in-the-middle. Drop-immediately: loses cross-turn recall. Top of context: sinks into the middle as the trajectory grows and breaks caching. Summarize then evict: the working middle that decouples bytes from signal. Add the cross-turn recall pattern: raw observation lives in agent state, summary lives in prompt, recall tool bridges them on demand. Close with the production framework references that implement the pattern.
Real products, models, and research that use this idea.
- LangGraph's typed-state reducers let nodes rewrite observation slots to compact summaries, with the full observation preserved in checkpoint history.
- Letta (formerly MemGPT) gives the model explicit memory-management tools to move observations between in-context and out of context tiers.
- Anthropic's Claude Code summarizes older tool outputs into compact references as a session grows, with the full bash and file-read outputs recoverable on request.
- Cursor's agent mode compacts older file-read results into named diffs once a subsequent edit step has consumed them.
- Mem0 extracts persistent facts from observation streams and stores them outside the prompt, with retrieval at turn time replacing always in prompt residence.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow do you decide what to keep in the summary versus what to drop entirely?
QWhat does the eviction policy look like for tool outputs that have not yet been consumed by any downstream step?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating eviction as a binary keep or drop choice when the load-bearing move is summarize then evict: keep the *signal* of the observation while freeing the bytes.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.