一句话:提出双上下文框架 RepoFuse,将跨文件上下文分为语义与相似两类,在毫秒级延迟下提升仓库级代码补全准确率。
仓库级代码补全需要理解复杂的跨文件依赖,但已有方法难以兼顾上下文丰富度与实时 IDE 集成所需的 200ms 以内延迟。本文提出 RepoFuse,将跨文件上下文系统性地划分为语义上下文(轻量静态分析得到的结构依赖)与相似上下文(相似度检索得到的功能类似模式),并设计相关性引导的选择算法优化效率与准确率的权衡。系统在蚂蚁集团部署,服务 1 万余名开发者与 5000 万行以上代码,平均延迟 156ms,补全接受率提升 18%。在 CrossCodeEval 上,Python 与 Java 的 exact match 分别提升 4.26 与 3.01,且仅需基线 25% 的 token。为期一周、含 8 万次补全请求的 A/B 实验显示,73% 的开发者认为该双上下文方法减少了跨文件切换。
Repository-level code completion requires understanding complex cross-file dependencies, yet existing approaches struggle to balance context richness with the sub-200ms latency requirements of real-time IDE integration. We present RepoFuse, a dual-context framework deployed at Ant Group1 serving 10,000+ developers across 50+ million lines of code. In a production deployment at Ant Group, RepoFuse maintained an average latency of 156ms and improved completion acceptance rate by 18%. This was accomplished through systematic categorization of cross-file context into semantic context (structural dependencies via lightweight static analysis) and similar context (functionally analogous patterns via similarity search), combined with a relevance-guided selection algorithm that optimizes the efficiency-accuracy trade-off. Benchmark evaluation on CrossCodeEval demonstrates 4.26 and 3.01 improvements in exact match scores for Python and Java respectively, while using only 25% of baseline token requirements. More significantly, our one-week A/B test with 80,000 completion requests revealed that developers particularly valued the dual-context approach when working across microservice boundaries, with 73% reporting reduced context switching between files. The system successfully operates under production constraints with distributed caching, real-time graph updates, and p95 latency under 190ms, demonstrating that principled context categorization enables practical repository-level completion at industrial scale. We have open-sourced RepoFuse at GitHub2.
@inproceedings{LiangXZZJWFD26,
title = {RepoFuse: A Dual-Context Approach to Repository-Level Code Completion at Industrial Scale},
author = {Ming Liang and Xiaoheng Xie and Gehao Zhang and Xunjin Zheng and Wei Jiang and Chengpeng Wang and Gang Fan and Peng Di},
booktitle = {FSE},
year = {2026},
doi = {10.1145/3803437.3805230}
}