跳过压缩器:编码智能体选择完整文件时能修复更多问题

·

研究论文 · 2026/10/19

编码智能体处理的代码库可能远超其上下文窗口容量。提示压缩器和检索器可缓解此问题,但修复问题需要同时获得必须修改的文件及其原始代码,因为模型必须逐行复现编辑内容。检索器按代码与问题的相似度排序而非按是否必须修改,压缩器则删除文本以适配预算。我们在300个近期SWE-rebench问题上,将每个上下文适配到相同的每问题预算,并用基准测试评估每个补丁。使用GPT-5.6和Claude Opus 5时,CQ2-CARE分别解决了43.7%和46.7%的问题,比三种压缩器中的最佳者高6.3个百分点,比三种检索器中的最佳者高9.3和12.7个百分点。CQ2-CARE甚至比两种针对问题解决训练的方法解决更多问题:比SweRank高0.7和1.7个百分点,比SWE-Pruner高2.0和7.3个百分点。分析表明基线方法的缺陷:检索器常遗漏待编辑文件,压缩器保留文件但改变其文本,导致更少补丁适用。精确文件选择无需压缩模型,并原样展示每一行代码,使模型能引用其编辑的代码。

该研究挑战了编码智能体中压缩和检索的默认做法,证明在相同预算下选择完整文件更有效,为上下文管理提供了简单而强大的新思路,且实验严谨,对比全面。

A coding agent works on repositories that can be far larger than its context window can hold. Prompt compressors and retrievers offer solutions to this problem, but patching an issue needs two things at once: the files that must change, and their code exactly as written, since the model must reproduce the lines it edits. Retrievers rank code by its similarity to the issue rather than by whether it must change, and compressors delete text to fit the budget. We show that at an equal token budget, an agent resolves more issues when the budget goes to choosing which files to show verbatim, as our simple selector CQ2-CARE does, than when it goes to pruning tokens or retrieving chunks. We fit every context to the same per-issue budget on 300 recent SWE-rebench issues and grade each patch with the benchmark's tests. With GPT-5.6 and Claude Opus 5, CQ2-CARE resolves 43.7% and 46.7% of the issues, 6.3 points more than the best of three compressors with either model, and 9.3 and 12.7 points more than the best of three retrievers. CQ2-CARE even resolves more issues than two methods trained for issue resolution, SweRank (by 0.7 and 1.7 points) and SWE-Pruner (by 2.0 and 7.3). Our analysis shows the defects of the baseline methods: retrievers often miss the files to edit, and compressors keep them but alter their text, so fewer patches apply. Exact-file selection needs no compression model and shows every line as the repository has it, so the model can quote the code it edits.

阅读原文

参与讨论