R2GI WorkApproachLabCareersWriting Contact Book a call ↗

Engineering 2 min read Arnav Rastogi

The context window is a budget

An agent does not run out of context the way a disk runs out of space. It gets slower and worse a long time before it hits the limit. Attention over a window of length nn costs O(n2)O(n^2), and every token you pour in is a token of attention pulled off the task. By the time a session is 100k tokens deep, the instruction you gave on turn two is competing with forty tool results for the model’s focus, and it usually loses.

So the working rule for any long session: context is spent, not stored. Most agents spend it carelessly.

Where it leaks

Three habits waste more context than anything else we see.

Re-reading files you just wrote. After an agent edits a file, the edit already confirmed the change. Reading it back to “make sure” copies the whole file into the window for no new information. A good harness tracks the file state for you and refuses the reread.

Dumping raw tool output. A search that matches sixty files, or a build log with 800 lines, lands in the window whole. Almost none of it matters two turns later. Send that work to a subagent that reads the noise and hands back the one line you needed, and you pay a few hundred tokens instead of twenty thousand.

Losing state to compaction. When the window gets summarized, anything you did not write down is gone. A short ledger on disk, one line per finished step, survives a compaction that the conversation does not.

The move under all three

Keep bulk out of the conversation and hold pointers instead. Write an intermediate result to a file and refer to it by path. Fan work out to subagents that return conclusions, not transcripts. Put the durable record on disk, where a summarizer cannot reach it.

None of this is clever. It is bookkeeping. But it is the whole distance between an agent that stays sharp through a four-hour task and one that starts well and forgets what it was doing by lunch.