‹ 返回 2026-06-16

FastContext:训练出高效的海量代码代理存储查询工具

FastContext: Training Efficient Repository Explorer for Coding Agents

▲ 76 💬 2 2026-06-16

Shaoqiu Zhang, Maoquan Wang, Yuling Shi, Yuhang Wang, Xiaodong Gu, Yongqiang Yao, Rao Fu, Shengyu Fu

摘要

大型语言模型(LLM)编码代理在软件工程任务上取得了显著的成绩,不过,仓库的探索过程仍然是一个主要瓶颈:找到相关的代码需要消耗大量的资源,同时还会让代理的上下文信息变得混乱,因为包含了大量无关的信息。在大多数代理中,相同的模型负责同时处理仓库的搜索和任务的解决过程,导致探索性操作被遗留在求解器的历史记录中。我们提出了FastContext这一专门的探索子代理,它可以将仓库的搜索与任务解决过程分离开来。当需要时,FastContext可以并发地调用各种工具,并返回简洁的文件路径和行号作为上下文信息。FastContext由专门设计的探索模型驱动,这些模型的参数范围从40亿到300亿不等。我们能够从强大的参考模型出发来初始化这些模型,并通过基于任务的奖励来优化它们,从而实现更高效的首次搜索、多轮证据收集以及精确的引用生成。在SWE-bench Multilingual、SWE-bench Pro以及SWE-QA测试中,将FastContext集成到Mini-SWE-Agent中,能够将其端到端的处理效率提高至5.5%,同时减少了编码代理的资源消耗,且开销很小。这些结果表明,将仓库的探索过程与任务解决过程分离出来,并由专门的模型来高效处理是可行的。代码和数据可在此处获取:https://github.com/microsoft/fastcontext

English Abstract

Large Language Model (LLM) coding agents have achieved strong results on software engineering tasks, yet repository exploration remains a major bottleneck: locating relevant code consumes substantial token budget and pollutes the agent's context with irrelevant snippets. In most agents, the same model explores the repository and solves the task, leaving exploratory reads and searches in the solver's history. We present FastContext, a dedicated exploration subagent that separates repository exploration from solving. Invoked on demand, FastContext issues parallel tool calls and returns concise file paths and line ranges as focused context. FastContext is powered by specialized exploration models spanning 4B--30B parameters. We bootstrap them from strong reference-model trajectories and refine them with task-grounded rewards for broad first-turn search, multi-turn evidence gathering, and precise citation generation. Across SWE-bench Multilingual, SWE-bench Pro, and SWE-QA, integrating FastContext into Mini-SWE-Agent improves end-to-end resolution rates up to 5.5\% while reducing coding-agent token consumption up to 60\%, with marginal overhead. These results show that repository exploration can be separated from solving and handled effectively by specialized models. Code and data: https://github.com/microsoft/fastcontext