What is context-window waste in AI coding?

The short answer

Context-window waste occurs when an AI model receives information that does not materially help it complete the current task. In coding workflows, this can include irrelevant files, duplicated source code, unnecessary dependencies, old context and repository content loaded primarily to discover where relevant code exists.

Waste, drawn

Each square is a file in a repository. The lit ones are the files that carry the answer to a single question. Everything else that gets read on the way to them is the waste this page is about.

YOUR CODEBASE
RELEVANT CODE
95.1% fewer tokens in the published benchmark.

Classifying context

Not everything sent into a model's context window plays the same role. Splitting it into rough categories makes it easier to see where waste is likely to accumulate.

Essential context

The code and information the model must have to complete the task correctly: for example, the function being modified and the type or interface contracts it must respect.

Supporting context

Related code that helps the model produce a better or more consistent result but isn't strictly required for correctness: nearby helper functions, similar patterns used elsewhere in the repository, or related tests.

Discovery context

Content loaded primarily to figure out where relevant code lives, rather than to complete the task itself: search results, directory listings, or files opened only to check whether they turn out to be relevant.

Irrelevant context

Content that doesn't materially help the task at all: unrelated modules pulled in by an overly broad scan, stale versions of files, or duplicate copies of code already present elsewhere in context.

The Context Efficiency Ratio

One way to reason about how much of a model's context window is doing useful work is to compare relevant context against total context supplied:

Relevant context tokens
─────────────────────── × 100
Total context tokens
CodeMesh proposed metric
The Context Efficiency Ratio is a CodeMesh-defined concept for reasoning about the problem of context-window waste; it is not an existing industry-standard metric, and no model provider or benchmark authority publishes it. Its value here is conceptual and illustrative: a framework for thinking about how much of a context window is relevant versus wasted, not a live, measured number CodeMesh has published for any specific repository or customer.

Give your agents the context they need

Start Saving TokensSee the Benchmark