Context window
Definition
A context window is the maximum amount of text an AI model can take into account at once, measured in tokens. It holds your messages, any files you add, its instructions and its own replies, and whatever doesn't fit is left out.
By Ronan Liedmeier, fractional head of growth and course author · Published 17 October 2026 · Last updated 17 October 2026
Also called: context length, context limit
It is the model's working memory for one conversation. Its size decides how much of a long report, a chat history or a set of files the model can use in one go.
How it works
Every token in the window competes for the model's attention: system instructions, the full chat history, uploaded files and your question. In a 2023 study, Liu and colleagues found that models answered best when the relevant information sat at the start or end of a long input and did noticeably worse when it was in the middle, even models built for long inputs. This is known as lost in the middle.
Long chats degrade for a related reason. After dozens of turns, stale instructions and contradictions pile up in the window and answers get muddier.
Example
A procurement analyst needs the termination terms from a 120-page supplier agreement. Instead of pasting the whole file and asking once, she has the model pull termination clauses section by section, then combine what it found. Each pass reads a small piece closely, and the notice period buried on page 87 makes it into her summary.
Common mistake
Assuming that because a document fits, it was read carefully. For a long document, point the model at the relevant section or split the work into passes. For a project that runs for weeks, start a fresh chat every so often and paste in a short summary of where things stand.
Learn it in AI Academy
- How AI Actually Works (The 20% You Need)Beginner · 12 minFree
- Working With Long ContextAdvanced · 14 min
Related terms
- Token
- A token is the small chunk of text an AI language model reads and writes, usually a short word or a piece of a longer one. In English one token averages about three-quarters of a word, and context windows and API prices are counted in tokens.
- Lost in the middle
- Lost in the middle is the tendency of AI language models to miss information placed in the middle of a long input while using information at the start or end more reliably. The name comes from a 2023 research paper by Liu and colleagues.
- Context engineering
- Context engineering is the practice of deciding what information an AI model sees each time it works: the instructions, documents, tool descriptions, memory and conversation history. It extends prompt engineering from the wording of one request to everything loaded around it.
- Retrieval-augmented generation (RAG)
- Retrieval-augmented generation (RAG) is a way of getting an AI model to answer from your own documents. A search step first finds the passages that match the question, then the model writes its answer using those passages.