Preprint
Large Language Models

Active Context Compression for LLM Agents

Nikhil Verma
January 12, 2026arXiv.org13 citations

13

Citations

4

Influential Citations

arXiv.org

Venue

2026

Year

Abstract

Large Language Model (LLM) agents struggle with long-horizon software engineering tasks due to"Context Bloat."As interaction history grows, computational costs explode, latency increases, and reasoning capabilities degrade due to distraction by irrelevant past errors. Existing solutions often rely on passive, external summarization mechanisms that the agent cannot control. This paper proposes Focus, an agent-centric architecture inspired by the biological exploration strategies of Physarum polycephalum (slime mold). The Focus Agent autonomously decides when to consolidate key learnings into a persistent"Knowledge"block and actively withdraws (prunes) the raw interaction history. Using an optimized scaffold matching industry best practices (persistent bash + string-replacement editor), we evaluated Focus on N=5 context-intensive instances from SWE-bench Lite using Claude Haiku 4.5. With aggressive prompting that encourages frequent compression, Focus achieves 22.7% token reduction (14.9M ->11.5M tokens) while maintaining identical accuracy (3/5 = 60% for both agents). Focus performed 6.0 autonomous compressions per task on average, with token savings up to 57% on individual instances. We demonstrate that capable models can autonomously self-regulate their context when given appropriate tools and prompting, opening pathways for cost-aware agentic systems without sacrificing task performance.

Analysis

Why This Paper Matters

LLM agents tackling long-horizon software engineering tasks face a critical bottleneck known as 'Context Bloat.' As interaction history accumulates, computational costs explode, latency increases, and reasoning degrades due to distraction by irrelevant past errors. This paper addresses a practical, pressing issue for AI practitioners deploying agents in real-world scenarios. The proposed solution, Focus, is agent-centric: it empowers the LLM itself to decide when and how to compress its context, rather than relying on passive, external summarization mechanisms that the agent cannot control. This shift in control is significant because it aligns with the trend toward more autonomous and self-regulating AI systems.

Inspired by the biological exploration strategies of Physarum polycephalum (slime mold), Focus introduces a persistent 'Knowledge' block where the agent consolidates key learnings, and actively prunes raw interaction history. This biological analogy provides a fresh perspective on context management, moving beyond static truncation or summarization to a dynamic, adaptive process. The paper's findings—that a capable model can autonomously self-regulate its context with appropriate tools and prompting—have immediate implications for building cost-aware agentic systems that maintain performance while reducing token usage.

Technical Contributions

  • Agent-Centric Compression: Focus allows the agent to autonomously decide when to compress, using a dedicated 'Knowledge' block for storing consolidated learnings and pruning raw history. This contrasts with passive external summarization.
  • Slime Mold Inspiration: The architecture draws from Physarum polycephalum's exploration strategies, which balance exploration and resource efficiency, informing the compression policy.
  • Optimized Scaffold: The implementation uses industry best practices, including a persistent bash environment and a string-replacement editor, to support long-horizon tasks efficiently.
  • Aggressive Prompting: The system uses aggressive prompting to encourage frequent compression, demonstrating that prompting can effectively drive self-regulation behavior.
  • Evaluation on SWE-bench Lite: The method is tested on context-intensive instances from SWE-bench Lite, a standard benchmark for software engineering tasks, providing concrete evidence of its effectiveness.

Results

Focus achieved a 22.7% token reduction (from 14.9M to 11.5M tokens) while maintaining identical accuracy (3/5 = 60% for both agents) on N=5 context-intensive instances from SWE-bench Lite using Claude Haiku 4.5. On average, Focus performed 6.0 autonomous compressions per task, with token savings up to 57% on individual instances. These results demonstrate that significant cost savings can be achieved without sacrificing task performance, at least on this small but challenging set of instances.

Significance

The broader impact of this work lies in its demonstration that LLM agents can be designed to be cost-aware and self-regulating. By enabling agents to manage their own context, we can reduce computational overhead and latency in long-horizon tasks, making agentic systems more scalable and economically viable. The biological inspiration from slime mold also highlights the potential for cross-disciplinary approaches in AI design. However, the small evaluation scale (N=5) and single model limitation mean that further validation on larger benchmarks and diverse models is needed to establish generalizability. Nonetheless, this paper opens a promising direction for developing autonomous, efficient AI agents.