ACL2026

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

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

被引用 1 次

摘要

Large language models (LLMs) substantially enhance developer productivity in repositorylevel 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 languagecentric representations. To overcome these limitations, we propose CODEMEM, an ASTguided 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 1 . * Corresponding author. 1 The code and data are available at https://github.com/ zhu-zhu-ding/CodeMem Instruction-1: Please write a python function called 'set_status'. This function sets the job status in Hadoop streaming by printing ...