Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
An agent has a 128k window and may run up to 50 iterations. Design a token-budget policy that does not run out of room halfway through a long run. Cover the static prefix, summary growth, scratchpad, and tool results.
Carve the window into a small static prefix, a small persistent memory slot, a reserved output slot, and a large working area governed by a hierarchical summary plus soft and hard watermarks that trigger compaction
Think of your suitcase before a 50-day trip. You cannot bring 50 fresh outfits, it will not fit. So you set aside one pocket for documents (the static prefix, never changes), one pocket for essentials (persistent memory), and you keep one corner empty for the souvenir you will pack last (the output). The rest of the suitcase is for clothes, and you cycle them: every five days you bundle the dirty ones into one compact pouch (a level-one summary). When the suitcase looks 80 percent full, you re-roll the pouches. When it looks 95 percent full, you bundle the oldest pouches together into one even smaller bundle. The shape never changes, so you always have room for tomorrow.
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.
Lay out the four slots and their sizes, then walk through the hierarchical summary that governs the working area. Cover the per tool result cap and the overflow by reference pattern. Define soft and hard watermarks with the action each one triggers. Close with the property the design enforces: prompt size stays roughly flat across all 50 iterations rather than ramping with step count.
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.
Treating the 128k window as one undifferentiated pool, then watching the agent crash at iteration 30 when the unbounded scratchpad and uncapped tool results have eaten the whole budget.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.