A context window is the maximum amount of text, measured in tokens, that a language model can consider in a single request, including both your input and the model's own response. Think of it as the model's working memory: if information is not inside the window, the model cannot see it.
OpenAI's conversation state guide states it plainly: "The context window is the maximum number of tokens that can be used in a single request." This guide covers what counts toward the window, how big current windows are, what happens when one fills, and how to manage it in coding agents.
What is a context window?
Every request to a large language model is self-contained. The model does not remember your last call; the app resends whatever history it wants the model to see. The context window is the cap on that bundle.
Anthropic's context window docs define it as "all the text a language model can reference when generating a response, including the response itself." They add that it is different from the data the model was trained on and "instead represents a 'working memory' for the model."
Google's long context guide uses a similar analogy: "An analogy for the context window is short term memory."
What counts toward the context window?
More than most people expect. Anthropic's docs list it out: the system prompt, every message (including tool results, images and documents), your tool definitions, and the output the model generates, "including its extended thinking."
OpenAI's guide says the limit "includes input, output, and reasoning tokens."
In a coding agent, the window fills with:
- The agent's system prompt and tool definitions.
- Instructions files such as CLAUDE.md or AGENTS.md.
- Every file the agent reads and every command output it sees.
- The full conversation so far, including the model's earlier replies.
- The reply it is writing now.
Prompt caching does not shrink this. Anthropic notes that cached prefixes "still occupy the context window": caching changes what you pay, not whether the tokens count. See what tokens are for how text maps to tokens.
How big are context windows in 2026?
Figures below come from each vendor's official model pages, read in October 2026. Check the page for the exact model you call, because limits differ between models and sometimes between input and output.
| Model | Vendor | Context window | Max output | Source |
|---|---|---|---|---|
| Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1 | Anthropic | 1M tokens | 128K tokens | Models overview |
| GPT-6 Astra | OpenAI | 1,050,000 tokens (922,000 max input) | 128,000 tokens | Model page |
| GPT-6.1 Sol | OpenAI | 1,050,000 tokens (922,000 max input) | 128,000 tokens | Model page |
| Gemini 4 Argon | 1,048,576 tokens (input and output combined) | 65,536 by default | Model page | |
| Gemini 3.8 Flash | 1,048,576 input tokens | 65,536 tokens | Model page |
A few details from those pages are worth knowing:
- Anthropic says 1M is the default for its 1M-token models, with no beta header needed. Older models such as Claude Sonnet 4.5 (deprecated) have a 200k-token window.
- Anthropic estimates 1M tokens at "roughly 555k words or 2.5M Unicode characters" on its current tokenizer.
- OpenAI's GPT-6 Astra page notes prompts over 272K input tokens are billed at higher rates.
- Google says Gemini 4 Argon can produce up to 1,048,576 output tokens with long decode.
- Google's long context guide puts 1 million tokens at about "50,000 lines of code (with the standard 80 characters per line)."
What happens when the context window fills up?
At the API level, behavior differs by vendor. On Claude, Anthropic's docs say that if the input alone exceeds the window, "the API returns a 400 invalid_request_error" on every model. On Claude 4.5 models and newer, a request whose input plus max_tokens exceeds the window is accepted, and if generation reaches the limit it stops with stop_reason: "model_context_window_exceeded".
OpenAI's guide warns that "Tokens generated in excess of the context window limit may be truncated in API responses."
Quality can drop well before you hit the hard limit. Anthropic says: "As token count grows, accuracy and recall degrade, a phenomenon known as context rot." Google's guide notes that when a model must find several facts in a long context, "the model does not perform with the same accuracy." A window that is 80 percent full of stale logs is worse than one that holds only what the task needs.
What is context compaction?
Compaction replaces older turns with a shorter summary so a conversation can keep going. Both major API vendors now offer it:
- Anthropic: the context window docs say server-side compaction "automatically summarizes earlier parts of the conversation on the server," and list it as available in beta for Claude 4.6 and later models. Context editing adds narrower tools, such as clearing old tool results.
- OpenAI: the compaction guide describes turning it on by setting
context_managementwith acompact_threshold, or calling the standalone/responses/compactendpoint, which returns a compacted context window you pass to the next request.
Coding agents do this for you. Claude Code's How Claude Code works page says it "compacts the conversation into a summary" as you approach the limit, and that "detailed instructions from early in the conversation may be lost." You can steer what survives with /compact and a focus, such as /compact focus on the API changes. Our Claude Code compact guide covers the details.
How do you manage the context window in a coding agent?
These habits come from the agents' own docs and apply to most tools:
- Put lasting rules in an instructions file. Claude Code's docs say to put persistent rules in CLAUDE.md "rather than relying on conversation history," because compaction can drop early instructions.
- Clear between unrelated tasks. Claude Code's cost guide says to use
/clearwhen switching to unrelated work, since "Stale context wastes tokens on every subsequent message." - Check what is using space. Run
/contextin Claude Code to see the breakdown. - Delegate noisy work. Subagents run in their own context window, so test runs and log digging stay out of your main conversation and only a summary comes back.
- Move rarely used instructions into skills. Claude Code loads skill descriptions at start and full skill content only when used.
- Filter big outputs before the model sees them. The cost guide shows a hook that greps test output for failures instead of passing the whole log.
- Ask specific questions. A precise prompt with file paths leads to fewer exploratory reads than "improve this codebase."
The Claude Code context window guide goes deeper on that tool, and context engineering covers the broader practice of choosing what goes in.
Where should reusable context live?
The prompts you paste at the start of a task, like a review checklist or a debugging brief, are part of your context too. Keeping them short and reusable saves tokens on every run. Kipt keeps prompts and Agent Skills as Markdown in a private GitHub repo you own, so you can store a tight version once and reuse it instead of retyping a longer one.
What should you read next?
Read what tokens are to estimate how much text fits, then context engineering for strategies to keep the window focused. For background on the models themselves, see what an LLM is.