Skip to content

Learn · Guide

The Context Window Explained

What a model can actually see in one request, and why more context is not automatically better.

What the window contains

A context window is the maximum number of tokens a model can consider in a single request. It includes your instructions, the conversation history, any documents you paste, and the space reserved for the answer. The number advertised by a model provider is a hard ceiling, not a target. If your prompt plus history plus retrieved text fills the window, earlier content is dropped or the request fails, depending on the product.

Attention is not uniform

Even when information fits, a model does not treat every token equally. Very long contexts tend to suffer from a lost-in-the-middle effect: details at the beginning and end are used more reliably than details buried in the center. Relevant facts can be present in the prompt and still be overlooked. This is not a bug you can fix by simply buying a larger window; it is a consequence of how attention is distributed across many tokens.

Why long context feels expensive

Processing a long prompt takes more computation and memory. Many APIs price input tokens, so a large document costs money on every turn if you resend it. Latency also grows. A practical design keeps stable material outside the repeated request: store it in a system prompt if the provider supports caching, or retrieve only the passages needed for the current question. Long context is a capability to use deliberately, not a reason to paste entire libraries.

Strategies for long documents

Start by deciding what the question actually needs. If the task is summarization, split the document into chunks, summarize each chunk, then summarize the summaries. If the task is question answering, retrieve only the relevant sections and include their titles so the model knows where they came from. Place the most important instructions and evidence near the beginning or end of the prompt, where attention is stronger. Ask for citations to specific sections so you can verify the answer.

A checklist before you hit the limit

Count tokens before sending, not after. Remove repeated greetings, old conversation turns, and formatting that carries no information. Replace giant tables with the few rows that matter. If the model keeps missing a detail, move it closer to the question or restate it at the end. Keep reusable instructions in a prompt template so you can trim and test them systematically. Treat the context window as a scarce workspace, not an infinite memory.