arXiv:2608.01507cs.SEcs.AI2026-08

对比两种代码搜索方式,发现传统检索更准更便宜。

Deep Agentic Search for Repository-Level Code Question Answering: An Empirical Study

论文配图:Deep Agentic Search for Repository-Level Code Question Answering: An Empirical Study
图 1 · 摘自论文原文
  • 用向量索引提前检索代码,比分步子代理搜索更高效
  • 语义搜索正确率65.2%,深搜仅46.2%,成本还不到一半
  • 深搜失败主因在主代理与子代理交接,常无声出错

代码智能体在仓库级代码问答中,大多耗费精力于定位正确代码。当前主流有两种方法:语义搜索通过预先构建的向量索引检索代码块;深搜(又称子代理grep搜索)由规划代理委派独立子代理在隔离上下文窗口中探索,仅返回压缩结果。后者被视作优良上下文工程实践,旨在防止上下文污染(即上下文腐化),避免无关内容累积导致准确率下降。近期如Claude Code、Codex、Antigravity等代码智能体已广泛采用,但缺乏实证支持其优越性。本研究在SWE-QA基准上对比二者表现:语义搜索正确率达65.2%,深搜仅为46.2%,且前者生成每条正确答案的成本不足后者的二分之一。进一步分析失败案例,发现深搜未消除错误,反而引入新类型失败——41.8%的失败发生在规划代理与子代理交接环节,且多为沉默型错误,表现为流畅自信但错误的答案。尽管深搜解决真实问题并已成为主流设计,但结果表明其保护机制非无代价,对于可索引的只读仓库场景,检索仍是更强且更经济的选择。

原文摘要 · Abstract (English)

Code agents spend much of their effort simply locating the right code inside a repository. Two approaches dominate current practice. In Semantic Search, the agent retrieves code blocks from a vector index built from the repository in advance. In Deep Agentic Search (also known as grep-search by subagent), a planning agent delegates the exploration to a separate subagent that works in an isolated context window and returns only a condensed result. The second design, which is considered good context engineering practice, exists to protect the main agent from context pollution (also known as context rot), the loss of accuracy that occurs as unrelated material accumulates in the context window. Recent code agents (such as Claude Code, Codex, Antigravity, etc) have adopted it quickly, but there is little evidence on whether it produces better answers. We compare the two approaches on SWE-QA, a benchmark for repository-level code question answering. Semantic search answered 65.2% of questions correctly against 46.2% for deep agentic search, and it produced each correct answer at less than half the cost. To explain the gap, we then coded every failed run into a taxonomy of failure modes. The taxonomy shows that deep agentic search did not remove failures but introduced a new class of them: the single largest share of its failures, 41.8%, occurred at the hand-off between the planner and its sub-agent, and these were usually silent, ending in a fluent and confident answer that was wrong. Deep agentic search addresses a real problem and is now the preferred design in many code agents. However, our results show that the protection it offers may not be free, and that for read-only questions over a repository that can be indexed, retrieval was the stronger and cheaper option.

代码问答智能体检索

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。