SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents
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 and up to 14.84x compression on single-turn tasks like LongCodeQA with minimal performance impact.
6976d4105d41524304c13517
Yuhang Wang
claimed_verified
2026-01-29T09:17:48.783Z
679cbc024ee3403814ca0e74
/avatars/0fc11476c642121eb264a891b072bb0e.svg
Yuhang Wang
ayanami-kitasan
user
ayanami-kitasan
6976d4105d41524304c13518
Yuling Shi
claimed_verified
2026-01-26T08:28:56.805Z
645b0c3ec35da9c7afd95421
https://cdn-avatars.huggingface.co/v1/production/uploads/645b0c3ec35da9c7afd95421/vYBrCDagHsXAo6J2p-uG0.jpeg
Yuling
YerbaPage
user
YerbaPage
6976d4105d41524304c13519
Mo Yang
6976d4105d41524304c1351a
Rongrui Zhang
6976d4105d41524304c1351b
Shilin He
claimed_verified
2026-01-27T09:43:51.995Z
62c6df026a092eda1f1ab6e5
/avatars/d58fff1a157b189ce2617889ef5f6e2f.svg
Shilin He
shilhe
user
shilhe
6976d4105d41524304c1351c
Heng Lian
6976d4105d41524304c1351d
Yuting Chen
6976d4105d41524304c1351e
Siyu Ye
6976d4105d41524304c1351f
Kai Cai
6976d4105d41524304c13520
Xiaodong Gu
claimed_verified
2026-01-28T11:32:11.281Z
6624ede5478dada13051af60
/avatars/1b064f7e3c417f1b603909ff3dbf2430.svg
xiaodong gu
guxiaodong1987
user
guxiaodong1987
SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents
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 and up to 14.84x compression on single-turn tasks like LongCodeQA with minimal performance impact.
SWE-Pruner is a self-adaptive context pruning framework for coding agents that uses task-aware pruning to reduce token usage while maintaining performance.
context compression LongLLMLingua PPL code understanding task-aware adaptive pruning neural skimmer token reduction SWE-Bench Verified LongCodeQA