We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

What Is Context?

Context is all the information your AI model can "see" when it's generating a response. A "context window" is the limit on how much of that information the model can work with at once.

Click to play video

Giving an agent the ability to read files, connect to a database, or call an API does not automatically put that data in the model's context. The agent needs to fetch it first. When the model is generating text, it uses the tokens in context to predict the next token, then repeats the process with the new token included.

What makes AI feel more sophisticated is that all the tool-calling, file-reading, etc. injects more information into context – often managed automatically by agents – before the model generates its final response to a prompt.

Why Not Just Say “Prompt”?

The prompt that you enter is only part of the context, and with coding, usually a very small part. Context can include:

  • System prompts
  • Previous messages
  • Reasoning tokens
  • Tool calls and their results
  • Your prompt (latest user message)

A context window of 1 million tokens can hold roughly 750,000 words of English text, or about 1.5x the length of the entire Lord of the Rings trilogy. That's much more than you'd ever write into a prompt by hand, but not so much when you're trying to shove your entire codebase, documentation, and session history into the model's context.