How the Context Window Eats Up Agent Budgets: Measuring Tokens Correctly

How the Context Window Eats Up Agent Budgets: Measuring Tokens Correctly

While developers argue over which model is best for agents, the main limitation is no longer the quality of responses, but the context window. An engineer from the Russian-speaking community measured actual token consumption in MCP agents and discovered that tool schemas occupy only 2% of the context, while their responses account for the remaining 98%. A single verbose tool response can exceed the entire budget of the schemas and continue to do so with every call.

Why the context window has become a bottleneck

The context window is the amount of data a model can process in a single request. It is measured in tokens: one token is approximately 0.75 words in English and 0.5 words in Russian. This includes instructions, conversation history, tool schemas, and everything those tools return. The more tasks an agent takes on, the more often it hits this limit.

In 2023, GPT-3 worked with a 4,000-token window. Today, Claude supports 200,000, and Gemini claims a million. But increasing limits hasn't solved the problem: agents have started performing longer tasks, and token consumption has grown proportionally. This is especially noticeable in enterprise scenarios where an agent must work with dozens of tools and maintain context throughout the entire session.

Where tokens are actually spent in agentic systems

Traditionally, it was believed that the primary expense was tool schemas. Lazy loading and the search_tools function were proposed as the main solution: loading tool descriptions only as needed. But measurements showed otherwise:

  • Tool schemas — static JSON descriptions of parameters and capabilities. They take up 2% of the context and are loaded once.
  • Tool responses — dynamic data returned with every call. They take up 98% and remain in the context until the end of the session.

A single snapshot of a web page, a directory listing, or the result of a SQL query spanning several dozen lines consumes the entire schema budget in one go. And it continues to do so with every new call. Saving on schemas does not affect the part that grows throughout the entire session.

What to do: three practical steps

Agent optimization is becoming a separate engineering discipline. Here is what you can do right now:

  1. Measure actual consumption. Most APIs provide token counters in their responses. Track how many tokens are spent on schemas, how many on tool responses, and how many on conversation history. Without measurements, optimization turns into guesswork.
  2. Reduce tool responses. If a tool returns an entire HTML page, replace it with a version that extracts only the text. If a directory listing contains metadata, keep only the file names. Every kilobyte of a response is a set of tokens that will sit in the context until the end of the session.
  3. Manage history. Not everything from the conversation history needs to be kept in the context at all times. Determine what can be summarized, what can be offloaded, and what should be kept. This is especially critical for long sessions with dozens of tool calls.

Why this is important for Russian developers

The release of Claude Opus 4.8 on May 28, 2026, demonstrated a new level of agentic systems: the model plans tasks and launches hundreds of parallel sub-agents in a single session, covering code base migrations of hundreds of thousands of lines. The context window is 1 million tokens, but even that may not be enough if every tool returns verbose responses.

For Russian companies transitioning from foreign software as part of import substitution, using agents for refactoring and legacy code migration is particularly relevant. But without controlling token consumption, the cost of such tasks can increase significantly. Token optimization is becoming just as important a skill as model selection and prompt quality.

Try Claude Opus 4.8 and other models for agentic tasks at GEMERA AI — access via Telegram bot and web dashboard, without blocks and with support in Russian.