Context and Context Windows

Updated · 5 min read
mediumPython 3.13aillmcontext-windowtokensbeginnersinterview

What should a model do with "Explain it."? On its own, nothing: explain what? But if Advitha first wrote "I'm learning about tokens", the same two words make perfect sense. The difference is context.

This lesson explains what context is, what a context window is, and what happens when a conversation or a document is too long to fit.

Context Is What the Model Can See

Context is all the text the model reads before it answers: the app's instructions, the conversation so far, any documents or search results the app adds, and your new message. The model has no other memory of your chat; everything it knows about this conversation must be in the context.

The model answers only from what is in its context

The Context Window

The context window is the maximum amount of text, measured in tokens, that a model can read at once, including its own reply. As of November 2026, window sizes vary widely by model, from a few thousand tokens to more than a million.

What fills the windowExample
InstructionsThe app's rules, such as "Be helpful and concise"
Conversation historyEvery earlier message in the chat
Added materialA pasted document, search results, a file
Your new message"Explain it."
The replyThe tokens the model generates

When a conversation outgrows the window, the app must drop or summarize older messages, and the model no longer sees them. That is why, in a very long chat, an assistant can "forget" something you said at the start.

Working Well with Context

DoWhy
Say what "it" and "this" refer toThe model can't guess what isn't in the context
Paste the relevant part, not everythingLess noise, fewer tokens, lower cost
Start a new chat for a new topicOld, unrelated messages can confuse the answer
Repeat key facts in long chatsEarly messages may have been dropped

Common Mistakes

Assuming the model remembers earlier chats. Unless the app adds a memory feature, each new chat starts with an empty context.

Pasting a huge document and asking a vague question. Point the model to the relevant section.

Forgetting that the reply counts against the window. A long answer needs room too.

Interview Corner

What is a context window?

The maximum number of tokens a model can process at once, including the instructions, conversation, added documents and its own reply. Text beyond the limit must be dropped, summarized or retrieved selectively.

Why does a chat assistant sometimes forget the start of a long conversation?

The conversation outgrew the context window, so the app dropped or summarized the oldest messages, and the model can no longer see them.

Practice

Exercise: test context. In a new chat, type only "Summarize it in one line." and note the reply. Then paste a short paragraph and ask the same thing. What changed? Finally, in a long chat, ask about a detail from your very first message and see whether it is still known.

Check your understanding:

  1. What is in a model's context?
  2. What happens when a chat outgrows the context window?
  3. Give two habits that help a model use context well.

Quick check: context and context windows

4 questions
1Why does "Explain it." fail in a new, empty chat?
2What is a context window measured in?
3A very long chat "forgets" your first message. Why?
4What counts against the context window?

Key Takeaways

Quick reference

TermMeaning
ContextAll the text the model reads before answering
Context windowThe maximum tokens a model can handle at once
Conversation historyEarlier messages sent along with each new one

Was this tutorial helpful?

Lesson 31 of 186