arXiv:2606.04397cs.SEcs.IR2026-06被引 1

让AI写文档时自动找跨文件依赖,提升准确性和效率

Context-as-AI-Service: Surfacing Cross-File Dependency Chains for LLM-Generated Developer Documentation

论文配图:Context-as-AI-Service: Surfacing Cross-File Dependency Chains for LLM-Generated Developer Documentation
图 1 · 摘自论文原文
  • 用检索层查询代码库,结合关键词与语义搜索定位依赖
  • 比基线多发现4个遗漏问题,包括错误注释和缺失前提
  • 适合做代码文档生成的开发者或AI助手团队使用

LLM代理在编写和维护开发文档时,其准确性和实用性常依赖于不明显的跨文件依赖链。即使上下文包含更多文件,代理仍需决定追踪哪些依赖。我们提出Context-as-AI-Service(CAIS),一个供LLM代理调用的检索层,用于在审查或生成文档时从代码库中寻找证据。CAIS索引源代码、API参考和上游文档,支持通过工具调用进行关键词与语义混合检索。我们在生产级SDK上用Claude Sonnet 4.6进行了两项案例研究:改进核心源文件的API注释,验证由LLM生成的教程。基线已具备常规仓库工具,如文件读取、关键词搜索和符号导航。CAIS作为额外检索层,使对比聚焦于检索能力本身。在API注释审查中,CAIS增强的代理与基线相同修复了5处缺失文档,并额外发现4项基线未察觉的问题:2个跨文件事实错误和2个未充分说明的API注释。在教程验证中,它发现了1个可执行缺陷、1个API使用改进建议和2个基线未捕捉到的缺失前提。这些发现需追溯跨越工具文件、框架内部逻辑、示例代码、测试和组件创建逻辑的非明显依赖链。五次运行结果显示,添加CAIS使两项任务的墙钟时间减少22%至34%,并降低了输入令牌消耗。

原文摘要 · Abstract (English)

LLM agents increasingly write and maintain developer documentation, but usefulness and accuracy often rely on dependency chains that are not obvious to follow. Even with more files in context, the agent must still decide which cross-file dependencies to trace. We present Context-as-AI-Service (CAIS), a retrieval layer that LLM agents query to find evidence across the codebase as they review or generate documentation. CAIS indexes source code, API references, and upstream documentation, then enables agents to query the index through tool calls that combine keyword and semantic search. We evaluate CAIS in two case studies using Claude Sonnet 4.6 on a production SDK: improving API reference comments in a core source file and validating an LLM-generated tutorial. In both studies, the baseline already had ordinary repository tools such as file reads, keyword search, and symbol navigation. CAIS adds a retrieval layer on top, so the comparison isolates added retrieval rather than basic repository access. In the API-reference review, the CAIS-augmented agent produced the same 5 missing-documentation fixes as the baseline and surfaced 4 findings the baseline missed: 2 cross-file factual errors and 2 underspecified API comments. In the tutorial validation, it surfaced 1 executable bug, 1 API-usage improvement, and 2 missing prerequisites that the baseline pipeline did not catch. These findings required tracing non-obvious dependency chains across utility files, framework internals, usage examples, tests, and component-creation logic. Over five runs per condition, adding CAIS reduced wall-clock time by 22% to 34% across the two tasks and lowered input-token usage.

文档生成AI检索代码依赖LLM应用

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