Attention improves compression of software engineering agent interactions

AttnCompress: Dynamic Attention-Guided Trajectory Compression for Software Engineering Agents

Software EngineeringArtificial Intelligence

Summary

Software engineering agents, which help automate coding tasks, often produce very long records of their work that are hard to manage and expensive to process. The authors designed AttnCompress, a method that smartly shortens these records by focusing only on the most important parts while keeping the meaning and details intact. This method looks at where the changes in code or logs are most significant, measures the relevance of past steps to current decisions, and updates its focus as tasks evolve. AttnCompress reduces the amount of data handled and the cost involved, while still performing better than previous methods. It works across different programming languages and with various models.

What this means in practice

  • For software development teams: Reduce the cost and improve performance of AI-based coding assistants by compressing their interaction histories without losing critical context.
  • For code analysis tool developers: Enhance tools that analyze or debug code by maintaining important dependencies and details while managing large volumes of sequential data efficiently.

Authors

Zhengran Zeng, Yixin Li, Rui Xie, Wei Ye, Shikun Zhang

Abstract

The transition from human-centric assistance to Autonomous Software Engineering (ASE) agents has enabled the resolution of complex real-world SE tasks. However, the trial-and-error nature of these agents generates lengthy interaction trajectories, creating severe bottlenecks in terms of context window limits and cost. While context compression offers a potential remedy, prior approaches suffer from static pruning strategies and granularity mismatches, often failing to preserve the semantic dependencies and syntactic details crucial for SE tasks. To strictly preserve critical task evidence while reducing context length, we introduce AttnCompress, a dynamic attention-guided trajectory compression framework. Unlike existing approaches, AttnCompress bridges the gap between semantic integrity and dynamic adaptability through three key mechanisms: (1) structure-aware segmentation via perplexity (PPL) spikes to preserve the syntactic structure of code and logs; (2) relevance estimation using proxy attention weights to quantify the precise relevance of historical blocks to the agent's current reasoning; and (3) a dynamic rolling window to re-evaluate and recall historical context as the task evolves. Extensive evaluation on SWE-Bench-Verified and Multi-SWE-Bench demonstrates that AttnCompress achieves a pass rate of 53.17%, outperforming prior state-of-the-art baselines while reducing token consumption by 21.6% and total costs by 33.6%. The framework proves to be model-agnostic and generalizes effectively across diverse programming languages.