NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Improving Code Localization with Repository Memory

Boshi Wang, Weijian Xu, Yunsheng Li, Xuemei Gao, Yujia Xie, Huan Sun, Dongdong Chen

The Challenge of "Amnesic" AI Coders

When fixing a bug in a large software repository, the crucial first step is code localization—finding the exact files and lines of code that need to be modified. Recently, LLM-powered agents have become quite adept at this by using tools to navigate code graphs and search for keywords.

However, existing frameworks (like LocAgent) have a glaring blind spot: they lack long-term memory. They treat every issue as a fresh puzzle, starting from scratch. Human developers don't work this way. A senior engineer relies heavily on their memory of past bugs, recent architectural changes, and a mental map of which modules are currently under active development. This paper asks: How can we give an AI agent this kind of historical, repository-specific intuition without requiring massive retraining?

Introducing RepoMem: Mining the Commit History

To bridge this gap, the authors propose RepoMem, a lightweight approach that mines a repository's natural evolutionary record—its commit history—to build two complementary memory stores. By equipping agents with this episodic and semantic memory, the authors significantly boost code localization performance and end-to-end bug resolution rates on real-world benchmarks like SWE-bench.

Overview of the RepoMem framework

RepoMem introduces two distinct types of memory:

  1. Episodic Memory (Past Commits): A searchable database of past commits, code patches, and linked issues. Agents are given tools like SearchCommit (to find historical commits related to the current bug using BM25 keyword search) and ExamineCommit (to view the exact diff and issue description of a past fix).
  2. Semantic Memory (Active Code Functionality): The system identifies "hotspots"—the top-k most frequently edited files in the recent commit history. An LLM then generates high-level summaries of what these files do. Agents can use SearchSummary and ViewSummary to quickly understand the purpose of these highly active modules without reading the raw source code.

These memory tools are seamlessly integrated into the action space of LocAgent, a state-of-the-art ReAct-based agent, allowing it to query past experiences before diving into structural code analysis.

Key Insights: How Memory Changes Agent Behavior

Adding memory fundamentally changes how the agent behaves. Instead of exhaustively exploring the code graph step-by-step, the memory-equipped agent forms hypotheses based on past commits and directly inspects relevant areas. It acts less like a junior developer blindly tracing functions and more like an experienced maintainer.

Tool usage comparison showing a shift toward memory-based tools
  • Sparse Retrieval Beats Dense Retrieval for Code: When searching the memory, exact keyword matching (BM25 with an LLM-based tokenizer) significantly outperformed a strong dense retrieval model (GritLM-7B). Code vocabularies are highly rigid (e.g., MigrationWriter vs. OperationWriter are semantically similar to an embedding model but functionally entirely different), making exact matches crucial.
  • Cost is a Strategic Investment: Using memory tools increases LLM API costs, but the extra cost is primarily concentrated on hard problems where the baseline agent failed. On easier problems, the memory often provides a direct hint, actually making the agent cheaper and faster.
  • History Richness Matters: The system thrives on data. Repositories with deep, rich commit histories (like Django or matplotlib) saw massive performance gains. Conversely, in repositories with sparse histories, the memory tools occasionally distracted the agent, slightly degrading performance.

Performance Gains on SWE-bench

The approach was evaluated on two standard benchmarks for repository-level software engineering: SWE-bench-verified (500 high-quality, human-verified examples) and SWE-bench-live (a dynamically updating benchmark, using a subset of 130 examples).

  • Improved Localization: On SWE-bench-verified, RepoMem achieved an Acc@5 of 76.5%, a solid 4.9% absolute improvement over the strong LocAgent baseline (71.6%). On SWE-bench-live, it improved Acc@5 from 63.1% to 66.2%.
  • Better End-to-End Bug Fixing: Better localization translates directly to better patch generation. Using a standard patch generation pipeline, RepoMem improved the final issue resolution rate from 37.0% to 40.4%.
  • Ablation Success: Both episodic memory (Acc@5: 74.3%) and semantic memory (Acc@5: 72.8%) individually improve upon the baseline, but combining them yields the best results, proving they offer complementary signals.

Limitations and Future Work

The authors acknowledge a few limitations. First, the episodic memory relies on explicit text links between commits and issues (e.g., "Fixes #123" in a commit message), which can be noisy or missing entirely in some repos. Second, if a bug is entirely novel or the repository history is sparse, the memory retrieval can pull in irrelevant information, distracting the LLM and hurting performance.

For future work, the authors suggest training agents to be more strategic—learning when to query memory versus when to rely on first-principles code exploration. They also propose using more advanced heuristics from the Just-in-Time Software Defect Prediction (JiT-SDP) literature (like time-decay filtering) to build even cleaner, more relevant semantic memories.

Summary updated

BibTeX
@inproceedings{wang2026improving,
  author = {Boshi Wang and Weijian Xu and Yunsheng Li and Xuemei Gao and Yujia Xie and Huan Sun and Dongdong Chen},
  title = {{Improving Code Localization with Repository Memory}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=8yjWLJy2eX},
}
Figure