On this page
- Context window in one sentence
- Tokens are not the same as words
- Input and output share the budget differently depending on the API
- What actually counts toward context?
- System instructions
- Project or workspace instructions
- Conversation history
- Tool definitions
- Tool results
- Attachments
- Reasoning/tool protocol metadata
- Why long chats get slower
- Why long chats cost more with usage-priced APIs
- What happens when the context is too large?
- Why “just drop the oldest messages” is not always safe
- Better context-management strategies
- Preserve durable instructions separately
- Keep recent turns verbatim
- Summarize old history
- Trim verbose tool results
- Retrieve files selectively
- Start a new chat when the task changes
- Context window vs memory
- Context
- App memory
- Model training knowledge
- Context window vs conversation storage
- Model switching complicates context
- Attachments make token estimates less obvious
- Tool calling can create a context explosion
- MCP tool descriptions also consume context
- Local models make context a hardware decision too
- Bigger context is not automatically better reasoning
- Why summarization can lose important details
- How to tell when context is becoming a problem
- Requests become noticeably more expensive
- Time to first token increases
- The model forgets old decisions
- The API returns a context-length error
- Attachments disappear from later reasoning
- Tool calls become confused
- Switching models breaks the chat
- A useful debugging workflow
- A practical context-budget example
- What users can do
- What a good AI client should do
- The practical takeaway
A model’s context window is the amount of information it can consider in one inference request.
That sounds like a simple token limit, but it affects almost every part of an AI chat experience:
- how much conversation history can be included;
- how many files can fit;
- whether tool results remain visible to the model;
- how much room remains for the answer;
- request cost;
- prompt-processing latency;
- local-model memory use;
- what happens when a chat grows too large.
If you have ever seen a long conversation become slower, more expensive, forget an early instruction, reject a large attachment, or suddenly summarize old messages, you have probably encountered context management.
Context window in one sentence
The context window is the model’s working input space for the current request, usually measured in tokens.
A simplified chat request might contain:
system instructions
+ project instructions
+ previous user messages
+ previous assistant messages
+ tool definitions
+ tool results
+ attached file text
+ current user message
+ room for the model's output
All of that competes for finite capacity.
The context window is therefore not simply “how long your latest prompt can be.”
Tokens are not the same as words
Models do not usually count context in human-visible words or characters. They process tokens produced by a tokenizer.
A token may represent:
- a whole short word;
- part of a longer word;
- punctuation;
- whitespace patterns;
- pieces of code;
- fragments of non-English text.
That means there is no universal conversion like:
1 token = 1 word
The ratio varies with language, content, code, formatting, and tokenizer.
This is why a client that estimates context by character count alone can be badly wrong near the limit.
Input and output share the budget differently depending on the API
When people say a model has a certain context size, they often imagine that entire amount is available for prompt history.
In practice, the client also needs room for the response.
Conceptually:
total context capacity
= input tokens
+ generated output tokens
If the request fills nearly the entire window with history and files, there may be little room left for a useful answer.
A good client therefore does not wait until the exact hard limit. It reserves output headroom.
For example:
model context limit: 100%
reserved output budget: 15%
available input budget: 85%
The exact percentages depend on the model and task, but the principle is stable: do not fill every available token with input.
What actually counts toward context?
The answer is often “more than the chat transcript you can see.”
System instructions
The system prompt can include behavior rules, safety constraints, response style, tool policy, product-specific instructions, or other hidden setup.
Even though the user may not see this text in the transcript, the model may receive it on every request.
Project or workspace instructions
A project may add reusable context such as:
- coding conventions;
- company background;
- writing style;
- product requirements;
- domain-specific instructions.
These are valuable, but they consume context too.
Conversation history
Earlier messages are the obvious component.
For stateless chat APIs, the client often resends relevant history with every new turn.
A conversation that looks like “one new message” to the user may actually become a request containing dozens of previous messages.
Tool definitions
When tools are enabled, the client may send structured descriptions of each available function:
name
description
argument schema
A handful of small tools is cheap. Dozens of verbose tool schemas can consume meaningful context before the conversation even begins.
Tool results
A tool call may return:
- search results;
- file contents;
- API responses;
- database rows;
- issue lists;
- logs;
- long JSON payloads.
If those results are inserted into the model conversation, they become context too.
This matters especially in multi-round agent workflows.
Attachments
A file may look like one attachment in the UI, but the model may receive extracted text representing thousands or tens of thousands of tokens.
PDFs, codebases, transcripts, and large Markdown documents can dominate the budget quickly.
Reasoning/tool protocol metadata
Some provider APIs and model modes carry additional structured state or reasoning-related information. Exactly what is counted depends on the provider and API.
The safe assumption for client design is that visible user text is only part of the request footprint.
Why long chats get slower
Generating one more answer in a long conversation often requires the model to process a large prompt again.
The rough shape is:
short chat
→ small prompt
→ less prompt processing
long chat
→ large prompt
→ more prompt processing
Even if the response itself is only 100 tokens, the model may first need to ingest a huge amount of history.
This is why two latency metrics should be separated:
- time to first token — includes prompt processing and provider/network delays;
- generation speed — how quickly output arrives once generation starts.
A long context can hurt the first metric even when generation speed stays similar.
For local models, the effect can be even more visible because context consumes memory and compute on hardware you own.
Why long chats cost more with usage-priced APIs
Many cloud APIs charge based on token usage.
If the client resends a growing history, later turns can contain far more input tokens than earlier turns.
Imagine this simplified sequence:
Turn 1 request: 500 input tokens
Turn 10 request: 6,000 input tokens
Turn 30 request: 18,000 input tokens
The user may type only one short sentence each time, but the provider may process much more accumulated context.
That is why “I only asked one small follow-up” does not necessarily mean “this request was small.”
For the billing side, see Understanding AI API Costs and Token Usage.
What happens when the context is too large?
There is no single universal behavior.
Different APIs and clients may:
- reject the request;
- automatically truncate input;
- drop older messages;
- summarize older conversation;
- remove large tool results;
- reduce attachment content;
- ask the user to start a new chat;
- switch to a model with a larger context window.
The important point is that something has to give.
A finite context window cannot contain an indefinitely growing transcript.
Why “just drop the oldest messages” is not always safe
A naive strategy is:
while prompt too large:
remove oldest message
That keeps the request under the limit, but it can silently remove the most important instruction in the conversation.
For example:
User, early in chat:
"Never modify production data. Only propose dry-run commands."
If that message falls out of context while later tool requests remain, behavior can change in a way the user does not expect.
This is why context budgeting should consider semantic role, not just age.
Better context-management strategies
A robust client can combine several techniques.
Preserve durable instructions separately
System and project instructions should not depend on remaining in a random old chat turn.
Store durable rules in dedicated fields and inject them intentionally.
Keep recent turns verbatim
Recent conversation usually has the highest local relevance.
A practical strategy is to preserve the newest messages exactly while compressing older material.
Summarize old history
Older conversation can be replaced with a structured summary such as:
Decisions:
- use SQLite for local persistence
- no server-side chat storage
- macOS and iOS share the data model
Open questions:
- backup format
- migration strategy
A good summary preserves decisions and unresolved state rather than merely shortening prose.
Trim verbose tool results
A tool may return 500 database rows when the model only needs five relevant fields.
The client can retain the full result for UI/audit purposes while giving the model a narrower representation.
Retrieve files selectively
Instead of dumping an entire knowledge base into every request, retrieval can choose relevant sections.
This turns context into a scarce resource that is allocated by relevance.
Start a new chat when the task changes
Sometimes the best context-management algorithm is a clean boundary.
A conversation about “design the database” does not need six months of unrelated product brainstorming attached forever.
Context window vs memory
These terms are often confused.
Context
Information included in the model’s current request.
App memory
Information the application stores outside the current request and may choose to reintroduce later.
Model training knowledge
Information learned during model training, which is neither the current chat context nor your app’s personal memory system.
A chat application can therefore “remember” something even when it is not in the current context—by storing it separately and retrieving it when relevant.
Conversely, a model can forget something from five minutes ago if the client no longer sends that information.
Context window vs conversation storage
A client can store a conversation with 500,000 tokens of history even if the selected model can only process a fraction of that at once.
Persistence and inference are separate layers:
stored conversation: potentially very large
current model request: limited by context window
This distinction matters for product design.
The UI should not imply that deleting content from the current model context necessarily deletes it from local conversation history, or vice versa.
Model switching complicates context
A multi-provider client may let you switch a conversation from one model to another.
Suppose:
Model A context limit: large
Model B context limit: smaller
A conversation that fits comfortably in A may overflow B immediately.
The client therefore needs to recompute its budget based on the currently selected model, not the chat’s historical model.
This is one reason provider/model metadata is operationally important rather than cosmetic.
For the broader multi-provider workflow, see Using Multiple AI Providers in One Workflow.
Attachments make token estimates less obvious
A user may attach a 3 MB PDF and assume the file size maps directly to context size.
It does not.
The client may:
- extract only text;
- convert tables;
- ignore images;
- send images separately;
- chunk the document;
- summarize it;
- retrieve selected pages;
- send the whole extracted text.
Each strategy produces a different token footprint.
A good UI can show that an attachment is too large or has been partially included rather than silently discarding arbitrary content.
Tool calling can create a context explosion
Agentic conversations grow differently from ordinary chat.
Consider one task:
user request
→ model tool call
→ tool result
→ model tool call
→ second result
→ model final answer
If each tool result is large, one visible user turn can generate a huge internal transcript.
Now repeat that for several rounds.
This is why tool systems need more than execution limits. They also benefit from:
- result-size limits;
- selective result projection;
- context-aware truncation;
- summaries for previous tool rounds;
- clear storage separate from what is resent to the model.
For the tool architecture itself, see MCP Tools vs Function Calling.
MCP tool descriptions also consume context
When an MCP server exposes many tools, a client may discover a long list of schemas.
Sending all of them to the model on every request can be wasteful.
A better design lets users or projects enable only the tools relevant to the conversation.
That improves more than security. It can also improve context efficiency and reduce tool-selection ambiguity.
The security side is explored in How MCP Tool Permissions Work.
Local models make context a hardware decision too
With hosted APIs, the provider owns the inference hardware.
With local AI, a larger context window can increase memory use on your machine. A theoretical model maximum may be impractical on your hardware at acceptable speed.
That means local context configuration is a tradeoff between:
- memory consumption;
- prompt-processing time;
- maximum retained history;
- number of parallel requests;
- model size;
- generation speed.
A smaller context can actually produce a better interactive experience if the client manages history intelligently.
See How to Connect Ollama to an AI Chat Client and How to Connect LM Studio to an AI Chat Client for practical local-server setups.
Bigger context is not automatically better reasoning
A model accepting more tokens does not guarantee that every token is used equally well.
Very long prompts can introduce:
- irrelevant information;
- conflicting instructions;
- duplicated facts;
- stale decisions;
- distracting tool output;
- harder retrieval inside the prompt.
The goal should not be “send the maximum possible context.”
The goal is:
Send the smallest context that preserves the information the model needs to do the task correctly.
That principle improves cost, latency, and often answer quality at the same time.
Why summarization can lose important details
Summaries are useful, but they are lossy.
A summary model may drop:
- exact numbers;
- exceptions;
- names;
- negative constraints;
- unresolved disagreements;
- code details;
- provenance.
For high-value workflows, preserve structured facts separately instead of trusting one free-form paragraph.
For example:
Pinned constraints
- output must remain backwards compatible
- no database migration in v1
- deployment target iOS 26
Conversation summary
- discussed three implementation options...
Pinned constraints and narrative summary serve different purposes.
How to tell when context is becoming a problem
Common symptoms include:
Requests become noticeably more expensive
Input-token usage climbs as the conversation grows.
Time to first token increases
The provider or local runtime spends longer processing the prompt.
The model forgets old decisions
History may have been truncated or compressed.
The API returns a context-length error
The assembled request exceeds the model/API limit.
Attachments disappear from later reasoning
The client may no longer be resending them.
Tool calls become confused
Too many tool definitions or stale tool results may be competing for attention.
Switching models breaks the chat
The new model may have a smaller context capacity.
A useful debugging workflow
When a long conversation behaves badly, inspect the request in this order:
- Selected model — what context limit applies now?
- System/project instructions — how large are they?
- Visible history — how many previous turns are resent?
- Attachments — how much extracted content is included?
- Tools — how many definitions are exposed?
- Tool results — are large payloads retained verbatim?
- Output reserve — is there enough room for the answer?
- Truncation policy — what does the client remove first?
- Summary state — what information has already been compressed?
Without that visibility, “the model forgot” can hide several completely different causes.
A practical context-budget example
Imagine a model with a fixed context budget. A client could allocate it conceptually like this:
reserved system/project instructions
+ recent conversation
+ compact summary of older history
+ selected attachment chunks
+ enabled tool definitions
+ recent tool results
+ current user request
+ reserved output space
The exact algorithm can vary, but each component has a reason to exist.
The important design property is that the client makes deliberate tradeoffs rather than depending on provider rejection at the final token.
What users can do
You do not need to manage token math manually, but a few habits help:
- start a new conversation when the task changes completely;
- keep durable project instructions in project settings rather than repeating them in chat;
- avoid attaching enormous documents when only one section matters;
- disable irrelevant tools;
- choose a larger-context model when the task genuinely needs it;
- check token/usage analytics when a chat becomes unexpectedly expensive;
- restate a critical constraint if you suspect old context was compressed.
What a good AI client should do
A client that supports serious long-running work should treat context as a managed resource.
Useful capabilities include:
- model-aware token budgeting;
- output headroom;
- visible context-limit errors;
- selective attachment handling;
- recent-turn preservation;
- old-history summarization;
- pinned instructions;
- bounded tool results;
- per-chat tool selection;
- clean recovery when switching to a smaller-context model.
The user should not have to understand every tokenizer detail, but the client should.
The practical takeaway
The context window is the model’s finite working space for a single request.
A chat application can store far more information than fits in that space, which means context management is part of the client architecture, not merely a model specification.
Long chats work well when the app continuously decides what deserves to remain verbatim, what can be summarized, what can be retrieved later, and how much room must remain for the next answer.
The most capable model still produces a poor experience if the client feeds it the wrong context.