← Latest papers
💻 computer science

Break Later or Never: Prefix-Preserving Context Compaction for Coding Agents

This paper addresses the conflict between context compaction and prefix caching in coding agents by introducing "batched observation masking" and "ObsDrop," a KV-cache-level technique that releases stale tool-observation data while preserving the logical token prefix, thereby significantly improving throughput and latency without compromising task quality.

Original authors: Musa Cim, Burak Topcu, Mahmut Kandemir

Published 2026-11-11
📖 5 min read🧠 Deep dive

Original authors: Musa Cim, Burak Topcu, Mahmut Kandemir

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). ✨ This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine a computer program designed to write code, fix software bugs, or solve complex engineering problems. These "coding agents" do not work in a single burst; they operate in a long, looping conversation with a large language model. In each step, the agent thinks, issues a command to a tool (like opening a file or running a test), and then reads the result. It then repeats the process, adding the new result to its history. Over time, this history grows into a massive document containing tens of thousands of words. To keep the system running, the computer must remember every single word of this conversation to understand the current step. This memory requirement creates a heavy burden, slowing down the system and making it expensive to run.

To manage this growing pile of text, engineers have developed ways to shrink the history, a process called context compaction. The most common method is to simply delete old parts of the conversation or replace them with a short summary. However, there is a hidden trap in this approach. Modern computers are incredibly efficient at reusing work they have already done. If a new request starts with the exact same words as a previous one, the computer can skip the heavy lifting and jump straight to the new part. But if you delete or rewrite the beginning of the conversation, even slightly, the computer loses its memory of the past and must start the heavy calculation over from scratch. The researchers behind this study discovered that the very act of trying to save space by editing the text often forces the computer to do far more work, canceling out any savings and sometimes making the system slower and more expensive.

The team, based at Pennsylvania State University, set out to understand this conflict between saving space and saving time. They observed that coding agents naturally repeat almost the entire history of their conversation in every single step. Because the history is mostly just being added to, like a diary where you only write new entries at the bottom, the computer can reuse its previous calculations almost perfectly, achieving a reuse rate of 98 to 99 percent. The biggest chunk of this memory cost comes not from the agent's thoughts, but from the raw data it receives, such as the contents of files or the logs from software tests. The researchers found that when they used standard methods to delete or summarize these old files, they broke the chain of reuse. The computer was forced to re-read and re-calculate everything that came after the deletion, turning a quick task into a slow, expensive one.

To solve this, the researchers first tested a simple adjustment to how the deletion happens. Instead of deleting old information after every single step, they tried deleting it only once every few steps. This small change, which they call "batched masking," allowed the computer to keep its memory intact for longer stretches. It reduced the amount of text the agent had to carry by up to half, while still keeping the computer's memory reuse rate high, between 95 and 98 percent. This approach lowered the cost of running the agent by up to 18 percent and made the tasks finish up to 21 percent faster. It was a practical fix that required no changes to the underlying computer software, simply a smarter way to schedule the deletions.

However, the team realized that even this improvement still involved rewriting the text, which inevitably broke the memory chain at the moment of deletion. They then developed a more advanced solution called ObsDrop. Instead of deleting words from the text that the agent sees, ObsDrop works inside the computer's memory itself. It keeps the text exactly as it is, so the computer can still recognize the pattern and reuse its previous calculations. But in the background, it quietly releases the memory slots holding the old, irrelevant data, such as the contents of files that are no longer needed. This allows the computer to keep the logical history intact for speed, while physically freeing up the space needed to run more agents at once.

The researchers tested this new system on powerful servers running multiple agents simultaneously. They found that as the number of agents increased, the standard methods began to struggle, with the system slowing down dramatically as it ran out of memory or had to constantly re-calculate. In contrast, the ObsDrop system maintained its speed and efficiency. Under heavy load, it allowed the servers to process between 2.45 and 2.85 times more work than before, and in some specific configurations, the improvement reached more than five times the original speed. The system handled the pressure without losing the quality of the work the agents produced.

This work highlights a crucial lesson for the future of artificial intelligence: managing the memory of a smart agent is not just about how much text you keep, but how you keep it. By understanding that the computer's ability to reuse past work is fragile, the researchers showed that effective management requires preserving the structure of the conversation even while discarding the data. Their new method, ObsDrop, offers a way to have both: a leaner memory footprint and a faster, more responsive system, ensuring that these powerful coding tools can scale up to handle the complex problems of tomorrow without getting bogged down by their own history.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →