Context Window
What is Context Window?
A context window is the maximum number of tokens a language model can consider at once, covering its instructions, the conversation so far, any supplied documents and the response it generates.
Updated November 2026 · 5 min read
The context window is the working memory of a language model. Everything the model takes into account when producing an answer must fit inside it: the system instructions, the user's request, earlier turns of the conversation, documents or data pulled in for reference, and the answer itself as it is generated. Anything outside the window is invisible to the model. Context windows are measured in tokens, and modern models range from tens of thousands of tokens to hundreds of thousands, with some exceeding a million.
Large context windows make new uses possible, such as analyzing a long contract or an entire codebase in one request. They also create a cost risk. Because providers charge for every input token, filling a large context window on every call can make an application expensive very quickly. For IT financial management, the context window is both a capability to use well and one of the main reasons AI costs vary so widely from one application to another.
Definition of Context Window
A context window is the limit on the total number of AI tokens a model can process in a single request, including both input and output. It is a property of each model and is set by its architecture and training.
The window is shared between what goes in and what comes out. A model with a 200,000-token window that receives a 190,000-token prompt has at most 10,000 tokens left for its answer, and many models also set a separate, lower limit on output length.
What Fills the Window
System prompts and instructions are sent with every request. In complex applications they can run to thousands of tokens on their own.
Conversation history accumulates as a chat continues. Unless an application trims or summarizes it, each new message carries all the previous ones with it.
Retrieved content, such as documents, search results or database records, is often the largest part. Agents add the results of tools they have called and the steps they have already taken.
Limits of Long Context
A larger window does not guarantee that a model uses all of the content equally well. Models can miss or underweight information buried in the middle of very long inputs.
Long inputs also take longer to process, which increases the time before a user sees a response.
For these reasons, giving a model less but more relevant context often produces better answers at lower cost than filling the window simply because it is available.
Importance of Context Windows in IT Financial Management
Context use is one of the largest drivers of AI costs. Since every token in the window is billed as input, the amount of context an application sends per request multiplies directly into its monthly bill.
The cost effect grows with usage. An extra 10,000 tokens of context per request looks small in testing but becomes significant across millions of requests.
Some providers also charge higher per-token rates for requests above a certain length, so very long contexts can cost more than their token count alone suggests.
Design Choices and Cost
How an application manages its context is a design decision with direct financial consequences. Sending whole documents, full histories and long instructions is simpler to build but more expensive to run.
Alternatives, such as retrieving only the relevant passages, summarizing history or caching fixed instructions, take more engineering effort but reduce the input and output tokens billed on every call.
Finance and engineering teams benefit from discussing these trade-offs early, before an application's design is fixed and its usage has grown.
Agents and Growing Context
AI agents that work through multi-step tasks often resend their full history with each model call. Context grows with every step, so later calls cost much more than earlier ones.
A task that takes twenty steps can therefore cost many times more than twenty single calls would suggest.
Understanding this pattern is essential for estimating the cost per task of agent-based applications and setting sensible limits on how long agents can run.
How to Manage Context Windows
Managing context involves measuring how much of each request is used by different kinds of content, then reducing whatever does not improve the answer.
The aim is the smallest context that produces reliable results, not the largest the model will accept.
Measuring Context Use
Break down input tokens by source for each application: instructions, history, retrieved content and tool results. This shows where context is being spent.
Track average and peak context size per request and per task over time, and watch for steady growth that may indicate history or retrieval is not being trimmed.
Test how answer quality changes as context is reduced. Many applications perform as well or better with less.
Reducing Context
Use retrieval to select only the passages most relevant to each question, often from a vector database, rather than sending whole documents.
Summarize or truncate conversation history, keeping recent turns in full and older ones in brief. For agents, replace detailed records of completed steps with short summaries.
Place fixed content, such as instructions and reference material, at the start of the prompt so it can benefit from prompt caching, which bills repeated content at a reduced rate.
Examples of Context Windows in IT Financial Management
The examples below show how context use shapes AI costs.
Both use an illustrative input price of $3 per million tokens. The first reduces the context sent by a document assistant, and the second controls context growth in an agent.
In each, the change in context design had a larger effect on cost than any change in model or price.
A Document Assistant
A company's internal assistant answers questions about policies by sending each relevant policy document in full, averaging 60,000 input tokens per question. At 100,000 questions a month, input costs $18,000.
The team switches to retrieving the five most relevant passages for each question, averaging 6,000 tokens. Input costs fall to $1,800 a month.
Accuracy on a test set of 500 questions improves slightly, because the model is no longer distracted by unrelated sections.
An Agent With Growing History
A coding agent resends its full history on every step. A typical task takes 15 steps, with context growing from 8,000 tokens to 120,000, for a total of about 960,000 input tokens per task, or $2.88.
The team changes the agent to keep the last three steps in full and summarize earlier ones, capping context at about 30,000 tokens. Total input falls to about 410,000 tokens per task, or roughly $1.22.
Task success rates are unchanged, and the agent can now handle longer tasks without reaching the model's context limit.
Conclusion
A context window is the maximum number of tokens a model can consider at once, covering instructions, history, supplied content and its own answer. Large windows enable new uses, but every token placed in them is billed, and very long inputs do not always produce better results.
In IT financial management, context use is one of the biggest drivers of AI costs, especially for agents whose context grows with each step. Measuring context by source, retrieving only relevant content, summarizing history, caching fixed instructions and testing quality at smaller sizes help organizations get the benefit of long context without paying for tokens that add nothing.
Related terms
AI Tokens
AI tokens are the small units of text, such as words or parts of words, that language models read and write, and the unit most AI services use to measure and charge for usage.
Input and Output Tokens
Input tokens are the tokens sent to a language model in a request, and output tokens are the tokens it generates in response. Most AI services price output tokens several times higher.
Cost per Task
Cost per task is the full cost of completing one unit of AI-assisted work, such as a resolved support request or a processed document, including every model call, tool and retry involved.
Vector Database
A vector database is a database designed to store embeddings, numerical representations of the meaning of text, images or other data, and to search them quickly for items with similar meaning.