Nestor G Pestelos Jr · ELI5

Phase 2: The User Interaction

Context Windows

The short-term memory limit of artificial intelligence. How much an AI can hold in its head at one time before forgetting.

01 / The Desk Space Metaphor

AI has a desk of fixed size.

An AI model has no permanent memory of your chat. It can only see what fits on its physical desk during that single conversation.

DESK CAPACITY: 128,000 TOKENS System Rules 2,000 tokens Retrieved Docs (RAG) 18,000 tokens User Message 1,000 tokens Empty Space Everything the AI knows right now must be sitting on this desk.
Why doesn't the model remember past chats?

Pre-training bakes permanent knowledge into model weights. But conversations happen entirely in temporary memory. When you start a fresh chat, the desk is wiped completely clean.

02 / Questions and Answers Compete

Every word in and every word out shares the same budget.

Both the questions you send and the paragraphs the AI writes back eat away at the same shared token capacity.

Input Tokens (Prompt + History) Output Tokens Free If the input takes up 95% of the desk, the AI can only write a short reply before running out of room.
What is max_tokens in API calls?

The max_tokens parameter sets an artificial cap on how many output tokens the model is allowed to generate in its response, ensuring it does not consume your entire remaining window budget or drive up API costs unexpectedly.

03 / Lost in the Middle

Long contexts get messy in the middle.

Language models pay close attention to the very beginning and very end of your prompt, but frequently overlook details buried in the middle.

High Recall (Start) High Recall (End) LOST IN THE MIDDLE Information gets missed Token Position 0 Token Position 100,000
Why does the middle get neglected?

In 2023, Stanford researchers discovered this U-shaped attention bias. Because humans naturally place instructions at the top and questions at the bottom, pre-training biases the network to weight the edges of documents far more heavily than the center.

04 / Rolling Memories

When the desk fills up, old papers fall off.

In long conversations, apps use sliding windows or summarization to toss out early messages so new replies keep flowing.

Turn 1 (Evicted) "What was my name?" ↓ Dropped from memory ACTIVE SLIDING WINDOW (RETAINED) Turn 8 Turn 9 Turn 10 (Current) That is why an AI chatbot in turn 50 might forget something you told it in turn 1.
How developers solve this with context compression

Sophisticated agent architectures periodically run a background summarizer. When older messages are about to roll off the desk, a small model condenses 50 turns into a 3-bullet summary note that stays permanently pinned to the top of the context window.