Definition

Context Window

A context window is a model’s token budget for processing a sequence. A request can include instructions, conversation history, retrieved material, tool schemas and tool results. Providers differ in how they count input and generated tokens against their limits. Reserve space for the expected completion and check the limits of the model in use.

Budget space for instructions, evidence and a reply

Suppose a model allows 16,000 tokens total and your application reserves 2,000 for its reply. That leaves 14,000 for input. Instructions and conversation cost 5,000, while tool schemas cost 1,000, leaving 8,000 for retrieval. Measure that budget with the model’s tokenizer. As history grows, trim or summarize low-priority material while preserving the user’s current request and required evidence.

OpenAI guide to managing a context window

Intelligence at Scale by Shashank Agarwal

Context Window diagram from Intelligence at Scale
Diagram from chapter 8, Prompt Engineering and Context Engineering

Explained in

Chapter 8: Prompt Engineering and Context Engineering

The number one practical skill for anyone working with AI.

Related terms

This is one term. The chapter is the argument.

Intelligence at Scale: 22 chapters, 65,000 words, 80-plus diagrams. Kindle, paperback and hardcover on Amazon.

Buy on Amazon.com
← All terms