arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2601.16746cs.SEcs.CL
收藏

SWE-Pruner: 为编码代理设计的自适应上下文修剪

SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents

Yuhang Wang, Yuling Shi, Mo Yang, Rongrui Zhang, Shilin He, Heng Lian, Yuting Chen, Siyu Ye, Kai Cai, Xiaodong Gu

AI总结:

本文提出SWE-Pruner,一种针对编码代理的自适应上下文修剪框架,通过任务感知的动态修剪策略减少长上下文影响,提升代码生成效率与准确性。

摘要:

LLM代理在软件开发中展现出显著能力,但长交互上下文导致高API成本和延迟。尽管已有如LongLLMLingua等上下文压缩方法,但通常依赖固定指标如PPL,忽视代码理解的任务特定性。本文提出SWE-Pruner,一种自适应上下文修剪框架,灵感来自人类程序员在开发和调试中选择性浏览源代码的方式。SWE-Pruner根据当前任务制定明确目标(如

英文摘要:

LLM agents have demonstrated remarkable capabilities in software development, but their performance is hampered by long interaction contexts, which incur high API costs and latency. While various context compression approaches such as LongLLMLingua have emerged to tackle this challenge, they typically rely on fixed metrics such as PPL, ignoring the task-specific nature of code understanding. As a result, they frequently disrupt syntactic and logical structure and fail to retain critical implementation details. In this paper, we propose SWE-Pruner, a self-adaptive context pruning framework tailored for coding agents. Drawing inspiration from how human programmers "selectively skim" source code during development and debugging, SWE-Pruner performs task-aware adaptive pruning for long contexts. Given the current task, the agent formulates an explicit goal (e.g., "focus on error handling") as a hint to guide the pruning targets. A lightweight neural skimmer (0.6B parameters) is trained to dynamically select relevant lines from the surrounding context given the goal. Evaluations across four benchmarks and multiple models validate SWE-Pruner's effectiveness in various scenarios, achieving 23-54% token reduction on agent tasks like SWE-Bench Verified while even improving success rates, and up to 14.84x compression on single-turn tasks like LongCodeQA with minimal performance impact.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