Same agent, ten times the reading
Ines, an analyst at an energy consultancy, puts two questions to the firm's research agent on the same Monday. What did home battery systems cost per kWh in Germany in 2023 and in 2025? takes nine model calls and about 150,000 input tokens in all. Which ten installers in Bavaria and Baden-Württemberg grew fastest in 2024, and how do their prices compare? reads 1.5 million input tokens over 23 calls, then stops with a context-length error. Same agent, same prompt, same model. The second question needed more steps, and every step was longer than the one before.
Everything the model reads, on every call
A model keeps nothing between calls. An agent seems to remember the start of its task because every call puts it in front of the model again, whether the app resends the history or the provider's API keeps it. The context window is the most a single call can hold: its input and, on most models, the output it writes, measured in tokens, word fragments of a few characters of English text each, the exact split depending on the model's tokenizer.
In Ines's agent the input has four parts, with illustrative sizes:
- The system prompt: the firm's rules on sources, units and citing, about 2,000 tokens.
- The tool definitions: a name, a description and a parameter schema for each of six tools, about 3,000 tokens. Each tool connected costs tokens on every call; discovery is MCP: how agents discover and call tools.
- The conversation: Ines's question, her follow-ups, and each reply and tool call the model wrote.
- The tool results: every search listing, page and table a tool returned, kept so that later steps can use them.
The first two are the same on every call; the last two only grow. In the second run each step added about 5,500 tokens, mostly fetched pages, so call 23 read about 126,000 tokens, leaving about 2,000 for its output in a model with a 128,000-token window, and call 24 would have needed 131,500 for its input alone. Because each call rereads every earlier step, the total read grows roughly with the square of the number of steps: twice the steps, close to four times the tokens. Every call's input is billed, and the wait for the first output token tends to grow with it, so each step was slower and dearer than the last. At the limit, the API may refuse the call, as here, or a framework may quietly drop the oldest messages, which can include the task itself.
Smaller results, at the tool
The largest line in the ledger was pages. The fetch tool returned a page's whole text, menus, cookie notice and footnotes included, about 9,000 tokens, when the agent wanted one price table. The fix belongs to the tool: return the main text, capped at 2,000 tokens, with the passages that match the query first, and have search return titles, snippets and URLs instead of pages. Long single-agent runs, like those in the AI Agent Platform Challenge, pile up results the same way.
Results also outlive their use. Once the agent has taken an installer's 2024 price from a page, the page can leave the history and a one-line note can take its place: the URL and the figure taken from it. If the page is needed again, fetching it costs one call; carrying it costs every call after.
The file the model never reads
Next the run needs a public registry export of home battery installations, one row per system with its installer, region, capacity and commissioning date: 90,000 rows, several million tokens as text. Even a window that held it would charge for every row on every later call, and a pasted sample would rank the sample. So the download tool writes the file to Object Storage and returns a reference instead: the path, the column names, the row count and three example rows, about 300 tokens.
The model writes a short program that filters the two states, counts each installer's installations in 2023 and 2024 and ranks them by the absolute increase, so a high percentage on a tiny 2023 base is not enough to top the list, and a Code Sandbox runs it against the file and returns a ten-row table. The model sees the program, its output and the three sample rows, never the whole file; running its code safely is Sandboxing untrusted code: isolation, limits & egress.
Folding the early turns into a note
The run still grows, because Ines keeps asking follow-ups. Compaction replaces the older part of the history with a summary once the context passes a threshold, here 60% of the window, about 77,000 tokens: a model call reads the early turns and writes a note of about 2,000 tokens on what was found, what was decided and what is still open, and the run continues from that note plus the latest few turns.
A summary loses detail by design, and what it drops is no longer in front of the model. In one test run the note said ranked installers by 2024 growth and left out Bavaria and Baden-Württemberg only; the next answer ranked installers across Germany. So two things stay out of the summariser's reach: the task with Ines's constraints, word for word at the top of every call, and a structured list of sources, each URL with the figures taken from it. Compaction is itself a model call that can make mistakes, so its prompt is tested on recorded runs (Evaluating LLM output: golden sets, judges & release gates). Notes that must survive a crash belong in the run's stored state (Durable workflows: orchestration that survives restarts). Memory across conversations is Long-term memory for assistants: write, recall, update, forget.
Ten reports, ten fresh contexts
The comparison needs the annual report of each of the ten installers, 40 to 80 pages each. Rather than read them itself, the lead agent hands each report to a sub-agent, a separate agent run with a context of its own that starts from a brief and ends by returning a result. The brief carries the question, the region constraint, the figures wanted (revenue growth in 2024, to set beside the registry's installation growth, and average price per kWh), the format of the answer and a limit of 15 steps. Each report reader may go through 60,000 tokens of report; what comes back is about 300:
installerand the two figures, each with its unit and year;sources: the URL and page of every figure;not_found: what the report does not state, so a gap arrives as a gap and not as a zero.
The lead agent keeps the task, the notes and ten short results. Each report reader starts from a brief. The registry stays in storage and reaches the sandbox, never a context.
The lead's context grows by about 3,000 tokens for ten reports instead of 600,000, and each reader works on one report with no other nine competing for its attention. It does not make the run cheaper by itself: every sub-agent pays for its own prompt, tools and steps, and multi-agent runs often read more tokens in total than one agent would, though here the lead no longer rereads every report. And the hand-off loses in both directions: a reader knows only its brief, so a constraint left out of it is ignored, and the lead knows only the result, which is why sources and gaps are fields, not optional prose. Whether to split work between agents at all, and in what shape, is AI Agent Orchestration patterns.
Paying less for the part that repeats
Every call here starts with the same system prompt and tool definitions, and several providers can cache such a prompt prefix so that a later call starting with exactly the same tokens is processed faster and billed less for that part. Whether caching is automatic or marked, the minimum length and how long an entry lives differ by provider, so what never changes goes first and anything per request, such as a date, after it. The cache lowers the price and the wait for that prefix, not the size of the window.
The same run, drawn
The Multi-Agent Research Assistant Challenge turns Ines's second question into a design brief: an orchestrator whose specialists each get only the context they need and return a compact, structured result, not a transcript. A good answer shows on the edges what a brief holds and which fields come back, keeps large intermediate data in Object Storage with a path travelling in its place, and notes each agent's token budget and what compaction may never summarise away.
Why not just a bigger window
A larger window would have moved the error from call 24 to a later call, with every call still paying for everything it read. Nor does a model use a long input evenly. In Lost in the Middle (Liu and others, 2023), models answered more accurately when the relevant passage sat near the start or end of a long input than in its middle, including models built for long contexts, and later tests report accuracy falling as inputs grow. The aim is not the most context that fits, but a context that holds what this step needs.