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

📄 arXiv: 2609.08318v1 📥 PDF

作者: Zhengran Zeng, Yixin Li, Rui Xie, Wei Ye, Shikun Zhang

分类: cs.SE, cs.AI

发布日期: 2026-09-08

备注: 23 pages, 5 figures, accepted at ISSTA 2026


💡 一句话要点

提出AttnCompress以解决软件工程代理的动态轨迹压缩问题

🎯 匹配领域: 支柱八:物理动画 (Physics-based Animation)

关键词: 动态注意力 轨迹压缩 软件工程代理 上下文处理 模型无关 性能优化 自动化任务

📋 核心要点

  1. 现有方法在处理自主软件工程代理的冗长交互轨迹时,面临上下文窗口限制和成本高昂的问题。
  2. 本文提出AttnCompress框架,通过动态注意力机制实现轨迹压缩,保留关键的语义和句法信息。
  3. 在SWE-Bench-Verified和Multi-SWE-Bench上的实验结果显示,AttnCompress的性能显著优于现有基线,且成本更低。

📝 摘要(中文)

随着从以人为中心的辅助转向自主软件工程(ASE)代理,这些代理能够解决复杂的现实世界软件工程任务。然而,这些代理的试错性质导致了冗长的交互轨迹,造成了上下文窗口限制和成本的严重瓶颈。尽管上下文压缩提供了潜在的解决方案,但现有方法往往由于静态剪枝策略和粒度不匹配而未能有效保留对软件工程任务至关重要的语义依赖和句法细节。为此,本文提出了AttnCompress,一个动态注意力引导的轨迹压缩框架,通过结构感知分段、相关性估计和动态滚动窗口等机制,严格保留关键任务证据的同时减少上下文长度。实验结果表明,AttnCompress在SWE-Bench-Verified和Multi-SWE-Bench上实现了53.17%的通过率,超越了现有的最先进基线,同时减少了21.6%的标记消耗和33.6%的总成本。

🔬 方法详解

问题定义:本文旨在解决自主软件工程代理在处理冗长交互轨迹时的上下文窗口限制和高成本问题。现有方法由于静态剪枝策略和粒度不匹配,未能有效保留语义依赖和句法细节。

核心思路:AttnCompress通过动态注意力引导的方式进行轨迹压缩,确保在减少上下文长度的同时,严格保留关键任务证据。其设计理念是通过动态适应性来平衡语义完整性与上下文压缩。

技术框架:该框架主要包括三个模块:1) 结构感知分段,通过困惑度(PPL)峰值来保留代码和日志的句法结构;2) 相关性估计,利用代理注意力权重量化历史块与当前推理的相关性;3) 动态滚动窗口,根据任务演变重新评估和回忆历史上下文。

关键创新:AttnCompress的核心创新在于其动态适应性,通过实时评估上下文的相关性和重要性,显著提升了上下文压缩的效果,与现有静态方法形成鲜明对比。

关键设计:在参数设置上,AttnCompress采用了动态调整的注意力权重和滚动窗口机制,确保在不同任务阶段能够灵活应对,同时优化了模型的计算效率。

🖼️ 关键图片

fig_0
fig_1

📊 实验亮点

在SWE-Bench-Verified和Multi-SWE-Bench上的实验结果显示,AttnCompress实现了53.17%的通过率,超越了现有最先进基线,同时减少了21.6%的标记消耗和33.6%的总成本,展现出显著的性能提升。

🎯 应用场景

AttnCompress框架在软件工程领域具有广泛的应用潜力,尤其是在需要处理复杂代码和日志的自动化任务中。其动态轨迹压缩能力不仅可以提高软件工程代理的效率,还能降低计算成本,推动自主软件工程技术的发展。未来,该框架可能在其他需要上下文理解的领域,如自然语言处理和智能助手中展现出更大的价值。

📄 摘要(原文)

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.