CodeMEM: AST-Guided Adaptive Memory for Repository-Level Iterative Code Generation

Peiding Wang, Li Zhang, Fang Liu, Chongyang Tao, Yinghao Zhu


Abstract
Large language models (LLMs) substantially enhance developer productivity in repository-level code generation through interactive collaboration. However, as interactions progress, repository context must be continuously preserved and updated to integrate newly validated information. Meanwhile, the expanding session history increases cognitive burden, often leading to forgetting and the reintroduction of previously resolved errors. Existing memory management approaches show promise but remain limited by natural language-centric representations. To overcome these limitations, we propose CodeMEM, an AST-guided dynamic memory management system tailored for repository-level iterative code generation. Specifically, CodeMEM introduces the Code Context Memory component that dynamically maintains and updates repository context through AST-guided LLM operations, along with the Code Session Memory that constructs a code-centric representation of interaction history and explicitly detects and mitigates forgetting through AST-based analysis. Experimental results on the instruction-following benchmark CodeIF-Bench and the code generation benchmark CoderEval demonstrate that CodeMEM achieves state-of-the-art performance, improving instruction following by 12.2% for the current turn and 11.5% for the session level, and reducing interaction rounds by 2–3, while maintaining competitive inference latency and token efficiency.
Anthology ID:
2026.findings-acl.834
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:
16903–16917
Language:
URL:
https://preview.aclanthology.org/ingest-acl/2026.findings-acl.834/
DOI:
Bibkey:
Cite (ACL):
Peiding Wang, Li Zhang, Fang Liu, Chongyang Tao, and Yinghao Zhu. 2026. CodeMEM: AST-Guided Adaptive Memory for Repository-Level Iterative Code Generation. In Findings of the Association for Computational Linguistics: ACL 2026, pages 16903–16917, San Diego, California, United States. Association for Computational Linguistics.
Cite (Informal):
CodeMEM: AST-Guided Adaptive Memory for Repository-Level Iterative Code Generation (Wang et al., Findings 2026)
Copy Citation:
PDF:
https://preview.aclanthology.org/ingest-acl/2026.findings-acl.834.pdf
Checklist:
 2026.findings-acl.834.checklist.pdf