Compaction at turn 30
Estimate how many turns a compaction at turn 30 buys an agent before its window fills again, and what it costs against the tokens it saves.
On this page
Compaction is a model call that rewrites the past. It costs tokens now to save tokens later, and whether it pays depends on how long the run goes on.
The situation
A research agent makes three tool calls a turn, each returning about 4 KB, and writes about 500 tokens of output per turn, so the history grows by 3,500 tokens a turn. Its system prompt and tool definitions are 6,000 tokens. The harness reserves 8,000 tokens of the window for the model's answer. At turn 30 the harness compacts: it sends turns 1 to 20 to the model with a 500-token instruction and receives a 2,000-token summary, which replaces those twenty turns; turns 21 to 30 stay verbatim. Runs of this agent typically go to about turn 60.
Course constants, restated: about four characters per token, so 4 KB is about 1,000 tokens; a 200k-token window; P_in = $3 per million input tokens and P_out = $15 per million output tokens; a cache read at C_r = 0.1 × P_in and a cache write at C_w = 1.25 × P_in. Ignore caching for the main estimate and then say what it changes.
The question
How many more turns does the compaction buy before the window is full again, what does the compaction call cost, and how many input tokens does it save over turns 31 to 54 compared with not compacting?
A strong answer · Rubric · Where answers go wrong
Write your answer first, then open