Deciding What Is Worth Keeping
You hand the agent a tool that compresses its own history, and it uses it sensibly: between tasks, once a search is finished, never in the middle of an edit. You read what it kept. The summary is short and accurate, the open bugs are listed, the files it touched are named. Then the work stalls. What went missing was a two-line note about why the first approach was abandoned, and an import at the top of a file read forty minutes earlier. Neither looked worth a line of the window. Each was the only thing holding something else up.
A scene survives for two different reasons
Picture a cutting room with far more footage than picture. The person working there is not asking which takes are good. Thirty dull seconds of a character pocketing a key are not good, and they stay, because the last ten minutes do not parse without them. Meanwhile a beautiful take goes in the bin, labelled, because nothing leans on it. Two questions are being asked of every frame — does this carry the story here, and does anything later depend on it — and they do not have the same answer.
Pruning the code an agent has read works the same way when it works at all. One rubric looks for spans that are semantically relevant to the request, and those tend to arrive in contiguous blocks: the body of the function, the comment explaining why it behaves oddly. The other looks for the lines that hold the dependency up — an import three hundred lines above, a call site in another file — and those are sparse and scattered. Separate models produce the two signals, because the signals behave differently; a gate conditioned on the query combines them, and a final layer decides what is held. The training labels can be derived from an AST, so nobody annotates by hand. Collapse the two into one score of usefulness and you get the failure the editor avoids: the file read once and never used goes, and so does the import.
Nobody recuts while the camera is running
Timing is the other half, and it is not a detail. A harness that compresses at a fixed percentage of the window fires when it fires, which is usually mid-subtask, exactly when the details just observed are still needed. Exposing compression as a tool moves that choice to the only party that knows where the seams are. The agent calls it between tasks, after pulling a result out of a bulky input, before opening something large, before a procedure it knows will run long. The middleware keeps a queue of recent messages intact, condenses the history behind them, and keeps the detail recoverable outside the window.
This is where you decide how much rope to give it. The policy stays conservative on purpose, because a compression taken at the wrong instant severs the thread of the work, and the bill arrives twenty minutes later as work redone rather than as an error you can see. Delegating the judgment is not a claim about how clever the model is. It holds when the criteria are written down — what counts as a boundary, what always survives, where the detail went — and it fails quietly when the agent is told to keep the important parts.
Some material is never up for review
Step back from the trims and the same decision covers everything in the window: the standing instructions, the tool definitions, the examples, the data pulled in, the history. What you are aiming at is the smallest set of high-signal tokens that makes the behaviour you want likely, not the largest set that fits. Attention is a budget before it is a capacity, which is why loading every document up front, for fear of missing one, reliably makes an agent worse at the job in front of it.
A rule applied to everything, though, is the wrong rule. Some things have to be true in every session and every subtask — naming conventions, the protocol for handing work between agents, what nobody is allowed to touch — and those never enter the pool being weighed. They stay loaded. Everything else is fetched when a task calls for it. Make a global safety rule retrievable and you have made obeying it depend on somebody choosing to search for it.
None of this is tidying. What leaves the window is chosen, again and again, all day, by whoever or whatever is holding the criteria at that moment — and the only part of that judgment you can hand over is the part you were willing to write down.