RefAgent: Discovering High-Usability References for Context-Aware Code Generation
Large Language Models (LLMs) have shown strong potential for repository-level code generation. However, existing coding agents predominantly rely on similarity-based retrieval to gather reference code, which often leads to suboptimal performance in complex software systems with rich cross-file dependencies. In particular, high-similarity references frequently suffer from incomplete or incompatible dependencies, while structurally compatible and reusable implementations may be overlooked due to low textual similarity.
To address this limitation, we propose RefAgent, an agent-driven framework that reframes code retrieval as a process of structure-aware context alignment. Instead of directly reusing retrieved code, RefAgent treats high-similarity but unusable references as structural signals. It first assesses their dependency completeness under the target context, and then abstracts their functional intent and dependency structures. Guided by these derived structures, the agent actively explores alternative implementations that satisfy the same functional requirements while remaining compatible with the target context. Finally, RefAgent selects candidates whose dependency structures are fully aligned and executable, enabling reliable and consistent code generation.
By transforming retrieval from a similarity-driven process into a structure-guided decision process, RefAgent effectively bridges the gap between similarity and usability. Experimental results on the DevEval and CoderEval benchmark demonstrate that RefAgent achieves state-of-the-art performance, with a pass@1 score of 68.54% and 78.1%, significantly outperforming existing approaches. Further analysis shows that our method substantially improves the handling of cross-file dependencies, enabling more accurate and robust repository-level code generation.
Sat 18 JulDisplayed time zone: Brisbane change
11:40 - 12:35 | Session 2: Code Search and GenerationResearch Track / Tool Demonstration at Promenade Chair(s): Jia Li Wuhan University | ||
11:40 15mTalk | RefAgent: Discovering High-Usability References for Context-Aware Code Generation Research Track Haizhuo Yuan Peking University, Siqiao Yan Peking University, Yanzhen Zou Peking University, Tongwei Deng Peking University, Junfeng Wang Peking University, Yujie Shi Peking University, Xutian Li Peking University, Bing Xie Peking University | ||
11:55 15mTalk | IVGen: Multi-Agent Code Generation via Interleaved Verification for Closed-Loop Robotic Manipulation Research Track Chenghao Fan Zhejiang Sci-Tech University, Yangyang Zhao Zhejiang Sci-Tech University, Ke Ding Hinyeung Technology Co., Ltd, Liming Nie | ||
12:10 15mTalk | SynH-Rank: Quality-Aware Code Search via Diverse Data Synthesis and Hierarchical Ranking Training Research Track Keyu Liang Zhejiang University, Haoye Wang Hangzhou City University, Yanfu Yan Zhejiang University, Zhiyuan Wan Zhejiang University, Zhongxin Liu Zhejiang University | ||
12:25 10mTalk | Seeing the Forest for the Trees: Repository-Level Version Change Summarization Tool Demonstration Junlin Zhou the School of Software Engineering, Xi’an Jiaotong University, Xi’an, China, Wuxia Jin Xi'an Jiaotong University, Zijun Wang the School of Software Engineering, Xi’an Jiaotong University, Xi’an, China, Jiale Li the School of Software Engineering, Xi’an Jiaotong University, Xi’an, China, Ting Liu Xi'an Jiaotong University | ||