What is a context window? Sizes by model in 2026 and 9 practical tips

What is a context window? Sizes by model in 2026 and 9 practical tips

A context window is the maximum amount of text, measured in tokens, that a language model can consider at once: your prompt, the conversation so far, attached files, tool results and its own reply. This guide explains what counts toward it, current sizes by model, what happens when it fills up, and the habits that keep long chats and agents accurate.

In shortTL;DR
  • The context window is the model's working memory for one request. It is measured in tokens and includes the reply, not only your input.
  • As of November 2026, Claude, GPT-6 and Gemini 4 models all offer about 1 million tokens; Anthropic puts 1M tokens at roughly 555,000 English words.
  • When the window fills, APIs reject the request or stop generating, and chat apps or agents drop or summarize older turns, so early details get lost.
  • Bigger is not automatically better: accuracy and recall degrade as context grows (context rot), and every turn re-sends the whole history, which costs money and time.
  • Start a fresh chat per task, put lasting rules in a project file, retrieve only relevant documents, and summarize before you switch topics.

What is a context window?

A context window is the total amount of text a large language model can take into account when it generates a response, counted in tokens. Anthropic's context window docs define it as "all the text a language model can reference when generating a response, including the response itself" and describe it as the model's working memory.

Three things are easy to mix up:

TermWhat it isHow long it lasts
Context windowEverything the model can see in this requestOne request; rebuilt each turn
Training dataThe text the model learned from before releaseFixed until a new model version
App memoryFacts an app saves and re-inserts into new chatsUntil you delete them

A model does not "remember" your last conversation by itself. Each request is assembled from scratch: the app or your code gathers the system prompt, the history and any files, and sends all of it again. If something is not in the window, the model cannot use it.

What counts toward the context window?

Everything sent with the request counts, plus everything the model writes back. Anthropic's docs list the system prompt, every message (including tool results, images and documents), the tool definitions, and the output for the turn, including extended thinking.

