DocAgent: A Multi-Agent System for Automated Code Documentation Generation
Abstract
High-quality code documentation is crucial for software development especially in the era of AI. However, generating it automatically using Large Language Models (LLMs) remains challenging, as existing approaches often produce incomplete, unhelpful, or factually inaccurate documentation. This paper introduces DocAgent, a novel multi-agent system designed to automate the generation of comprehensive and accurate code documentation. DocAgent leverages a collaborative framework where multiple specialized LLM agents work together, each focusing on different aspects of documentation, such as code analysis, context understanding, and natural language generation. The system employs an incremental context-building mechanism, allowing agents to refine their understanding of the codebase and generate more precise and relevant documentation over time. Experimental results demonstrate that DocAgent significantly outperforms existing single-agent and traditional methods in terms of documentation quality, completeness, and factual accuracy. This work highlights the potential of multi-agent systems to address complex software engineering tasks that require deep contextual understanding and collaborative intelligence.