用多智能体系统分层总结大型代码库,提升摘要质量与关键词覆盖率。
Agent4cs: A Multi-agent System for Code Summarization in Large Hierarchical Codebases

- 构建多智能体框架,自底向上逐层生成代码摘要。
- 相比基线方法,语义一致性平均提升8%,关键词覆盖率达38%提升。
- 适合需要理解复杂代码结构的开发者和团队使用。
理解大型复杂代码库,尤其是结构模糊且文档不全的情况,仍是重大挑战。现有代码摘要方法多依赖单一语言模型(如Claude Code),将源码视为扁平文本,未能充分利用仓库内的丰富依赖关系与层级信息。为此,我们提出Agent4cs——一种多智能体框架,采用自底向上的方式总结大型代码库:摘要代理负责生成稳健摘要;关键词提取代理主动识别子目录中的关键信息;质量保障代理则迭代优化输出,确保可读性、连贯性与完整性。在7个前沿模型上评估显示,Agent4cs相比两种结构化提示基线,在所有文件夹层级上平均提升8%的语义一致性。在真实数据集上的广泛评估表明,其标准化关键词覆盖率最高提升达38%。
原文摘要 · Abstract (English)
Understanding large, complex codebases, especially those with obfuscated structures and incomplete documentation, remains a significant challenge. Existing code summarization solutions often rely on a single language model or coding assistant like Claude Code, and treat source code as flat text, underutilizing the rich interdependencies and hierarchical information within a repository. To address these shortcomings, we propose Agent4cs - a multi-agent framework that summarizes large codebases in a bottom-up fashion, where a summarization agent focuses on producing robust summaries; a keyword-extraction agent proactively identifies critical information from subfolders; and a quality-assurance agent iteratively refines the outputs for readability, coherence, and completeness. Evaluated on 7 frontier models, Agent4cs improves semantic consistency across all folder levels by average 8% compared to two structured prompting baselines with code segments. Furthermore, extensive evaluation on real-world datasets demonstrates up to 38% gains in normalized keyword coverage rate over the same baselines.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。