all lessons · Context and cost · 6 of 17

Context is the budget

Every tool result is re-read on every turn. Spend accordingly.

The agent runs the test suite. Four thousand lines come back. It reads them, finds the one failure, fixes it, and runs the suite again.

Those four thousand lines are still in the window. They will be re-read on the next turn, and the one after, and every turn until the session ends. The model does not skim.

An agent session is a growing document. Your messages, its replies, and every byte of tool output get appended, and the model reads the whole document to produce each next step. The cost of a turn is therefore the size of the session so far, not the size of what just happened. A session of forty turns reads roughly forty times as much as it needed to.

Drive it

Watch a session fill its window

turn 1turn 40

first compaction—
compactions—
tokens read in total—
spent re-reading—
What to try
  • Defaults. A 40-turn task with modest tool output never compacts, yet more than nine tenths of everything the model reads is a re-read of an earlier turn.
  • Drag "tokens per turn" to 20k. That is one big cat of a log file or a full test run piped back per turn. The window overflows by turn ten and the session compacts repeatedly; every compaction loses detail.
  • Cut instructions to 4k. Notice how little it helps once turns are large. The per-turn payload dominates; the constitution does not.
  • Halve the turns. Total tokens read drops by roughly four times, not two. Cost grows with the square of session length. This is why one session per task beats one long session for everything.

What this changes about how you work

One session per task, cleared between tasks. The context that helped with the last task is dead weight for the next one, and it is expensive dead weight. Start fresh; the constitution and the state file carry what matters.

Keep tool output small. head, tail, grep, a --stat instead of a full diff, a test runner in quiet mode. When the agent needs to read a large file, it should read the part it needs. A cat of a log is a permanent tax on every later turn.

Send exploration to a subagent. A broad search across a codebase can pull in fifty file excerpts. Have a separate, cheaper agent do the reading and return one paragraph. The main session pays for the paragraph, not the excerpts. Part 5 covers the split.

Never poll in a loop. Checking a background job every thirty seconds with a large context re-reads the whole session thirty times an hour for zero new information. Background the job and act on its completion.

Effort is a knob too

Both major agents let you set how hard the model thinks per turn. The standing rule here is medium by default, raised per task when the problem is genuinely hard, never raised globally. Most turns are mechanical; paying for deep reasoning on “rename this variable” is the same mistake as paying for a huge window on a small task.

What about the very large windows?

A window five times larger does not make sessions five times cheaper; it makes the re-read tax five times larger before anything forces you to stop. Opt into a large window for a task that needs it, such as reading a big corpus in one pass, and go back to the default afterwards. The default is a feature.

The window is not storage, it is working memory that is re-read on every step. Keep sessions short, keep output small, and send the reading to someone cheaper.