AttnCompress: Dynamic Attention-Guided Trajectory Compression for Software Engineering Agents
Open Access
- 1 October 2026
- journal article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Software Engineering
- Vol. 3 (ISSTA) , 1331-1353
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.Keywords
All Related Versions
This publication has 20 references indexed in Scilit:
- Prompt Compression with Context-Aware Sentence Encoding for Fast and Improved LLM InferenceProceedings of the AAAI Conference on Artificial Intelligence, 2025
- AgentDiagnose: An Open Toolkit for Diagnosing LLM Agent Trajectories2025
- ETF: An Entity Tracing Framework for Hallucination Detection in Code Summaries2025
- Lost in the Middle: How Language Models Use Long ContextsTransactions of the Association for Computational Linguistics, 2024
- LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compression2024
- Efficient Memory Management for Large Language Model Serving with PagedAttention2023
- Compressing Context to Enhance Inference Efficiency of Large Language Models2023
- LLMLingua: Compressing Prompts for Accelerated Inference of Large Language Models2023
- BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding2019
- Focus-shifting patterns of OSS developers and their congruence with call graphs2014