# What happens when a chat exceeds the context window?

It depends on how the chat is run, and the vendor docs describe four behaviours: an error, a stop, trimming of the oldest turns, or a summary of them. In Anthropic's API, a prompt that is already over the window gets a 400 "prompt is too long" error, while claude.ai can manage the window on a rolling first-in, first-out basis. In OpenAI's Responses API the default is to fail with a 400 error, and the (now deprecated) auto truncation setting drops items from the beginning of the conversation instead. Both vendors also document compaction, which replaces earlier turns with a summary so the conversation can carry on.

## What happens when a chat gets too long?

A model can only read what fits in its context window, the working memory that holds the whole conversation so far plus the reply it is writing. Anthropic's [context windows guide](https://platform.claude.com/docs/en/build-with-claude/context-windows) says the window includes the system prompt, every message (with tool results, images and documents), the tool definitions and the output the model generates, including its extended thinking. OpenAI's [conversation state guide](https://developers.openai.com/api/docs/guides/conversation-state) says the window is the maximum number of tokens in one request, covering input, output and reasoning tokens, and that even when you chain responses, all earlier input tokens in the chain are billed as input.

When the total would pass the limit, the vendors document these responses:

| Behaviour | Where it is documented | What you see |
|---|---|---|
| Error | Anthropic API: if the input alone exceeds the window, the API returns a 400 `invalid_request_error` ("prompt is too long") on every model. OpenAI Responses API: with `truncation` set to `disabled`, the default, a request that would exceed the window fails with a 400 error | Nothing is lost; the request does not run |
| Stop mid-answer | Anthropic: on Claude 4.5 models and newer, if input plus `max_tokens` exceeds the window the request is accepted, and generation that hits the limit ends with `stop_reason: "model_context_window_exceeded"`. OpenAI: tokens generated in excess of the window may be truncated in responses | A cut-off answer |
| Trim the oldest turns | OpenAI reference: `truncation: "auto"` truncates to fit by dropping items from the beginning of the conversation; the reference marks this setting deprecated. Anthropic: chat interfaces such as claude.ai can manage the window on a rolling first-in, first-out basis | Early instructions silently stop applying |
| Summarise | Anthropic: server-side compaction summarises earlier parts of the conversation (beta for Claude 4.6 and later models). OpenAI: server-side compaction runs when the rendered token count crosses a `compact_threshold` and returns an encrypted compaction item that carries prior state forward in fewer tokens | A shorter history that may not keep every detail |

Anthropic also documents context editing, which clears old tool results and thinking blocks. The vendors differ on the chat apps: of the sources read here, only Anthropic says what its chat interface can do, and I found no vendor page stating exactly what the ChatGPT or Gemini apps drop. Check the app you use rather than assume.

## Worked example: how long until it fills?

Take a 200,000-token window, a 2,000-token system prompt and 8,000 tokens held back for the reply (assumed figures). If each exchange adds about 700 tokens, say 300 for the question and 400 for the answer, then (200,000 - 2,000 - 8,000) / 700 = 271.4, so the chat holds about 271 exchanges. On exchange 272 a system that trims from the front would drop exchange 1, including any rules or facts you gave at the start, and the model would answer without them and without any warning. Because every turn resends the history, input cost per turn also grows: see the [AI chat cost calculator](https://scaling.chat/cost-calculator) on Scaling Chat.

## What to do

1. Put rules that must always apply in the system prompt or project instructions, not only in your first message.
2. Restate key facts before a long task, and at about every 50 exchanges in a long session.
3. Estimate your document or chat size with the [Will it fit? calculator](/will-it-fit), leaving room for the answer.
4. For apps you build, choose the failure mode on purpose: an error, compaction with a threshold you set, or trimming that keeps the system prompt and recent turns.
5. When a chat has run long, ask for a summary of the decisions so far and start a new chat with it.

## Related

[How big are AI context windows in 2026](/context-windows), [Will it fit? calculator](/will-it-fit), [AI models compared](/models), [Why different assistants give different answers](/why-different-answers).

## Sources

Read November 19, 2026:

- Anthropic, [Context windows](https://platform.claude.com/docs/en/build-with-claude/context-windows) (overflow behaviour, compaction, context editing, cached prefixes)
- OpenAI, [Conversation state](https://developers.openai.com/api/docs/guides/conversation-state) and [Compaction](https://developers.openai.com/api/docs/guides/compaction)
- OpenAI, [Create a response (API reference)](https://developers.openai.com/api/reference/resources/responses/methods/create), `truncation` parameter

## Questions people ask

### Does the AI forget the start of a long chat?

It can. If the system trims the conversation by dropping the oldest items, the model never sees them again and cannot use anything they said. OpenAI's reference describes auto truncation as dropping items from the beginning of the conversation, and Anthropic says claude.ai can manage the window first-in, first-out.

### Does a cached prompt count toward the context window?

Yes. Anthropic's context window guide says cached prompt prefixes still occupy the context window, and that prompt caching changes what you pay for those tokens, not whether they count.

### Does my own message plus the answer count?

Yes. Both vendors say the window covers input and output, and OpenAI adds reasoning tokens. Anthropic counts the system prompt, every message, tool results, images, documents, tool definitions and the output, including extended thinking.

---
Source: https://greatest.chat/chat-exceeds-context-window . Updated 2026-11-19
