AI写代码时自己就知道哪些内容该删掉
以前帮AI删掉无关代码上下文需要另加一个分类器,但研究者发现:AI在读工具输出时,自己内部就已经在判断哪些行有用。他们给AI加了一个小头,直接读AI自己的内部信号来逐行决定删不删,还根据每段输出的行数做了长度感知。结果在多个测试上省了最多39%的token,任务质量没掉,甚至在一个基准上还涨了3.8%的解决率。它不是你明天能用上的,但说明AI内部其实比我们以为的更知道自己要什么。
📄 原文摘要(英文)
Pruning long context for coding agents has been a vital technology for efficient context management. While existing context pruning methods such as SWE-Pruner realize this by attaching a separate code classifier, we find the agent itself encodes internal representations indicating the relevance of code context when reading tool output. Based on this finding, we propose SWE-Pruner Pro, which prunes tool outputs directly inside the agent. Concretely, a small head turns the agent's own internal representations into a keep-or-prune label for each line, with a length-aware embedding keyed to each tool output's line count. Across two open-weight backbones and four multi-turn benchmarks, SWE-Pruner Pro saves up to 39% of prompt and completion tokens while preserving task quality, with bounded inference overhead. Notably, on MiMo-V2-Flash SWE-Pruner Pro additionally raises the SWE-Bench Verified resolve rate by +3.8% and the long-context Oolong accuracy by +2.2 points.