AI
New pruning technique helps coding AI agents manage long contexts without sacrificing performance
Researchers propose SWE-Pruner Pro, which leverages an AI coder's own internal signals to strip away irrelevant code snippets and reduce token usage by up to 39%.
Managing lengthy code contexts remains a persistent challenge for coding agents powered by large language models. A new approach, detailed in a research paper submitted to arXiv, suggests that the solution may already exist within the agent itself.
The Problem with Long Contexts#
Coding agents often need to process extensive tool outputs and documentation while solving software engineering tasks. Each line of context consumes tokens, inflating computational costs and slowing inference. Prior methods like SWE-Pruner relied on separate code classifiers to identify and strip out unnecessary information, but this added complexity and overhead.
A Self-Aware Alternative#
Researchers behind SWE-Pruner Pro discovered that coding agents already encode signals about the relevance of code snippets in their internal representations. Rather than bolting on an external pruning system, they embedded this capability directly into the agent itself.
The technique works by attaching a small classification head that reads the agent's internal states and assigns a keep-or-prune label to each line of code. A length-aware embedding, indexed to each tool output's line count, helps the model make context-aware decisions about what matters.
Results and Trade-offs#
Testing on two open-weight model backbones across four multi-turn benchmarks revealed substantial efficiency gains:
- Up to 39% reduction in combined prompt and completion tokens
- Task quality preserved, with no loss of accuracy on standard benchmarks
- Minimal inference overhead, making the approach practical for deployment
On the MiMo-V2-Flash model specifically, SWE-Pruner Pro boosted performance on SWE-Bench Verified by +3.8% and improved long-context accuracy on Oolong by +2.2 points—suggesting that pruning irrelevant noise can actually sharpen the agent's reasoning.
Why It Matters#
This work illustrates a broader principle: the solution often lies within the model, waiting to be surfaced. By trusting an agent's native understanding of relevance, pruning becomes more efficient and less error-prone than adding external machinery.

