Let the Comments Speak: A Multi-Agent Framework based on Large Language Model for Comment-Guided Code Refactoring

Zixuan Wang, Wutong Yu, Deyu Zhou


Abstract
Code refactoring is essential for software maintainability, yet current Large Language Model (LLM) based frameworks primarily focus on syntax and neglect the vital semantic signals in code comments. As pointed out in Fowler’s refactoring theory, explanatory comments function as semantic anchors that provide necessary guidance for method extraction. Moreover, research reports show that more than 84 percent of codebases lack appropriate code comments, which hinders the leverage of such guidance. To bridge this gap, we propose MACOR, a Multi-Agent framework for COmment-guided code Refactoring. In specific, MACOR populates original code with precise comments to provide necessary semantic guidance for the subsequent refactoring process. These generated signals are employed to retrieve expert examples. An iterative feedback is incorporated loop for validation. Experiments are conducted on three benchmarks using three base LLMs. Experimental results show that MACOR significantly optimizes code quality and achieves higher developer acceptance compared to the representative baselines.
Anthology ID:
2026.findings-acl.1620
Volume:
Findings of the Association for Computational Linguistics: ACL 2026
Month:
July
Year:
2026
Address:
San Diego, California, United States
Editors:
Maria Liakata, Viviane P. Moreira, Jiajun Zhang, David Jurgens
Venue:
Findings
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
32377–32393
Language:
URL:
https://preview.aclanthology.org/ingest-acl/2026.findings-acl.1620/
DOI:
Bibkey:
Cite (ACL):
Zixuan Wang, Wutong Yu, and Deyu Zhou. 2026. Let the Comments Speak: A Multi-Agent Framework based on Large Language Model for Comment-Guided Code Refactoring. In Findings of the Association for Computational Linguistics: ACL 2026, pages 32377–32393, San Diego, California, United States. Association for Computational Linguistics.
Cite (Informal):
Let the Comments Speak: A Multi-Agent Framework based on Large Language Model for Comment-Guided Code Refactoring (Wang et al., Findings 2026)
Copy Citation:
PDF:
https://preview.aclanthology.org/ingest-acl/2026.findings-acl.1620.pdf
Checklist:
 2026.findings-acl.1620.checklist.pdf