<!-- description: A context window is the most tokens an LLM can handle in one request: prompt, conversation, tool results and reply. What it is, sizes, and how agents manage it. -->

# Context Window

A **context window** is the maximum amount of text, measured in [tokens](token), that a large language model (LLM) can take in and produce in a single request. Everything the model works with has to fit inside it: the system prompt, the whole conversation so far, every file and tool result the agent has read, and the reply it is writing now.

In plain terms, the context window is the model's working memory. Anything inside it, the model can see and reason about. Anything outside it, the model does not know exists.

## What Is a Context Window, in One Example

Ask an agent to fix a failing test. Before it writes a line, its context already holds the system prompt and tool definitions, your message, the test output, and the three source files it opened. Each edit, each command it runs, and each result it reads back is appended. Forty turns later, all of that is still in the window and is sent to the model again on every turn.

That is why a context window has two limits, not one:

- **A hard limit.** When the conversation reaches the model's maximum, older content has to be dropped or summarized before the next request can be sent.
- **A cost and quality limit.** Long before the hard limit, a full window makes every turn slower and more expensive, and buries the details that matter under ones that no longer do.

## Context Window Sizes

| Model | Context window |
|-------|----------------|
| Claude Fable 5.1 | 1M tokens |
| Claude Opus 5.5 | 1M tokens |
| Claude Sonnet 5.5 | 1M tokens |
| Claude Haiku 4.5 | 200K tokens |

One million tokens is roughly 750,000 words, enough for a large codebase. Size limits change with every model release, so check your provider's model documentation for the model you actually run.

## How Agents Manage the Context Window

[Agents](agent) run in long loops, so their context grows on its own. The usual ways to keep it under control:

- **Clear it between tasks.** Start each new task on an empty context instead of carrying the last task along. See [clear context](clear-context).
- **Compact it.** Summarize earlier turns into a short recap and continue from the summary. Claude Code does this automatically near the limit, and on demand with `/compact`.
- **Trim tool results.** Keep only the lines of a log or file the agent needs, not the whole thing.
- **Keep knowledge outside the window.** Store durable facts in [workspace memory](/features/workspace-memory) or files the agent can read again when it needs them.

Poor context management shows up as an agent that "forgets" an instruction from earlier in the session, repeats work, or stalls mid-task.

## Context Windows and AgentRQ

AgentRQ keeps human conversation and task history outside the model's context. An agent pulls the one task it is working on over [MCP](mcp) instead of holding every past exchange, and AgentRQ can [clear the agent's context](/features/clear-context) before it picks up each new task, so every task starts small.

## Related Terms

- [Clear Context](clear-context)
- [Token](token)
- [Agent](agent)
- [Claude Code](claude-code)
- [Tool Use](tool-use)
