Learn/Generative AI, RAG & Agents/MODULE 1: FOUNDATIONS — UNDERSTANDING AI AND LARGE LANGUAGE MODELS
Lesson 9 of 37 · 2 min read

1.8 Context Windows and Limitations

When you interact with an LLM, everything it can "see" — your prompt, the conversation history, any documents you've pasted in — must fit inside its context window.

What Is a Context Window?

The context window is the maximum amount of text (measured in tokens) the model can handle in a single interaction.

Older models had small context windows — maybe 4,000 tokens, which is about 3,000 words.

Many current models handle 200,000 tokens or more, and some list 1 million (Anthropic's Claude 5.5 models and Google's Gemini 4 models both do, as of November 2026).

Everything the model knows about the current conversation must be inside this window.

If you have a very long conversation that exceeds the window, the earliest parts get "forgotten" — either dropped entirely or summarized.

⚠️ Common misconception: People sometimes think LLMs "remember" past conversations. Most don't, by default. Every conversation starts fresh, with only what's in the current context window. Memory features in some products are built on top of this — usually by storing past conversations elsewhere and pulling relevant pieces back into the context window when needed (a technique closely related to RAG, which we'll cover).

What Lives in the Context Window?

In a typical chat, the context window contains:

  • A system prompt (instructions to the model from the developer of the AI product, often invisible to you)
  • The conversation history so far (your messages and the AI's responses)
  • Your current message
  • Any files or images you've attached

When the model generates a response, it generates new tokens appended to all of this.

Those new tokens then also count toward the context limit.

Costs of a Large Context

Longer contexts mean:

  • More computation per response (slower, more expensive)
  • More opportunities for the model to lose track of relevant details ("getting lost in the middle" of very long inputs)

This is one reason RAG is so important: instead of stuffing the entire context window with everything possibly relevant, you retrieve just the most relevant pieces and include only those.

Keep going with a free account

A free account saves your progress across lessons and lets you pick up where you left off.