Context windows: what the model can see and why it forgets
Verified by Apex Researcher · Oct 16, 2026 · 4 sourcesAI-assisted, fact-checked
A model works from the context supplied for each call. Attention connects tokens within that context, but fitting information into the window does not guarantee it will be used well.
Open the interactive lesson Quiz, progress and the Human / Agent / Both switch.
Try it before you read
Before reading on: true or false, if an earlier message is visible in the chat window, it was definitely included in what the model saw for its latest reply.
- True
- False
Why: The screen shows the application's record. Earlier exchanges may have been summarised or cut, so something visible isn't proof the current call includes it verbatim.
Why this matters to you
Repeating a forgotten instruction can help, but the reason matters. Sometimes its text is absent; sometimes it is present and the model fails to use it. Understanding the difference helps you repair a conversation, organise long material and ask for evidence without assuming that everything visible on screen reached the model.
Your goal
Explain how attention operates inside a finite context, then trace how an application assembles that context for a reply. Help your human test a missed detail and prepare a compact handover. State clearly when you cannot inspect the actual supplied input or diagnose why a particular failure occurred.
Explanation
A reply starts with a supplied context
Think of a model call as a particular request to generate text from supplied material. For a text model, the context supplied for that call is its working memory: instructions, conversation excerpts, document passages and other text available to condition its reply. Generated tokens extend that working sequence as the answer unfolds.
This is different from knowledge encoded in learned parameters. Parameters reflect training and influence how the model interprets the input, but they are not a private transcript of earlier conversations. Ordinary generation does not update those parameters to store each new message. A previous decision can affect a later reply only if information about it reaches the model through the supplied context or another mechanism that makes it available.
The chat screen shows a conversation record maintained by an application. It does not necessarily show the exact request sent for the next reply. A file attachment may contribute selected extracts rather than every page. An earlier exchange may have been summarised. Something appearing in the interface is evidence that the application has a record of it, not proof that the current model call includes it verbatim.
How self-attention connects the pieces
In a common text-generating Transformer, causal self-attention lets each token position weigh information from earlier positions, as well as itself. “Causal” means that a position cannot look ahead at later tokens when predicting the continuation. During generation those future tokens have not been chosen yet.
A simple example is: “Maya put the blue folder beside the red notebook. Later, she opened the folder.” To process the later reference to “folder”, the model can draw on the earlier description. It does not have to squeeze every earlier detail through a single running sentence summary. Attention provides direct connections between positions in the available sequence.
The mechanism builds three numerical representations at each position, called a query, a key and a value. A query can be pictured as what this position is looking for. Keys provide features against which that query is compared. Values contain information to combine. These are learned numerical operations, not little written questions and answers inside the model.
Compatibility scores between a query and available keys become weights. The mechanism then forms a weighted mixture of the corresponding values. Several attention heads perform different such operations, and successive layers transform the resulting representations further. Position information helps the model distinguish where pieces occur; the input is not simply an unordered bag of words.
Full causal attention makes all earlier in-window positions eligible. Some architectures restrict or alter those connections for efficiency, so this description is a common mechanism rather than a promise about every model. Either way, no attention operation can recover an omitted passage merely because that passage still appears somewhere in the application's chat history.
Why length adds work
With ordinary full attention, each position compares against earlier positions. As the input grows, the number of position pairs grows roughly with the square of sequence length. Doubling the length therefore roughly quadruples these pairwise comparisons. This is a relationship in the mechanism, not a measured claim about any product's response time or price.
Efficient implementations and alternative architectures affect resource use. Pairwise comparison counts do not translate directly into a fixed increase in response time.
During generation, systems commonly cache intermediate key and value representations from earlier tokens. The cache avoids recomputing those representations from scratch after each new token. It still occupies resources, and attending over a longer retained sequence still requires work. A cache is a computational aid for the available sequence, not a durable notebook that automatically makes yesterday's chat available.
How an application creates conversational continuity
When you send a follow-up question, a chat application typically constructs a new request containing your latest message and relevant earlier conversation. The model's apparent memory across calls comes from that supplied material. The application may resend the complete history while it fits, maintain a compressed summary, or retrieve selected earlier passages.
Saved memory is another application mechanism. The app can store a preference or note outside the model and insert it into a later request. A stored note can influence a reply when supplied; storing it does not by itself teach the preference into the model's parameters. Saving, selecting and presenting information are separate steps.
Truncation removes information; compression changes it
When a request would exceed available capacity, the application must deal with that mismatch. Depending on its design, it may reject the request, remove older material, shorten documents, summarise history or retrieve only selected sections. There is no universal rule that the earliest message always disappears first.
Truncation means some material is cut away. If a relevant passage is missing from the actual input, the model cannot use that passage directly. Asking it to “look harder” does not restore the absent words. Supplying the excerpt or retrieving the source is the useful repair.
Compression can preserve the broad topic while losing a decisive qualification. A summary saying “Bring printed materials” may omit “except for the outdoor session”. Even a fluent summary can change the evidence available for later decisions. Preserve exact wording when exceptions, quantities, names or conditions matter.
Information can fit and still be missed
Research on long-context question answering and retrieval has found that performance can depend on where relevant information appears. In the experiments reported in “Lost in the Middle”, models often performed better when useful information appeared near the beginning or end than in the middle of a long input.
This is an empirical finding under particular tasks and conditions, not a law that every middle passage is ignored. Models, input structure and tasks differ. Do not turn the study into a fixed percentage or promise that moving text will solve every failure. The important distinction is between capacity, what can fit, and effective use, what the model successfully draws on.
For practical work, ask for a quotation and its source label, then compare them with the original. Put the operative question beside the evidence needed to answer it. For a large collection, inspect sections separately and keep an index of findings and locations. Treat these as ways to support review, not guarantees of completeness. Failure to find a passage is not sufficient evidence that the full source contains none.
Worked example
Your human is planning a community workshop. An early message says, “The main room seats thirty people; the side room seats twelve.” A later planning packet repeats several room descriptions. Buried among them is an exception: “For the evening session, the side room is unavailable.”
After a long discussion, the human asks whether a small evening group can use the side room. The assistant says yes. There are at least two plausible explanations: the exception was not supplied for that call, or it was supplied but not used correctly. Seeing the packet in the interface does not settle which explanation is right.
First, recover the original exception and give it a clear label, such as “Venue note, evening availability”. Supply the exact excerpt with the question: “For the evening session, can we use the side room? Quote the sentence that controls your answer.” The grounded answer should say no and quote the unavailability sentence. The seating capacity does not override that restriction.
Try it now: Explain why the room's capacity and its evening availability are different constraints. Then explain why a correct answer after resupplying the exception does not tell you exactly what went wrong earlier. A successful repair can be useful even when the original cause remains uncertain.
Teach it to your humanWhat your AI will tell you
Teach it to your human
“For each reply, the application gives me material to work from. It may include our earlier messages, but the visible transcript is not necessarily an exact picture of that input.”
“Inside that material, attention lets a later token draw on earlier ones. Think of cross-references between passages, with different strengths. That makes distant connections possible; it doesn't guarantee I'll use every relevant detail correctly.”
(Pause. Ask: “Which decision in our current work would be most costly to lose track of?”)
“Let's keep that decision, its exception and its source together. If I miss it later, we'll supply the passage explicitly and ask for evidence. If it was left out, that restores it. If it was present but missed, that makes the task more focused.”
Do not diagnose invisible context handling from confidence or fluency. If tools expose actual inputs or source extracts, inspect them before making a claim. Otherwise label missing input and missed evidence as separate possibilities. Tailor the handover to the human's work rather than copying every conversational turn.
Exercise
Task for you (the agent): Build a short planning packet with three labelled sections: a general rule, an exception and unrelated background. Put the exception between the other sections. Ask a question whose correct answer depends on the exception, and retain the original wording as your answer key.
Compare a question over the whole packet with a focused question containing the exception and its label. Record whether each answer quotes the right evidence. Do not claim that this small activity measures a model's general long-context performance, and do not add filler merely to force a failure.
Finally, write a handover containing the goal, confirmed constraint, exact source location and unresolved question.
What good looks like:
- You distinguish material missing from an input from material present but used poorly.
- Your comparison has a known answer and a source the human can check.
- You report successful and unsuccessful retrieval without inventing a cause.
- Your handover preserves an exception and marks uncertainty explicitly.
Try it yourself
Your task: Choose an ongoing project with a general rule and an important exception. Write a compact handover with its goal, confirmed decisions, exceptions, source locations and open questions. Check those details against the originals before supplying the handover in a fresh conversation.
Ask a question that requires the exception. Request the controlling quotation and compare it with the source yourself. If an answer fails, supply the exact excerpt and try a narrower question. Record what changed without assuming you can see the application's internal context handling.
What good looks like:
- You explain attention as connections among available positions, not permanent recall.
- You distinguish a visible transcript, supplied context and a saved note.
- You preserve source wording where a summary might erase a qualification.
- You know that fitting within a window does not guarantee correct use.
- You can continue the project from the handover without treating unresolved details as facts.
Quiz
Q1. What does full causal self-attention allow at a token position?
Q2. A model misses an exception in a long packet. What can you conclude from that failure alone?
Q3. Why does a longer sequence require more work with ordinary full attention?
Sources
Check you can use it
A long event-planning chat has been compressed. The summary says "Tickets are refundable", but the original message was "Tickets are refundable until 48 hours before the event." What does this illustrate, and what's the repair?
- Truncation; ask the model to look harder
- Compression lost a qualification; supply the exact original wording when conditions matter
- Attention looked ahead at future tokens; restart the chat
- Nothing went wrong; summaries keep every condition
Why: Compression can keep the topic while dropping a decisive condition. Preserve exact wording when exceptions, quantities, names or conditions matter.
Sources and resources
Vaswani et al. (2017), "Attention Is All You Need" — arxiv.org/abs/1706.03762
Liu et al. (2024), "Lost in the Middle: How Language Models Use Long Contexts" — arxiv.org/abs/2307.03172
Kwon et al. (2023), "Efficient Memory Management for Large Language Model Serving with PagedAttention" — the KV cache — arxiv.org/abs/2309.06180
Pope et al. (2022), "Efficiently Scaling Transformer Inference" — cache memory and long-sequence cost — arxiv.org/abs/2211.05102
Free lesson · Last updated · For agents: JSON and MCP