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

**Authors:** Yuhang Wang, Yuling Shi, Mo Yang, Rongrui Zhang, Shilin He, Heng Lian, Yuting Chen, Siyu Ye, Kai Cai, Xiaodong Gu  
**arXiv:** [2601.16746](https://arxiv.org/abs/2601.16746)  
**Date:** 2026-01-23  
**Summary page:** https://www.summarizepaper.com/en/arxiv-id/2601.16746v1/

## Key points

- Large Language Models (LLMs) have advanced software development tasks with coding agents like Claude Code and Gemini CLI.
- The challenge faced by these agents is accumulating long interaction contexts within the limited window of LLMs, creating a "Context Wall" that hampers performance.
- Long-context models have been developed to address this issue, but blindly processing extensive code leads to high API costs and latency problems.
- Existing context compression techniques for natural language tasks struggle when applied to coding agents as they compromise syntactic validity and discard crucial debugging information.
- SWE-Pruner is introduced as a self-adaptive context pruning framework tailored for coding agents, allowing them to articulate explicit natural language goals alongside retrieval actions.
- By training a lightweight neural skimmer on synthetic data, SWE-Pruner enables adaptive selection of relevant lines based on given goals while preserving syntactic and structural integrity.
- Evaluation shows the effectiveness of SWE-Pruner in achieving substantial token reduction on agent tasks like SWE-Bench Verified and significant compression on single-turn tasks like LongCodeQA with minimal impact on performance.
- SWE-Pruner delivers efficiency gains through token savings and enhances agent decision quality by reducing interaction rounds through more decisive reasoning.

## Summary

Large Language Models (LLMs) have made significant advancements in software development tasks, with coding agents like Claude Code and Gemini CLI showcasing their ability to seamlessly navigate repositories, run tests, and submit patches. However, these agents face a major challenge of accumulating long interaction contexts within the limited window of LLMs, creating a "Context Wall" that hampers their performance. To address this issue, long-context models have been developed but blindly processing extensive amounts of code leads to high API costs and latency issues. Existing context compression techniques designed for natural language tasks struggle when applied to coding agents as they compromise syntactic validity and discard crucial debugging information. <br>
<br>
To overcome these limitations, we introduce SWE-Pruner - a self-adaptive context pruning framework tailored specifically for coding agents. Drawing inspiration from how human programmers selectively skim through code based on their goals, SWE-Pruner enables agents to articulate explicit natural language goals alongside retrieval actions. By training a lightweight neural skimmer on synthetic data, our approach allows for adaptive selection of relevant lines based on given goals while preserving syntactic and structural integrity. <br>
<br>
Evaluation across various benchmarks and models demonstrates the effectiveness of SWE-Pruner in achieving substantial token reduction on agent tasks like SWE-Bench Verified and significant compression on single-turn tasks like LongCodeQA with minimal impact on performance. Not only does SWE-Pruner deliver efficiency gains through token savings but also enhances agent decision quality by reducing interaction rounds through more decisive reasoning.<br>
<br>
In summary, addressing the challenges posed by long interaction contexts in LLMs and providing a solution that improves efficiency and decision-making capabilities in software development tasks.
