Manuscript Offprint

arXiv:2610.25516

Bud ContextCompact 2.0: Context Compaction for Agent Success and Accuracy with Small Language Models and Constrained Context Windows

Jithin VG, Ditto PS

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Agents that work for many turns outgrow the context window of the model that serves them, and on small language models (SLMs) and constrained inference systems that window is small. Context compaction replaces older turns with a summary so a session can continue, but it is lossy, it costs a model call, and whether it helps or hurts accuracy depends on when it runs. We describe Bud ContextCompact 2.0, the compaction built into the Bud agent runtime, and evaluate it in two settings. On recall questions over recorded agent sessions, compaction to a 16K budget raised a 1.2B-parameter model's accuracy from 0.247 (truncated history) and 0.176 (full 32K history) to 0.335 (p < 0.001 against the full history), and compaction to a 32K budget raised a 9B model from 0.515 (truncated) to 0.577 (p = 0.04). On agentic software engineering, 100 SWE-bench Verified tasks run end to end by a 27B reasoning model on a 49K-token window (556 graded sessions), compaction raised the resolve rate on long sessions from 41% to 53% (+12.3 pp, 95% CI +1.6 to +23.0, exact McNemar p = 0.043), left short sessions unchanged (+1.7 pp, p = 1.0), and did so at equal total token cost and 13% fewer tokens per solved task. The dominant failure without compaction was not the history overflowing but a reasoning turn exhausting the space the history left. Two conditions bound the gain: under a 45-minute session budget it vanished (-3.3 pp, p = 0.48), because each summary took a median 161 s; and in a threshold study it appeared only when compaction triggered early enough to leave room (24K threshold, +13.9 pp on long pairs; 48K, compaction ran in 4 of 50 sessions and the arm behaved like no compaction). An 8B model on the same tasks submitted after about ten turns at 5–8K tokens and never needed compaction. We argue that the accuracy results transfer across hardware for an equivalent model and window, while the time cost scales with the hardware and must be budgeted for.

1 Introduction

Tool-using agents alternate model calls and tool calls until a task is done [17]. Every observation, command output and intermediate thought is appended to the conversation, so the prompt grows with every turn. Software-engineering agents are an extreme case: a single SWE-bench task [6, 10] routinely takes tens to hundreds of turns, many of them reading files and test logs [13, 16]. When the conversation no longer fits the model's context window, the session fails.

The window available to an agent depends on where it runs. Hosted frontier models offer windows of hundreds of thousands of tokens. Small language models (SLMs) deployed on a single GPU, a desktop accelerator or a CPU usually run with 8K to 64K: the KV cache that a longer window needs competes for scarce memory, prefill time grows with the prompt, and many small models degrade well before their nominal limit [3, 8]. These are exactly the deployments where a long-running agent hits the wall first.

Context compaction keeps a session inside its window by replacing older turns with a summary [11]. It is not free. The summary is lossy; writing it costs a model call; it can invalidate the provider's prefix cache; and it can run at the wrong time—too late to prevent an overflow, or so often that the agent spends its time summarising. Whether compaction improves an agent's success, and under which conditions, is an empirical question that published agent evaluations rarely isolate, because they change scaffolding, prompts and models at the same time.

This paper isolates it. We evaluate Bud ContextCompact 2.0, the compaction built into the Bud agent runtime (Section 3), with A/B comparisons in which the compaction setting is the only difference between arms. We report:

• SLM evidence on recall (Section 4): with 1.2B and 9B models answering questions over recorded agent sessions, compaction to a constrained budget beat both truncation and, for the 1.2B model, the full history.

• Agentic evidence (Section 5): on 100 SWE-bench Verified tasks run by a 27B reasoning model, compaction raised the resolve rate on long sessions by 12.3 points (p = 0.043), with a replication on 40 tasks added after the first result.

• Mechanism (Section 5.3): with a reasoning model, the binding constraint was the room left for a turn’s reasoning, not the history itself.

• Boundary conditions (Sections 5.4–5.6): the gain vanishes under a tight wall-clock budget, depends on the trigger threshold, and needs sessions long enough to compact—which an 8B model on these tasks never produced.

• Cost (Section 5.7): equal total tokens, 13% fewer tokens per solved task, every summary at full measured fidelity.

Section 6 discusses what transfers to SLM and CPU deployments and what does not.

References (15)