In practice, a typical turn in a chat app or coding agent contains:

  1. The system prompt and app instructions you never see.
  2. Project or custom instructions (for example a CLAUDE.md file or a custom GPT's instructions).
  3. Saved memories the app inserts.
  4. Tool and connector definitions.
  5. The conversation so far, including pasted text, files and images.
  6. Tool results: search results, file contents, command output.
  7. The model's reasoning and its reply.

The units are tokens, pieces of words that the model's tokenizer produces. A rough conversion helps when you plan:

1Mtokens in Claude's context window
555KEnglish words in 1M tokens, approximately
150KEnglish words in 200K tokens, approximately
Source: Anthropic, Claude models overview (November 2026). Ratios depend on the tokenizer and the text.

Code, tables, JSON and many non-English languages use more tokens per word than plain English prose. Our guide to AI tokens covers tokenization in detail.

How big are context windows in 2026?

As of November 2026 the flagship models from Anthropic, OpenAI and Google all have context windows of about one million tokens; open-weight models range from 128K to 1M. The maximum reply length is a separate, smaller limit.

ModelContext windowMax outputSource
Claude Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.51M tokens128K tokensAnthropic
GPT-6 Astra, GPT-6.1 Sol, GPT-6 Luna1,050,000 tokens (max input 922,000)128,000 tokensOpenAI
Gemini 4 Argon1,048,576 tokens, shared by input and output65,536 by default, up to 1,048,576 with long decodeGoogle
DeepSeek V4.1 Flash (open weights)1M tokensn/aModel card
Qwen3.8-27B (open weights)262,144 native, up to 1M with scalingn/aModel card
Gemma 4 (open weights)128K (E2B, E4B) or 256K (12B and up)n/aModel card

Two caveats. First, these are API limits; a chat app or a plan may give you less, and local runners often load a model with a smaller context than its maximum unless you raise it in settings. Second, a 1M window does not mean 1M tokens of useful attention, as the next sections show. For open models and their hardware needs, see our comparison of open source LLMs.

What happens when the context window is full?

When a conversation outgrows the window, something has to give: the request fails, the reply is cut off, or older content is removed or summarized. Which one you get depends on whether you use an API, a chat app or an agent.

  • APIs. On the Claude API, if the input alone exceeds the window you get a 400 invalid_request_error ("prompt is too long"). If the input fits but generation runs into the limit, the response stops with stop_reason: "model_context_window_exceeded" on Claude 4.5 and newer models.
  • Chat apps. Apps manage the window for you, for example on a rolling first-in, first-out basis or by summarizing older turns. The visible symptom is that the assistant "forgets" instructions or details from early in the chat.
  • Coding agents. Claude Code compacts the conversation into a summary as it nears the limit. The summary keeps your requests and key code snippets, but detailed instructions from early in the session may be lost, which is why persistent rules belong in CLAUDE.md. Run /context to see what fills the window and /compact focus on the API changes to summarize with a focus.
Tall stack of paper-clipped documents on a desk
A larger window lets you hand the model more pages at once, but it reads the middle of the stack less carefully.

Is a bigger context window always better?

No. A larger window lets the model see more, but accuracy and recall drop as the input grows, and every extra token costs money and time. Anthropic's docs call the effect context rot: "As token count grows, accuracy and recall degrade," which makes curating what goes in as important as how much space is available.

Two pieces of research show what that looks like:

  • Lost in the middle. Liu et al. found that models answered best when the relevant information sat at the beginning or end of the input, and "significantly" worse when it sat in the middle of long contexts, even for models built for long context.
  • Context rot. Chroma's 2025 report tested 18 models and found performance "grows increasingly unreliable as input length grows," even on simple tasks, and that simple needle-in-a-haystack tests overstate real long-context ability.

The costs are concrete too:

Trade-offWhy it happensExample
PriceEach turn re-sends the whole history as input tokensA 200K-token conversation on Claude Sonnet 5.5 ($2 per million input tokens) costs about $0.40 in input for every new message without caching
Price tiersSome models charge more for long promptsClaude Haiku 5.5 input costs $0.10 per million tokens up to 100K tokens and $0.50 above
SpeedThe model must process every token before it answersLong prompts take noticeably longer to the first word
QualityIrrelevant text competes for attentionA pasted 300-page manual can bury the one paragraph that matters

Prompt caching lowers the price of re-sending the same prefix, but cached tokens still occupy the window.

How do you work within a context window? 9 practical tips

Keep the window small and relevant: give the model what this task needs, in a place it will notice, and nothing else. These habits work in chat apps, APIs and coding agents.

  1. One chat per task. Start a new conversation when the topic changes. In Claude Code, /clear starts fresh while keeping project memory.
  2. Put lasting rules in a project file. Custom instructions, Projects or CLAUDE.md are re-loaded every session, so rules survive compaction and new chats.
  3. Put the key instruction at the start or the end. Given the lost-in-the-middle effect, place the question after long documents and restate critical constraints at the end.
  4. Paste excerpts, not whole files. Give the model the three relevant sections instead of the full contract or log.
  5. Retrieve instead of stuffing. For large knowledge bases, use search or retrieval-augmented generation so only matching passages enter the window.
  6. Trim tool output. Agents fill windows fastest with logs and test output; ask for summaries or the last 50 lines.
  7. Summarize and restart. When a long chat starts drifting, ask for a handoff summary (prompt below) and paste it into a new chat.
  8. Delegate to subagents. In agent tools, a subagent works in its own context window and returns only its result, which keeps the main conversation clean.
  9. Measure before you send. On the API, count tokens first so you know whether a request fits and what it costs.

This prompt produces a summary you can carry into a fresh conversation:

prompt
We are going to continue this work in a new chat. Write a handoff note of at most 300 words:1. Goal: what we are trying to achieve, in one sentence.2. Decisions made so far, with the reason for each.3. Constraints and preferences I stated (formats, tone, tools, things to avoid).4. Current state: what is done, what is in progress.5. Next three steps.Do not include anything we discarded.

And this checks a request's size on the Claude API with the token counting endpoint:

terminal
curl https://api.anthropic.com/v1/messages/count_tokens \  -H "x-api-key: $ANTHROPIC_API_KEY" \  -H "anthropic-version: 2023-06-01" \  -H "content-type: application/json" \  -d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Paste your long prompt here"}]}'

The response is a small JSON object such as {"input_tokens": 14}. The broader discipline of deciding what goes into the window is called context engineering.

How do context windows affect AI agents?

AI agents use context faster than chats, because every file they read and every command output they see lands in the window. A long agent session therefore lives or dies by compaction, subagents and good project files, not by the raw window size.

Practical consequences for agent work:

  • Sessions are independent. A new session starts with an empty window, so anything the agent must know every time belongs in CLAUDE.md or an equivalent file.
  • Big outputs cause thrashing. Claude Code's docs note that if one file or tool output is so large that the window refills right after each summary, auto-compaction stops after a few attempts and shows an error instead of looping.
  • Small, well-scoped tasks finish more reliably than one giant task that spans several compactions.

This matters most when agents run for hours without you watching. If you run Claude Code or Codex on an always-on Orkio box, break work into tasks that each fit comfortably in one session and keep the rules in the repository, so each fresh session starts with the right context. Our Claude Code tips cover more of these habits.

Context window checklist

  • Know your model's window and max output, and remember the reply counts too.
  • Start a new chat or session for each separate task.
  • Keep permanent instructions in a project file, not in the chat.
  • Place long material first and the question last; restate key rules at the end.
  • Send excerpts and retrieved passages instead of whole documents.
  • Summarize and restart when answers start ignoring earlier instructions.
  • Count tokens before large API requests, and use caching for repeated prefixes.

Frequently asked questions

Is a context window the same as memory?

No. The context window is short-term working memory for a single request and is cleared when you start a new chat. Memory features in apps such as ChatGPT or Claude save selected facts outside the window and insert them into future conversations. The model's training data is a third, separate thing.

How many words fit in a 1 million token context window?

Anthropic estimates about 555,000 English words, or 2.5 million characters, in 1M tokens on Claude's current tokenizer, and about 150,000 words in 200,000 tokens. Other vendors' tokenizers differ, and code, tables and non-English text usually use more tokens per word.

Does the AI's answer count toward the context window?

Yes. The context window holds the input and the output generated for that turn, including any hidden reasoning or thinking tokens. A request with 990,000 tokens of input in a 1M-token window has only about 10,000 tokens left for the reply.

Why does ChatGPT or Claude forget what I said earlier?

In a long conversation the app may drop or summarize older turns to stay within the context window, and even text that is still in the window is recalled less reliably as the conversation grows. Restate key constraints, or start a new chat with a short summary of what matters.

Do bigger context windows make RAG unnecessary?

Not for most uses. A large window lets you paste whole documents, but retrieving only the relevant passages is cheaper, faster and often more accurate, and many knowledge bases are larger than any context window. The two work together: retrieval chooses what goes into the window.

SOURCES

  1. Claude docs: Context windows
  2. Claude docs: Models overview
  3. OpenAI API docs: GPT-6 Astra
  4. Gemini API docs: Gemini 4 Argon
  5. Liu et al.: Lost in the Middle: How Language Models Use Long Contexts
  6. Chroma: Context Rot, How Increasing Input Tokens Impacts LLM Performance
  7. Claude Code docs: How Claude Code works
  • #context window
  • #llm
  • #tokens
  • #ai basics
Orkio team

The team building Orkio. We write about putting AI to work: coding agents that run overnight, always-on boxes and pull requests ready by morning.

Keep reading

All posts

07:06 · YOU MERGED #128

Go to sleep. Wake up to pull requests.

Start for $19 a month
© 2026 Orkio · Hosted in Europe TürkçeStatus