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

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Wang, Yuhang, Shi, Yuling, Yang, Mo, Zhang, Rongrui, He, Shilin, Lian, Heng, Chen, Yuting, Ye, Siyu, Cai, Kai, Gu, Xiaodong
Format: Preprint
Publié: 2026
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866911656221605888
author Wang, Yuhang
Shi, Yuling
Yang, Mo
Zhang, Rongrui
He, Shilin
Lian, Heng
Chen, Yuting
Ye, Siyu
Cai, Kai
Gu, Xiaodong
author_facet Wang, Yuhang
Shi, Yuling
Yang, Mo
Zhang, Rongrui
He, Shilin
Lian, Heng
Chen, Yuting
Ye, Siyu
Cai, Kai
Gu, Xiaodong
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2601_16746
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents
Wang, Yuhang
Shi, Yuling
Yang, Mo
Zhang, Rongrui
He, Shilin
Lian, Heng
Chen, Yuting
Ye, Siyu
Cai, Kai
Gu, Xiaodong
Software Engineering
Computation and Language
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.
title SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents
topic Software Engineering
Computation and Language
url https://arxiv.org/abs/2601.16746