Context Window Visualizer
Set the tokens for your system prompt, tools, chat history, RAG context and output reserve, pick a model window (8K–1M), and watch a stacked bar fill it. The moment it overflows, the tool shows exactly how much compaction would have to trim from history and retrieved context to make the request fit.
- Summarize 5.0k tokens of chat history
One window, many tenants
A model's context window is a single fixed budget of tokens, and everything competes for it at once: the system prompt, every tool definition, the entire chat history (re-sent on every turn), any retrieved documents, the current user message — and space reserved for the output. If the sum exceeds the window, the request is rejected or silently truncated, and truncation is worse: the model quietly loses the start of your prompt and you get a confidently wrong answer.
Why it's usually not the question
People imagine the user's message fills the window. It rarely does. In an agent or RAG app the heavy bands are the system prompt (rules, persona), the tool schemas, the history that grows every turn, and the retrieved context. Watch the bar above: nudge history and RAG and they swamp everything else long before the user message matters.
Reserve room to answer
The window is shared between what you send and what comes back. Fill it entirely with input and the model has nowhere to write its reply. That's why this tool reserves output tokens and only calls a prompt "fitting" when the answer fits too — a subtlety that trips up a lot of first agents.
What compaction does when it overflows
When the prompt won't fit, a harness compacts: it summarizes the oldest chat history into a short running summary and trims or re-retrieves context, while keeping the system prompt, tool schemas and current turn intact. The overflow panel above estimates how much of each band would need to go — and warns you when even full compaction isn't enough and you have to cut tools, shorten the system prompt, or move to a bigger window.
How it works
- Input = system + tools + history + RAG + user; output is reserved on top.
- All of it shares one window — history and RAG grow the fastest.
- Overflow means the request is rejected or truncated: something must give.
- Compaction trims history and retrieved context first; prompts and tools stay.
Frequently asked questions
What is a context window?
A context window is the maximum number of tokens a model can consider in a single request — everything you send (system prompt, tool definitions, chat history, retrieved documents, the user's message) plus room reserved for the response must fit inside it. Exceed it and the request is rejected or silently truncated.
What fills up the context window in an agent?
Usually not the user question. The bulk is the system prompt, the tool/function definitions, the growing chat history (re-sent every turn), and any RAG or document context — all sharing one budget, with output tokens reserved on top. This tool shows each contributor as its own band so you can see what is crowding the window.
Why reserve tokens for the output?
The window is shared between input and output. If you fill it entirely with input, the model has no room to answer. Reserving output tokens (say 1–4K) guarantees space for the response; this tool subtracts that reserve from the usable budget so "fits" means the answer fits too.
What does compaction trim first?
Typically the oldest, bulkiest, most-summarizable content: chat history (folded into a running summary) and retrieved context (re-retrieved or trimmed), while the system prompt, tool schemas and current message stay intact. This tool estimates how much of each would need to go to bring an over-budget prompt back under the cap.