Source-linked AI summary
AttnCompress: Dynamic Attention-Guided Trajectory Compression for Software Engineering Agents
Zhengran Zeng, Yixin Li, Rui Xie, Wei Ye, Shikun Zhang
TL;DR
Long-horizon ASE agents face context-window and cost bottlenecks, while existing compression can lose dynamic dependencies and precise code or debugging details. AttnCompress combines PPL-based segmentation, proxy-attention relevance estimation, and dynamic rolling context maintenance. It reports a 53.17% pass rate with lower token consumption and total cost, while evaluation scope remains constrained across agent frameworks.
Problem
Long-horizon ASE trajectories create context-window and cost bottlenecks, while existing compression can lose dynamic dependencies and precise software details.
Method
AttnCompress combines PPL-based structure-aware segmentation, proxy-attention relevance estimation, and a dynamic rolling window for recalling relevant historical context.
Results
53.17% pass rate, 21.6% lower token consumption, and 33.6% lower total costs were reported across SWE-Bench-Verified and Multi-SWE-Bench-Flash.
Takeaways & Limitations
The framework preserves syntactic integrity and semantic dependencies while reducing context and resource demands for SE agents.
Takeaways & Limitations
External validity is limited because computational costs restricted evaluation across agent frameworks.
Abstract
from arXiv · showhide
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.
1 Introduction
Autonomous Software Engineering agents solve complex tasks through long-horizon trial-and-error interactions, but accumulating context creates efficiency and reasoning bottlenecks. AttnCompress addresses static compression and granularity limitations with structure-aware segmentation, proxy-attention relevance scoring, and dynamic context maintenance, achieving strong benchmark results with lower resource use.
- Long-horizon SE agent trajectories accumulate verbose logs, redundant files, and obsolete errors, increasing latency, API costs, and context-length risk.
- Existing compression methods use heuristic pruning, summarization, or selection, but struggle with dynamic dependencies and precise software artifacts.
- AttnCompress combines PPL-based segmentation, proxy attention relevance estimation, and a rolling window that can re-evaluate and recall suppressed context.
- 53.17% pass rate, 21.6% lower token consumption, and 33.6% lower total costs were reported on SWE-Bench-Verified and Multi-SWE-Bench-Flash against Agent Diet.
2 Background & Related Work
SE agents repeatedly process tool outputs, with observations forming most of their context. Related compression methods reduce length but face uneven information density, shifting relevance, structural fragility, semantic loss, or deployment overhead.
- 2.1 LLM-based SE Agents & Workflow: Observation tokens comprise 62.6% of interaction traces, exceeding Action, Thought, and Task Input and making environmental feedback the main source of context bloat.
- 2.2 The Context Challenge in SE: SE trajectories have uneven information density: in django-11133, over 700 retrieved lines were noise while the useful make_bytes method occupied about 15 lines.
- 2.2 The Context Challenge in SE: Historical relevance shifts during debugging, so permanently pruning utils.py can force the agent to reopen it after the root cause returns to that file.
- 2.3 Background & Related Work: Heuristic methods are simple and efficient but lack semantic awareness, potentially discarding earlier evidence needed after a hypothesis shift.
- 2.3 Background & Related Work: Summarization methods may alter exact paths, line numbers, error codes, or variable names, while adding runtime overhead and latency.
- 2.3 Background & Related Work: Prior methods motivate compression that preserves structural integrity while dynamically selecting context according to the agent’s current needs.
3 Approach
AttnCompress is a plug-and-play middleware that segments trajectories into semantic blocks, scores historical relevance with proxy attention, and dynamically maintains compressed context through rolling updates.
- AttnCompress uses three consecutive phases: structure-aware segmentation, attention-based scoring, and dynamic context maintenance.
- The framework aims to make compressed trajectories much shorter while retaining information relevant to the agent’s current reasoning step.
- Structure-Aware Segmentation: PPL spikes identify semantic boundaries in tool outputs, producing non-overlapping blocks that preserve relatively independent syntactic or semantic units.The method detects adjacent-line PPL differences above an adaptive threshold and merges one-line fragments with the preceding block.
- Attention-Based Scoring: Proxy attention scores each block by averaging attention from the query token to its contained tokens, then greedily retains highest-scoring blocks within a token budget.The query token is appended after historical context and the new observation, allowing its attention to represent relevance to the next response.
- Dynamic Context Maintenance: The rolling mechanism keeps recent turns raw, repeatedly re-compresses short-term history, and archives long-term history until a global refresh is triggered.This combines frequent short-term updates with lower-frequency long-term refreshes to accommodate task-focus drift while reducing inference overhead.
4 Experimental Design
The evaluation tests AttnCompress against baselines for cost-effectiveness, component contributions, and generalization across proxy models and multilingual software-engineering benchmarks.
- Research Questions: The study evaluates whether AttnCompress balances problem-solving effectiveness with token, monetary, and latency efficiency against state-of-the-art baselines.
- Research Questions: Ablation studies measure the contributions of PPL segmentation, proxy-attention scoring, rolling windows, and sensitivity to tail size and compression ratio.
- Research Questions: Generalization is tested across Qwen and Llama proxy models and on the multilingual Multi-SWE-Bench dataset.
- Datasets: The benchmarks comprise a 100-instance SWE-Bench-Verified validation set for tuning and ablations, a 200-instance test set for main comparisons, and 300 multilingual tasks across seven languages.The languages are Rust, TypeScript, JavaScript, Java, Go, C, and C++.
- Baselines and Metrics: Evaluation reports Pass%, interaction-step metrics, input and output tokens, agent cost, and compression cost to characterize performance and resource trade-offs.All baselines are integrated into the same Trae-Agent framework, with the applicable tail size standardized to k=2.
5 Results
AttnCompress achieves the strongest reported balance of pass rate, token use, cost, and latency among the evaluated compression methods, while its ablations show that attention guidance, dynamic recall, and PPL segmentation each contribute to performance. Results also reveal remaining failures when later reasoning requires discarded evidence.
- Limitations: AttnCompress can still discard earlier paths, helper functions, or error messages that later reasoning needs, causing incorrect decisions and unrecovered failures.
- Main results: 21.6% lower token consumption and 33.6% lower total cost than AgentDiet demonstrate AttnCompress’s efficiency advantage.Mean input is 644.66k tokens, and total cost is $0.0949 versus AgentDiet’s $0.1429.
- Main results: 366.7s average end-to-end time includes 66.6s of compression overhead, while AgentDiet averages 498.5s.Heuristic baselines are faster but achieve lower pass rates, indicating a speed–effectiveness trade-off.
- Main results: 53.17% pass rate is the highest among studied compression methods, improving upon AgentDiet by 3.9%.
- Component contribution: Removing proxy attention, the rolling window, or PPL segmentation reduces pass rate by 7.0%, 5.0%, or 3.0%, respectively.The corresponding ablation pass rates are 35.0%, 37.0%, and 39.0%.
- Sensitivity analysis: Larger rolling windows improve pass rate from 35.0% to 42.0% with minimal token-cost impact, whereas larger tail sizes improve pass rate but increase cost.Increasing tail size from 2 to 10 raises pass rate to 44.0% while changing cost from $0.0557 to $0.0821.
6 Threats to Validity
The evaluation faces internal threats from possible training-data leakage and hyperparameter overfitting, while external validity is constrained primarily by evaluation on Trae-Agent. Mitigations include Multi-SWE-Bench, shared backends, a held-out test set, and validation across proxy models and seven programming languages.
- Internal validity: Data leakage is an internal threat because proprietary LLMs may have encountered SWE-Bench issues during training.The authors include the newer Multi-SWE-Bench and note that shared backend models preserve relative comparisons if leakage affects baselines equally.
- Internal validity: Hyperparameter overfitting is mitigated by isolating 100 validation instances from the 200-instance test set.The separation is intended to ensure reported test performance reflects generalization rather than tuning on the evaluation set.
- External validity: Generalization across agent frameworks remains constrained because computational costs limited evaluation primarily to Trae-Agent.The authors argue transferability is theoretically plausible because most software-engineering agents follow similar ReAct patterns.
- External validity: Validation across Qwen, Llama, and Gemma proxy models and seven programming languages supports broader model and language generalization.The reported consistency suggests the findings are not limited to one model architecture or programming language.
7 Conclusions
AttnCompress addresses context scalability in Autonomous Software Engineering agents with structure-aware segmentation, proxy attention relevance estimation, and dynamic rolling-window maintenance. On SWE-Bench-Verified, it reports a 53.17% pass rate while reducing token consumption by over 21.6% and total costs by 33.6%.
- Conclusion: AttnCompress addresses the context scalability bottleneck in Autonomous Software Engineering agents.The framework targets efficient processing of long-horizon software-engineering tasks.
- Conclusion: The framework combines PPL-spike segmentation, proxy attention-guided relevance estimation, and dynamic rolling-window maintenance.These mechanisms target syntactic integrity, semantic dependencies, and changing task relevance during compression.
- Conclusion: 53.17% pass rate is reported on SWE-Bench-Verified, alongside over 21.6% lower token consumption and 33.6% lower total costs.The conclusion characterizes AttnCompress as outperforming strong compression baselines while reducing resource use.
- Conclusion: The results support dynamic attention alignment as a model-agnostic approach for efficient, long-horizon software-engineering tasks.This conclusion remains within the reported scope of the evaluated framework and benchmarks.