Context Windows & Long-Context Techniques
A bigger number on the spec sheet doesn't mean the model uses every token in it equally well.
Intermediate
context_window = system_prompt + conversation_history + retrieved_documents
+ current_user_message + model_output
# all of it counts against the same limit -- not just what you type
Multiple studies on long-context retrieval found that models are most reliable at using information placed at the very start or very end of the context, and measurably worse at retrieving/using information buried in the middle of a long input — even when the model's stated context window comfortably fits everything. This isn't a hard limit like running out of tokens; it's a quality-of-attention gradient across position.
| Technique | Trade-off |
|---|---|
| Summarize old conversation turns instead of keeping them verbatim | Loses detail; cheap and usually sufficient for casual chat continuity |
| Retrieve only the relevant slice of a large corpus (RAG) instead of pasting it all in | Requires a retrieval pipeline; scales to corpora far larger than any context window |
| Prompt caching (reuse a cached prefix across calls) | Doesn't reduce the logical context used, but cuts latency/cost when a large prefix — e.g. a system prompt or document — repeats across calls |
| Sliding window (drop the oldest turns) | Simple, but loses arbitrarily old information with no summarization |