Volume 1 / Part 3 Mechanics — What Happens Inside / Chapter 33
The Context Window — How Big Is the AI's Desk?
Ever been deep in a long chat with an AI, only to have it suddenly forget something you said earlier? That's not a mood swing. AI has a hard limit on how much it can "see" at once — something like the size of a desk. This time we'll look at the context window, based on how things stood as of October 2026.
The Moment a Long Conversation Stops Making Sense
If you've ever gone dozens of rounds back and forth with a chatbot, you've probably noticed things go sideways partway through. It suggests something that ignores a condition you set at the start, or it asks you the same question twice. In moments like these, most people assume the AI is just having an off day.
But what's actually happening has less to do with mood and more to do with something close to a physical constraint. An AI can't hold an entire conversation in its head forever. There's a hard cap on how much text it can process at one time.
That cap is called the context window. Last time, we looked at "temperature," the setting that makes answers to the same question vary. This time, we're talking about capacity itself — just how much an AI can handle at once.
What Is a Context Window? — The Desk-Size Analogy
Think of the context window as the frame that defines how much text an AI can reference in a single pass. People often compare it to the size of a desk. A big desk lets you spread out all your documents and compare them side by side. A small one forces you to put some away, and anything that doesn't fit just disappears from view.
For an AI, the "documents" aren't counted in letters but in units called tokens. A token is smaller than a word — in English it's roughly four characters, and in Japanese it's often just one or two characters. Whatever you type, and whatever the AI writes back, all of it gets broken down into tokens before any processing happens.
The context window is simply the number of tokens that can sit on that desk at once. And here's the twist: that number varies wildly from model to model, which is exactly what the next section is about.
Input Plus Output: The Easy-to-Miss Counting Rule
Here's where a lot of people get tripped up: they assume the context window only limits the input. In reality, input tokens and output tokens together have to fit inside that one frame. OpenAI's own documentation spells this out: the context window is the total number of tokens usable across both input and output, and for some models that total even includes internal reasoning tokens.
Let's put real numbers on this. According to OpenAI's official documentation as of October 2026, the gpt-4o-2024-08-06 model has a total context window of 128,000 tokens, of which only up to 16,384 tokens can go toward output. In other words, the longer your question, the less "desk space" is left over for the AI's answer.
This exact confusion has actually come up in OpenAI's developer community. Someone asked whether the context window limits only input, or input and output combined. Official support replied that all input, output, and control tokens are counted together. If you want a long answer, you need to keep your own question tight.
The context window is the combined total of input and output. A long question eats into the space left over for the answer.
What Happens When the Desk Overflows? — Error or Mid-Sentence Stop
So what happens if input plus output exceeds that frame? Short answer: the overflow either gets cut off or the request gets rejected with an error. But the exact behavior depends on the vendor and the model generation.
OpenAI's documentation defines it this way: the combined length of the prompt and the generated output must not exceed the model's maximum context length. Anthropic handles it differently. If the input alone already exceeds the window, you get a 400 error reading "prompt is too long." But starting with Claude 4.5, the behavior shifted: even if input tokens plus your requested output limit add up to more than the window, the request is still accepted, and generation only stops once it actually hits the ceiling, with the reason given as "model_context_window_exceeded." Older models instead throw a validation error up front.
As for Google's models, developer forum reports describe the API returning an error once total input tokens exceed the limit. Lined up side by side, it's clear there's no single universal answer to "what happens when you go over" — it genuinely comes down to each vendor's design choices. It's worth checking the official docs for whatever API or tool you're using to see which camp it falls into.
The Longer It Gets, the More the Middle Gets Skipped — Lost in the Middle
There's a second, trickier property of the context window. Even when everything technically fits inside the frame, accuracy tends to drop as the context gets longer. This phenomenon is known in research circles as "Lost in the Middle."
A Stanford research team published the finding in 2023, and it was later published in the TACL journal in 2024. In tasks that required finding an answer across multiple documents, performance was strong when the relevant information sat at the very start or very end of the document set, but dropped sharply when it was buried in the middle. Plotted on a graph, the result forms a U-shaped curve, which is where the name comes from.
Picture a thick stack of reference material where you only ever really look at the front cover and the back cover, while the middle pages go unturned. Anthropic describes this same idea in its own documentation, using the term "context rot": stuffing more context in does not automatically make a model perform better. Reading more text doesn't make an AI smarter in any simple, linear way.
The longer the context gets, the easier it is for information buried in the middle to get overlooked. Put your most important instructions at the start or the end.
Tips for Making the Most of Your Desk
So does picking a model with a huge context window solve everything? Not quite. Google's Gemini 3 family, including gemini-3.1-pro-preview, offers an enormous input window of around one million tokens according to official documentation as of October 2026. But output limits vary a lot across that same family — some models top out around 64,000 tokens, while image-generation models cap out at just 32,000. In other words, it's entirely possible for two models to share the same huge input capacity while their output room differs by more than double.
Here's something worth trying yourself. Next time you're deep into a long chat with an AI service, ask it: "Do you remember the condition I mentioned at the start?" If the answer is off, that might be a sign the desk is full. When that happens, the practical fix is to summarize the conversation so far, or start a fresh conversation and restate the conditions.
Put your most important instructions either right at the start of the conversation or in your very next message. Summarize conversations before they get too long. Small habits like these can meaningfully change how accurate an AI's answers are. The desk size itself is fixed, but how you use the desk is entirely up to you.
FAQ
Does the context window limit only the input, or output too?
It's the combined total of input and output that counts against the limit. OpenAI's official documentation describes it as the sum of input, output, and for some models even internal reasoning tokens.
What happens if you go over the context window?
Depending on the vendor and model generation, you either get an error or the generation gets cut off partway through. Anthropic's older models throw an error upfront, while Claude 4.5 and later let generation run until it actually hits the limit — both documented officially.
What is "lost in the middle"?
It's the tendency for information placed in the middle of a long context to get overlooked more easily than information at the start or end. A Stanford research team published the finding in 2023, and it appeared in the TACL journal in 2024.
Even when a conversation looks continuous, the AI might just be rereading everything from scratch each time. Next time, we dig into whether AI actually has "memory" — and the surprising mechanics behind it.
Primary sources
- OpenAI Developer Platform – Conversation state — Context window = input plus output total; gpt-4o token counts
- OpenAI Developer Platform – Key concepts — Primary source stating that prompt plus generated output must not exceed the maximum context length
- Claude Platform Docs – Context windows — Differences in overflow behavior; origin of the term "context rot"
- Lost in the Middle: How Language Models Use Long Contexts (Stanford, arXiv) — Original paper on the lost-in-the-middle phenomenon
- ACL Anthology – Lost in the Middle (TACL 2024) — Peer-reviewed publication record of the same paper
- Google AI for Developers – Gemini 3 developer guide — Input/output token limits for Gemini 3 family models
- OpenAI Developer Community – What does CONTEXT WINDOW mean — Referenced as a reader-relatable discussion thread
- Google Developer Forums – Gemini Pro and Flash 002 shorter context window — Real-world example of a Gemini API overflow error
This article organizes general knowledge based on our experience and public sources. Product specs, prices, and regulations reflect the time of writing (October 8, 2026) and may change.