Announcing US$ 3.2M pre-seed round · OneVC · Maya · Norte Ventures Read →
Back to blog

Context window:
what it is and how agents use that space well

In short

A financial control agent spends the afternoon reconciling invoices with purchase orders. At each step it calls a tool, gets a result and adds that result to what it was already carrying. At some point the accumulated volume approaches the limit the model accepts in a single call, and the quality of the answers had started to drop well before that. This space is the context window. How it is filled sets cost and quality, and it depends on the Company Brain, the layer that knows the company: what data exists, where it lives, how it connects and who may see what.

The context window is everything the model receives in a call

System instructions, tool descriptions, examples, conversation history, results of earlier steps, retrieved documents and records. All of it goes into the same space, measured in tokens, the fragments of text the model processes and the provider charges for. Whatever stays outside the context window plays no part in the answer.

The maximum size varies by model and has grown considerably in recent years. Available space and well-used space are still different measures.

A bigger window does not fix answer quality on its own

A guide to context engineering for agents published in September 2025 brings together observations on this behaviour. As the number of tokens grows, the model's precision in recalling a specific piece of information inside the context window tends to drop. It happens in every model, at different rates, and has been nicknamed context rot.

The explanation lies in the architecture. In a transformer, every token is related to every other token, and the number of pairs grows much faster than the number of tokens. The guide describes this limit as a finite attention budget, where every token added uses up a share of it.

Hence the central principle: look for the smallest set of high-signal tokens that makes the desired outcome likely. Every component of the context window goes through that filter.

A full context window compared with a curated window holding a few high-signal tokens
In a curated context window, the passage that decides the answer takes up more of the attention budget

System instructions work best at the right altitude

An instruction can go wrong in two directions. One is hard-coding rigid logic, full of conditions, that breaks on the first unforeseen case and needs maintenance every time a process changes. The other is vague guidance, such as asking the agent to be careful with discrepancies, which assumes context the model never received.

The right altitude sits between the two. In the financial control agent, the instruction defines what counts as a relevant discrepancy, asks that each one cite both source documents and leaves the order of the analysis open. Separate sections for role, rules, tools and output format make review easier.

Tools and examples also take up the context window

Each tool enters the window with its name, description and parameters. A large set with overlapping tools, such as three ways to look up a supplier, spends tokens and creates ambiguous choices. The guide's test is simple: if an engineer cannot say which tool to use in a given situation, the agent is likely to get it wrong too.

The same goes for examples. A long list of edge cases tries to cover every rule and bloats the window. A few varied, representative examples show the expected behaviour with fewer tokens.

Just-in-time retrieval keeps the window light

The common practice is to load everything that might be useful at the start. The alternative described in the guide is for the agent to keep light references, such as an order identifier, a file path or a saved query, and fetch the content through a tool when the step needs it.

The two approaches are often combined. Part of the context arrives at the start, for speed, and the rest is fetched during the task. Just-in-time retrieval costs execution time and depends on references that point to something that can be queried.

A context window loaded up front compared with just-in-time retrieval by identifiers
With just-in-time retrieval, the context window keeps light references and fetches the content when the step needs it

Long tasks call for compaction, notes and subagents

In tasks with many steps, the history grows beyond what fits or what is worth keeping. Three techniques deal with this:

  • Compaction: near the limit, the history is summarised, keeping decisions and open items and discarding tool results that have already done their job.
  • Structured notes: the agent records its progress outside the context window, such as the discrepancies already resolved, and reads those notes when it needs them.
  • Subagents: focused tasks run in clean windows and return only a condensed summary to the main agent.

In a multi-step agent, the history is resent on every call. Compacting that history lowers the cost per token of the whole task, and a lean window lets simple steps run on smaller models.

The Company Brain delivers the slice to the window already resolved

In the Company Brain, the light reference is the entity in the knowledge graph: the identifier of the customer, the contract or the order. The agent keeps the identifier and, when the step needs it, asks for the slice over MCP, the open protocol that connects models to data sources.

The slice arrives resolved. The business ontology has already defined what each term means, the semantic layer has taken the question to the right source and permissions have been inherited from the source system. What enters the context window is the records and relationships the step needs, each with its source, and a single context endpoint takes the place of several overlapping tools.

The Company Brain delivering a resolved slice over MCP to the agent's context window
The Company Brain returns to the context window only the slice the step needs, with permissions and source

The context window depends on reliable sources and on evaluation

Curation does not fix bad data at the source. If the ERP has a duplicated order, the slice arrives with the duplicate. Compaction can also discard a detail that turns out to be needed later, so summaries have to be evaluated on real tasks.

A context window review starts with one up-front load

The practical starting point is to pick, in an agent already in production, a set of documents loaded on every call. It is replaced with identifiers and just-in-time retrieval, and the team compares cost and accuracy on the same tasks. The sources the agent starts querying most often show where the first Company Brain slice should begin.

Get the next articles on context architecture for AI