Harness, Part 8: Context Compaction
When the conversation outgrows the window: older turns get summarized - the thread survives, the cost drops.
What this is about
You felt it for the first time in Part 2: the whole history rides along on every turn, and turn ten pays for turns one through nine all over again. So far that was a shrug - now that your agent runs on its own via trigger and works through jobs, it becomes a bill. And at some point it becomes a wall: the context window is finite.
The answer belongs to the extensions from Block II and is called compaction: older turns become a summary, the newest stay verbatim. When the conversation gets too long, a separate call to the same model summarizes the old turns; the summary replaces them in the history, while the system prompt and the latest turns remain untouched. This is the "context-frugal" of this series in its purest form - and it is a bet: the summary keeps what will still be needed later and discards what won't. What you place that bet on, you decide in the interview.
At the end of this part, this works: a long conversation simply keeps going - and you see in real numbers what compaction saved.
How the build works
As before: copy the prompt, hand it to your coding agent, answer its questions. The prompt reads harness-doku.html and requires the state from Part 7.
This section belongs to the Pro tier. You get access to full code, deeper explanations, and rabbit-hole material.
See tiers →It works when
Compaction demonstrably kicks in, the conversation keeps its thread - a question about something summarized still gets answered correctly - and the token counts before and after the cut sit in your docs as evidence. One piece is missing, the finale: Part 9: Tool-Call Optimization - a small model takes over the tool calls.