There are three common kinds of AI system: recognition, prediction and generation. A large language model is one example of generation: a model that, given some text, produces the text that comes next. Once trained, the model writes an answer one word at a time. To be exact, the model works with small pieces of text, called tokens. A token is not always a word.
All the text the model is given for one answer, and the answer itself, is called the context window. The context window has a limit, and the limit is measured in tokens. For example, Anthropic says its Claude models have a context window of up to a million tokens.
The model does not keep your chat from one answer to the next. So with each new message, the earlier messages of the chat are given to it again, as many as fit. For example, on the Claude website, you start a chat with "Keep your answers short" as your first message. With your next message, the model gets your first message, its answer, and your new message. Some chat apps add a separate memory feature. For example, OpenAI says ChatGPT's memory, when turned on, keeps useful details from your chats.
Everything given to the model takes up room in the context window. That includes your messages, any file you add, the written instructions from the app's maker, and the answer. So the context window works as a budget of tokens. The more your messages spend, the less is left for a file or the answer. For example, Google says a larger context window lets the Gemini app work with longer chats. Anthropic says that as the context window holds more tokens, the model gets worse at recalling what is in it.
Once the context window is full, not all of a long chat can be given to the model. For example, Anthropic says the Claude website can leave out the oldest messages first, to make room for new ones. In that case, "Keep your answers short." is the first message left out. After that, the answers are written without it.
The context window is all the text the model is given for one answer, and the answer itself. Its limit is measured in tokens. The model does not keep your chat, so the earlier messages are given to it again with each new message, as many as fit. Everything given to the model spends part of the context window, so it works as a budget. On the Claude website, when the context window is full, the oldest messages can be left out first. When you add a long file, ask how much room is left for the answer.