# swe-pruner **Repository Path**: wowtools/swe-pruner ## Basic Information - **Project Name**: swe-pruner - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: public - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-05 - **Last Updated**: 2026-03-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents
[![arXiv](https://img.shields.io/badge/arXiv-2601.16746-b31b1b.svg)](https://arxiv.org/abs/2601.16746) [![GitHub](https://img.shields.io/badge/GitHub-Repo-181717.svg?logo=github)](https://github.com/Ayanami1314/swe-pruner) [![PyPI](https://img.shields.io/pypi/v/swe-pruner.svg)](https://pypi.org/project/swe-pruner/) [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-blue)](https://huggingface.co/ayanami-kitasan/code-pruner) [![Bytedance](https://img.shields.io/badge/Bytedance-Research-blue)]() [![License](https://img.shields.io/badge/License-MIT-green.svg)]() [![Blog](https://img.shields.io/badge/Notion-Blogs-000000)](https://www.notion.so/Yuhang-Wang-s-LLMSE-articles-2f0b0995619480d09880e9668338651e)

Semantic Highlight  โ—ฆ  Coding Agent Native  โ—ฆ  Flexibly Use  โ—ฆ  Long Context Tailored

Make Claude Tokens 40% Saving!

Tokens Cost Reduction

๐Ÿ“ข Latest Updates

**๐Ÿ”ฅ Releases:** - 1/28/2025: We release some scripts for optimize and visualize the result! see `./utils` - 1/27/2025: We published our tech blogs: `Towards Real-World Software Agents: How we push Semantic Highlight feature to Agentic Coding?` - ๐Ÿ“„ [Towards Real-World Software Agents: How we push Semantic Highlight feature to Agentic Coding? ](https://www.notion.so/Towards-Real-World-Software-Agents-How-we-push-Semantic-Highlight-feature-to-Agentic-Coding-2f5b099561948096b911c9e1043b8e11) - ๐Ÿ“„ [่ฟˆๅ‘็œŸๅฎžไธ–็•Œ็š„่ฝฏไปถๆ™บ่ƒฝไฝ“๏ผšๅฆ‚ไฝ•ๅฐ†่ฏญไน‰้ซ˜ไบฎๅŠŸ่ƒฝ่žๅ…ฅๆ™บ่ƒฝไฝ“็ผ–็จ‹๏ผŸ](https://www.notion.so/2f5b0995619480ff8bc5edce30de6b92) - 1/26/2025: Introduce **SWE-Pruner** - ๐Ÿ“– paper: https://arxiv.org/abs/2601.16746 - โš™๏ธ code: https://github.com/Ayanami1314/swe-pruner - ๐Ÿ pip: https://pypi.org/project/swe-pruner/ - ๐Ÿค— huggingface: https://huggingface.co/ayanami-kitasan/code-pruner ## ๐Ÿ“‘ Introduction to SWE-Pruner

Tokens Cost Reduction

Are you struggling with **excessive token costs** and latency when using LLM agents for software development? Traditional context compression often relies on fixed metrics like perplexity (PPL) and ignores task-specific code understanding. But **generic compression โ‰  relevant preservation** โ€” we need **task-aware context pruning** that retains critical implementation details. Inspired by how human programmers "selectively skim" source code, **SWE-Pruner** enables agents to formulate explicit goals and uses a lightweight neural skimmer to **dynamically select relevant code lines**. It operates in two key steps: - Formulate task-specific goals to guide the pruning process - Dynamically select relevant code lines using a lightweight neural skimmer ## ๐ŸŽฏ Core Features **๐Ÿง  Task-Aware Pruning** Understands the *intent* (e.g., "focus on error handling") and uses it to guide context pruning process, beyond generic metrics. **๐Ÿค– Coding Agent Native** Built for multi-turn workflows and integrates seamlessly into agent decision loops, providing just-in-time context for complex software engineering tasks. **๐ŸŽจ Semantic Highlight** A lightweight [0.6B model](https://huggingface.co/ayanami-kitasan/code-pruner) identifies and preserves semantically critical lines of code, keeping logical structures intact. **โšก Extreme Compression** Delivers significant token savings without sacrificing performance: **23-54%** token reduction on [SWE-Bench Verified](https://openai.com/index/introducing-swe-bench-verified/) and up to **14.84x** compression on [LongCodeQA](https://github.com/Zteefano/long-code-bench), cutting API costs and latency. **๐Ÿ”ง Flexibly Use** Adaptable framework for various LLMs and scenarios, from debugging to feature development. ## ๐ŸŒฒ Project Structure ```text . โ”œโ”€โ”€ data/ # Experiment trace archives and hyperparameter configurations โ”œโ”€โ”€ downstream_eval/ # Downstream evaluation benchmarks โ”‚ โ”œโ”€โ”€ multi_turn/ # Includes: SWE-bench, SWEQA (coming soon) โ”‚ โ””โ”€โ”€ single_turn/ # Includes: LongCodeQA, LCC (LongCodeCompletion) โ”œโ”€โ”€ swe-pruner/ # Inference code and model utilities โ”‚ โ””โ”€โ”€ model/ # Model files for SWE-Pruner โ”œโ”€โ”€ examples # Examples for integrating with other agents like claude code and openhands ``` ## ๐Ÿงฐ Prerequisites This project uses [uv](https://docs.astral.sh/uv/) for fast and efficient dependency management. ## ๐ŸŽฎ Quick Start Go to [Inference Tutorial](./swe-pruner/README.md) and have a try! > Tips: For easier serving and reproducing, we upload our models in `./swe-pruner/model` directory(tracked by git lfs). It make the serving more simple but greatly increase the repo size if you use `git clone` directly without lfs config (and might failed to download model for traffic limit of github lfs service). However, you can use the methods in the tutorial to download it from HuggingFace. ## โš™๏ธ Installation Since different modules have different dependencies, please refer to the specific `README` file inside each subfolder for detailed installation instructions. ## ๐Ÿ“– User Guides - For Users, look [Inference Tutorial](./swe-pruner/README.md) to start a swe-pruner locally and then reading [real world examples](examples/README.md) for agents integration. - We now support [OpenHands](https://github.com/OpenHands/OpenHands) and [Claude Agent SDK](https://github.com/anthropics/claude-agent-sdk-python)! - For Developers, look `./train`(coming soon) for training a pruner by yourself! - For Researchers, `./downstream_eval` has some scripts for reproducing our results. We recommend to use [slurm](https://github.com/SchedMD/slurm) with at least 4 GPU to reuse our scripts. ## ๐Ÿงช Utils Scripts We provide some utils scripts for continue improving the swe-pruner in `./utils`, just look `utils/README.md`! ## ๐Ÿ”ฎ Coming Soon - [ ] ๐Ÿ’ป Update Training Code of SWE-Pruner - [ ] ๐Ÿ“ Upload full parameters and trajectory files & logs - [ ] ๐Ÿ“ Upload Training Dataset of SWE-Pruner - [ ] ๐Ÿ“ Upload SWE-QA evaluation code - [x] ๐Ÿค— Update HuggingFace model card - [x] ๐Ÿค— Update HuggingFace blog to introducing our technical approach in detail. - [x] ๐ŸŽฎ Update agents integrate demo ## ๐Ÿ“œ Citation ``` @misc{wang2026sweprunerselfadaptivecontextpruning, title={SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents}, author={Yuhang Wang and Yuling Shi and Mo Yang and Rongrui Zhang and Shilin He and Heng Lian and Yuting Chen and Siyu Ye and Kai Cai and Xiaodong Gu}, year={2026}, eprint={2601.16746}, archivePrefix={arXiv}, primaryClass={cs.SE}, url={https://arxiv.org/abs/2601.16746}, } ``` ## ๐Ÿ† Acknowledgements - Bytedance Douyin Team for advises. - Alibaba Qwen Team for open-source models. ## โญ Star History [![Star History Chart](https://api.star-history.com/svg?repos=Ayanami1314/swe-pruner&type=Date)](https://star-history.com/#Ayanami1314/swe-pruner&Date)