Skip to content
Harness · 3 of 6 · about 20 minutes · With a year

Compact the context

A long task fills the context window. Each call sends all the messages again, so each step costs more than the step before. When the messages are above a limit, a harness compacts them. The first message, which has the task, stays. The newest messages stay, because the next step needs them. One summary takes the place of all the messages between. In this lab, you decide which messages stay.

About this lesson

Words to know

compaction
A step that puts a short summary in the place of old messages, so that a long conversation fits in the context window.
context window
Everything a model can read and write in one request, measured in tokens. It has a fixed maximum size.
token
The unit a model reads and writes: a word, a piece of a word, or a punctuation mark. Limits and prices are counted in tokens.

Why it matters

Each agent that works for a long time has this step. After it, the agent knows the old messages only through the summary, so a fact that the summary lost is gone.

With a year

How it works, a worked example, the exercise with its tests, three hints and the explained solution are in the app, with a year of Algo150 for $29 or ₾49. The first chapter, Model foundations, is free for everyone: start with Vector dot product.

What a year includes