Forgetting is not optional
The loop has a leak. Every observation is appended to the prompt, and the prompt has a fixed maximum. Run long enough and you hit it — not as an edge case, but as a certainty, because the prompt grows by a whole page every step.
So on any real task the model will forget things. The only question is whether anybody chose which.
Keep the finding, drop the page
Section titled “Keep the finding, drop the page”Look at what survives. Not “the recent stuff” — four specific things, each kept for a reason:
The question, restated in full every call. It is the cheapest thing in the prompt and the easiest to drift away from over twenty steps.
The quotations it has already pulled out. These are the actual product of the work so far.
What it has already tried, one line each: the query, never the page it returned. Enough to stop it repeating itself, for almost nothing.
The one page it is looking at now, overwritten rather than appended when it moves on.
The pattern underneath is worth saying plainly: a page it has finished with is dead weight; the sentence it pulled out of that page is why it read the page at all. Everything else is an application of that.
Where the rest of it goes
Section titled “Where the rest of it goes”Two options once something is evicted, and you already know both.
Summarise it. Periodically compress the history into a shorter version and carry that. You lose the wording, you keep the gist — usually fine, occasionally fatal when the detail you dropped turns out to matter.
Store and look it up. Write findings somewhere external, then retrieve relevant ones when needed. This is retrieval-augmented generation applied to an agent’s past work. Retrieval can still miss relevant information, and stored findings can be wrong or outdated.
Go deeper: a bigger window is not the fix
Two problems survive it.
Attention thins out. Models retrieve less reliably from the middle of a long context than from either end — lost in the middle (Liu et al., 2023). Being inside the window is not the same as being read.
Cost is per call. Not once per task — every step re-sends the whole thing. A hundred-thousand-token context on a thirty-step task is three million tokens processed to answer one question.
So curation is not a workaround for small windows. It is what makes long tasks affordable and reliable at any window size.
Planning is the same question, earlier
Section titled “Planning is the same question, earlier”Deciding what to keep is deciding what matters. Deciding what to do next is the same judgement pointed forward.
You can plan up front — a full plan before acting, which gives coherence and then survives contact with the first surprising observation. Or incrementally — one step at a time, adaptive, and prone to wandering. In practice: a rough plan up front, details settled as you go.
And after an action lands, one more move — reflection: did that get me closer? Was that what I expected? Should I try something else? Written into the context, a failed step becomes a note that steers the next attempt instead of a thing to repeat. That is the difference between recovering from an error and executing a broken plan to the end.
Reflection lets the loop recover after a bad step. The next chapter asks whether it could have known the step was bad beforehand.
Sources · 3
- Nakano, Reiichiro, et al. “WebGPT: Browser-assisted question-answering with human feedback.” arXiv:2112.09332 (2021).
- Liu, Nelson F., et al. “Lost in the Middle: How Language Models Use Long Contexts.” TACL 2024; arXiv:2307.03172.
- Shinn, Noah, et al. “Reflexion: Language Agents with Verbal Reinforcement Learning.” NeurIPS 2023; arXiv:2303.11366.