Researchers from Hugging Face have proposed SWE-Pruner Pro, a novel approach to context pruning for coding agents. Unlike existing methods such as SWE-Pruner, which rely on a separate code classifier to prune long contexts, SWE-Pruner Pro uses the agent’s own internal representations to decide which lines of tool output to keep or discard.
The key insight is that the coding agent already encodes relevance information internally when reading tool outputs. A small head is attached to the agent to convert these internal representations into keep-or-prune labels for each line, using a length-aware embedding that accounts for the line count of each tool output.
Evaluated across two open-weight backbone models and four multi-turn benchmarks, SWE-Pruner Pro achieves up to 39% savings in prompt and completion tokens while preserving task quality, with only bounded inference overhead. Notably, on the MiMo-V2-Flash benchmark, the method improves the SWE-Bench Verified resolve rate by +3.8% and the long-context Oolong accuracy by +2.2 points.
The code is available on GitHub at https://github.com/Ayanami1314/swe-pruner-pro.