AI Agents on Long Tasks Drown in Their Own Notes. Trimming Them Cuts the Load by 26-54% (Context Compression)

4 min read

A long-horizon agent, an AI program that works through a long, many-step task on its own, accumulates context, the text it keeps in front of the model, the way a desk accumulates paper. Every tool call (each action it takes, like a search), every observation (each result that comes back), every turn of conversation goes into the prompt, the text sent to the model. After an hour of work, the prompt is enormous. The model, the AI language program doing the thinking, slows down, the bill grows, and the attention, the model's focus on what matters, dilutes across thousands of tokens, chunks of text the model reads and you pay for, that no longer matter.

New to these terms? Every word is explained in the series glossary.

Context compression, shrinking what goes into the prompt, is the answer, and ACON is a system that optimises it for long-horizon agents. It reduces peak token usage, the biggest the prompt gets, by 26 to 54 percent on AppWorld, OfficeBench, and multi-objective question answering, three test settings for agents, while improving task success over existing compression baselines, the older methods it is compared against. For smaller language models, the performance improvement reaches up to 46 percent. Smaller models benefit most, because they are the ones that choke first on long context.

The techniques are practical. Summarise old turns instead of keeping the raw transcript. Retrieve only the history that is relevant to the current step. Drop stale observations that no longer affect the task. Keep a structured state, a short summary of what is decided and what is still open, instead of the full log. Each technique trades a little information for a lot of tokens, and the art is knowing which information is safe to lose.

What to compress first is a decision, not a guess. Old tool outputs go first, because the agent already acted on them. Stale observations go next, because the world has moved on. Repeated system instructions, the standing rules given to the model, can be replaced by a short pointer. What stays in full detail is the present: the current goal, the latest observation, and the next step. ACON optimises exactly this choice, learning which parts of the context to keep and which to compress, instead of applying one rule to everything.

Animation: The prompt fills with tool calls and observations, then the past is summarised and the present kept in full.

Smaller models benefit most. The paper reports up to 46 percent performance improvement for smaller language models, and the reason is simple. A small model's effective context, how much text it can really use well, is shorter, so it chokes sooner on long histories. Compression buys it room it did not have. A large model can muscle through a long prompt. A small one cannot, and compression is what makes it viable for long-horizon work at all.

There is a catch, and it is worth stating plainly. Compared with no compression at all, there is a small accuracy tax on some benchmarks. Compression is a trade, not a free lunch. You give up a little accuracy to fit the task into the window, the limit on how much text the model can see at once, at all. The alternative is not perfect accuracy. The alternative is a prompt so long the model cannot use it, or a bill so large you cannot afford it.

The way to think about it is as a budget. Every agent has a token budget per step, set by cost and latency, the waiting time. Compression is how you stay inside it. The best systems do not compress blindly. They compress the past and protect the present: the current goal, the latest observation, and the next step stay in full detail, while everything older gets summarised or dropped.

My read is that context compression is becoming as important as the model itself for agents. The model is rented by the token. The context is what you pay for. An agent that manages its context well can run ten times longer on the same budget, and that is often the difference between a demo and a product.

ACON peak token reduction
Low end26%High end54%
Data from the sources listed below.

Try this

Clone, meaning download a copy of, the open-source ACON implementation and see how it decides what to compress.

bash
git clone https://github.com/microsoft/acon

Then build a tiny context summariser yourself. You need an OPENAI_API_KEY, an API key that lets your code use OpenAI's models. The code uses the OpenAI Python library and the small gpt-4o-mini model.

python
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])
history = [
    'Turn 1: user asked for a flight to Delhi.',
    'Turn 2: agent found 3 options, user picked the 6pm flight.',
    'Turn 3: agent asked about baggage, user said one bag.',
    'Turn 4: agent asked about meals, user said vegetarian.',
]
summary = client.chat.completions.create(
    model='gpt-4o-mini',
    messages=[{'role': 'user', 'content': 'Summarise this agent history in two sentences, keeping every decision: ' + ' '.join(history)}],
).choices[0].message.content
print(summary)

Sources