Order the slots to trim first when a turn exceeds the soft context budget
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Trim in order of information value already consumed: stale tool outputs, then old turns, then low-rerank chunks, then dim memories, then format hints, never the user turn.
Imagine packing a small bag for a hike with too much gear on the table. You take out the snack wrapper from yesterday's hike first, it has zero use today. Then the souvenir maps from past trips. Then a couple of guidebook pages that turned out to be off-route. Then a fact card you barely glance at. The trail snack and the map of today's hike stay in the bag until the very end, because dropping them turns the trip into a guess. Context trimming follows the same instinct: throw away things whose value you have already extracted before you touch things you are about to need.
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.
7 min: value per token framing, why stale tools beat old turns for first eviction, the protected slots, and how summary compaction reshapes the order.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Trimming the user turn or the output schema first to save tokens, that breaks the call before the model can even attempt the task.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.