Please enable JavaScript to use CodeHS

AI Literacy

Why do chatbots forget?

You told the chatbot something at the start of a long chat. Fifty messages later, it acts like you never said it. The reason is a limit called the context window. Here is how it works, and how to work around it.

Context window ~10 min Beginner friendly
The big idea

A chatbot does not remember. It re-reads.

If you have ever asked "why does ChatGPT forget?", here is the short answer. A chatbot does not have a memory like yours. It does not store your chat in its head and think back on it.

Instead, every time you send a message, the chatbot gets the whole conversation so far as one big block of text. It reads all of it from the top, then writes the next reply. When you send another message, it starts over and reads everything again, plus the new part.

You send a message

Your new message is added to the end of the chat.

The AI re-reads the chat

It gets the chat so far as one block of text, up to a size limit.

It writes one reply

Then it is done. Nothing is kept inside the AI between replies.

Simple definition: The context window is the most text an AI can read at one time. If you are asking "what is a context window?", picture a window cut into a long scroll. You can only see the part of the scroll that shows through the glass.

That size limit is the whole story. If the chat fits inside the window, the AI can see all of it. If the chat gets longer than the window, the oldest parts do not fit anymore. The AI does not see them. For the AI, those messages never happened.


Measuring the window

What is a token?

A window needs a unit of size. For a window of glass, you might use inches. For a context window, the unit is the token.

A token is a small piece of text that an AI reads as one unit. It can be a short word, part of a longer word, or a punctuation mark. As a rough rule in English, one token is about three-quarters of a word. So 100 tokens is about 75 words.

Want to see how text gets cut up? Type anything below. This page uses a simple approximation: it splits words and punctuation, and cuts long words into 4-letter pieces.

Token chopper
Try:
0tokens 0words

Real tokenizers are different. They learn their pieces from huge amounts of text, so common words are often one token and rare words get chopped in odd places. Different AI models also use different tokenizers. This chopper is a simplified model to build your intuition. Want the full story? Read How Do Chatbots Read? Tokens Explained.


Interactive

Window Lab: watch a chatbot forget

Below is a chat between a student and a helper bot. Early on, the student shares a fact: the dog's name is Biscuit. At the end, the student asks the bot for it.

You control two things. The window size sets how many tokens the bot can read. The chat length sets how far along the conversation is. Shrink the window and watch the old messages fade, and watch the answer change.

Window Lab The numbers here are tiny so the effect fits on a screen. Real windows hold far more.
Tokens inside the window: 0 of 110 Whole chat: 0 tokens

What the bot can do

The fact about Biscuit is inside the window.

If the bot cannot see the fact, it:

Try this: Leave the chat at 13 messages and slide the window from Big down to Tiny. Somewhere along the way, message 1 falls out. The bot never decided to forget. The fact simply stopped being part of what it was given to read.


What goes wrong

Why forgetting causes contradictions and made-up answers

When something falls out of the window, the bot does not feel a gap. It cannot tell that anything is missing. It just reads what is left and does its best. That leads to a few common problems:

  • Contradictions. Early in a chat you say "I'm allergic to peanuts." Many messages later, the bot suggests a peanut snack. The allergy fell out of the window.
  • Repeating itself. The bot cannot see that it already gave you that idea, so it gives it again.
  • Confident wrong answers. A chatbot is built to write a likely-sounding reply. If the real fact is missing, some bots fill the gap with a believable guess. This looks a lot like a hallucination, which is when an AI states something false as if it were true.

Try the "Guesses anyway" button in the lab above. The bot says a name with total confidence, and it is wrong. Some chatbots are trained to say "I'm not sure" in this situation, and that helps. But no chatbot is perfect at it. To learn more about why AI makes things up, read What Is an AI Hallucination?

A good habit: If an AI answer is about something you said earlier in a long chat, double check it. A smooth, confident tone does not prove the bot still has the facts.


Bigger is not magic

Do bigger context windows fix it?

Window sizes vary a lot from one AI model to another, and they keep growing as engineers improve them. Some newer models can read the equivalent of whole books at once. That helps a lot. But a bigger window is not a perfect fix, for three reasons.

  • It costs more. Reading more text takes more computing power. That means more money and slower replies, so companies do not always give you the biggest window.
  • The middle gets fuzzy. Researchers have found that many models pay the most attention to the start and the end of a long text. Details buried in the middle are more likely to be missed. It varies by model, and newer models are improving, but it is still a real effect.
  • Every chat still has a limit. A big window just means you hit the wall later.
Idea sketch: how well a model notices each part of a long text

This is a simple sketch of a common pattern, not real measurements. The shape differs between models and tasks.


What you can do

Fix the chat: four tricks that work

You cannot make the window bigger. But you can control what goes inside it. Here are four habits that help, each with an example.

TRICK 1

Restate the key facts

Do not count on the bot remembering. Say the important part again, close to your question.

Before"Now write the invitations."
Bot: "Sure! Who is the party for?"
After"Write invitations for my dog Biscuit's birthday party. It is Saturday at 2 pm in our backyard."
TRICK 2

Start a new chat with a summary

When a chat gets very long, ask the bot to summarize it. Then open a fresh chat and paste the summary in.

BeforeOne chat with 80 messages. The bot starts mixing up details.
AfterNew chat: "Summary so far: party for Biscuit, Saturday 2 pm, 8 kids, no peanuts, treasure hunt game. Next, help me plan the snacks."
TRICK 3

Keep prompts short

Every extra word uses up window space. Cut the filler so the important words stay in view.

Before"So, um, I was thinking, and tell me if this is dumb, but maybe we could possibly do some kind of snacks, I guess?"
After"Suggest 3 easy snacks for 8 kids. No peanuts."
TRICK 4

Do not bury your instructions

Put what you want the bot to do where it will not get lost: at the start, and again at the end of long text.

Before[Three pages of pasted article] ... "by the way, summarize this in 5 bullets" ... [two more pages]
After"Summarize the article below in 5 bullets." [article] "Reminder: 5 bullets, simple words."

How AI chatbots remember

How "memory" features really work

Some chatbots now have a "memory" feature. It can seem like the bot got a real brain. But the trick is simple, and it is the same context window.

When you turn on memory, the app saves short notes about you, like "has a dog named Biscuit" or "prefers short answers." Those notes are just text stored by the app. Then, at the start of each new chat, the app pastes the notes into the top of the context window before your first message. The bot reads them like any other text.

What happens when you open a new chat

Saved notes

  • - Has a dog named Biscuit
  • - Likes short answers
  • - Peanut allergy in the group

New chat: inside the context window

Pasted in by the appNotes: dog named Biscuit. Likes short answers. Peanut allergy in the group.
YouPlan a snack list for Saturday.
BotHere are 3 peanut-free snacks...

The bot did not remember the notes. It was handed them again, just like a student who gets a sticky note before every test.

This has two side effects worth knowing:

  • Notes use up room in the window, so the apps keep them short.
  • A note can be wrong or out of date, and the bot will trust it anyway. Many apps let you view, edit, or delete saved memories. It is a good idea to check what yours has saved, and to think before you save anything private.

Check yourself

Quick quiz

1. What is a context window?

2. In a very long chat, the bot forgets the first thing you said. What most likely happened?

3. Which move is most likely to help a chatbot that keeps losing track of your project?

Keep learning about how AI works

Now you know why chatbots lose the thread. Go deeper on how they read text, or on why they sometimes state things that are not true.

CodeHS courses teach students how AI works and how to use it well, with hands-on lessons built for middle and high school.