🚀NEW COURSEVibe Coding AI Apps with Claude Code 🤖✨Enroll now
← All papers  /  Sep 9, 2026
Agents · Code · Efficiency

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

First page
AttnCompress: Dynamic Attention-Guided Trajectory Compression for Software Engineering Agents
The curator’s take

Zhengran Zeng and Yixin Li at Peking University present AttnCompress, which segments an agent trajectory at perplexity spikes, scores each historical block by proxy attention weight against the agent's current reasoning, and recalls blocks back into context as the task changes.

Ask this paper

Key points
01

Why static pruning fails on SWE trajectories: Autonomous software engineering agents generate long trial-and-error trajectories, and prior compression uses static strategies at the wrong granularity, dropping the semantic dependencies and syntactic details that code and log content require.

02

Perplexity-spike segmentation: Structure-aware segmentation cuts at perplexity spikes, which keeps the syntactic structure of code and logs intact instead of splitting at fixed token counts.

03

Proxy attention as the relevance signal: Attention weights are used to quantify how relevant each historical block is to what the agent is reasoning about right now, so relevance is recomputed rather than fixed at write time.

04

A dynamic rolling window recalls history: Blocks that were dropped can be re-evaluated and brought back as the task evolves, which is what distinguishes this from one-way pruning.

05

Result on two benchmarks: On SWE-Bench-Verified and Multi-SWE-Bench it reaches a 53.17% pass rate above prior state of the art while cutting token consumption by 21.6% and total cost by 33.6%, and it is model-agnostic across programming languages.

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.

Every Monday
Get next week’s papers.
Subscribe on Substack