§02 · Sessions, Context Windows & Turns

Context window

Also called Context length · Window

The fixed-size buffer of tokens a model can read in one request; if something isn't in it, the model can't see it.

The context window is the maximum amount of text, measured in tokens, that a model can take in on a single model provider request. The system prompt, every message in the session, every file the agent read and every command result it saw all have to fit inside it together. The size is a property of the model: current frontier models offer somewhere between roughly 200k and a million tokens, and the number moves with each release.

The window fills faster than people expect. A coding session appends constantly: your prompts are small, but one cat of a large file or a noisy test run can consume tens of thousands of tokens in a single step. When the window is nearly full, the harness has to do something: compact the history, drop old turns, or refuse to continue. Long before that point, quality usually slips, because the model is weighing more material than it can hold in focus (see attention degradation).

Treat the window as a budget rather than a limit. Load what the task needs and no more, prefer targeted reads over whole-repo dumps, and open a fresh session for a new task instead of stacking it on the old one. A bigger window is not a licence to be careless about what goes in; it just moves the cliff further out.

AvoidCalling it 'memory'. The window is working space for the current session and is discarded when the session ends; anything you want remembered has to live in a file and be reloaded.
In the tools
  • Claude CodeAn indicator shows remaining context as the session grows; /compact frees space and /clear empties the window entirely.
  • Anthropic APIThe window size is per model and covers both the input you send and the tokens the model generates in reply.
In conversation

The agent read every file in src/ and now its answers are vague.

You spent most of the context window on files it didn't need. Clear, then point it at the two modules that matter.

Related terms
Learn it in the school
Words are the easy part

Course 01 puts every one of these terms to work: you install Claude Code, run the loop, and ship a real project — permission modes, compaction, hooks and all.

Start Course 01 →