Kipt

Your prompts and skills, one keystroke away.

Explore

What is a context window? LLM context limits explained

What a context window is, what counts toward it, current context sizes for Claude, GPT and Gemini models, what happens when it fills, and how compaction works.

By the Kipt team · Updated 26 October 2026

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 Google 1,048,576 tokens (input and output combined) 65,536 by default Model page
Gemini 3.8 Flash Google 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_management with a compact_threshold, or calling the standalone /responses/compact endpoint, 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:

  1. 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.
  2. Clear between unrelated tasks. Claude Code's cost guide says to use /clear when switching to unrelated work, since "Stale context wastes tokens on every subsequent message."
  3. Check what is using space. Run /context in Claude Code to see the breakdown.
  4. 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.
  5. Move rarely used instructions into skills. Claude Code loads skill descriptions at start and full skill content only when used.
  6. 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.
  7. 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.

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.

Questions

What is a context window in an LLM?

The context window is the maximum number of tokens a model can work with in one request, counting both what you send and what it writes back. It acts as the model's working memory. Anything outside it, such as earlier chats that were not resent, is invisible to the model.

How big are context windows in 2026?

As of October 2026, current Claude models list a 1M-token context window. OpenAI's GPT-6.1 Sol and GPT-6 Astra list 1,050,000 tokens with a 922,000-token input cap, and Google lists 1,048,576 tokens for Gemini 4 Argon. Always check the model page for the exact model you call.

Does the output count toward the context window?

Yes. Anthropic and OpenAI both count the model's output, including reasoning or thinking tokens, toward the window. A request whose input nearly fills the window leaves little room for the answer, so leave headroom for long outputs.

What happens when the context window is full?

It depends on the API and the app. Claude's API returns a prompt is too long error if the input alone exceeds the window, and OpenAI says output beyond the limit may be truncated. Coding agents like Claude Code compact the conversation into a summary automatically as they approach the limit.

Is a bigger context window always better?

No. Anthropic's docs say accuracy and recall degrade as token count grows, which they call context rot, and Google notes accuracy drops when a model must find several facts in a long context. A focused context usually beats a full one.

What is context compaction?

Compaction replaces older parts of a conversation with a shorter summary so work can continue past the limit. Anthropic and OpenAI both offer server-side compaction in their APIs, and Claude Code runs it automatically or on demand with /compact.

More in Learn

All guides

Keep your prompts and skills in one place, in your own GitHub. Install every skill with one command.

Get started

Kipt is an independent product, not affiliated with or endorsed by Anthropic, OpenAI, Cursor or GitHub. Claude, ChatGPT, Codex, Cursor and GitHub are trademarks of their owners.