Editor’s introduction
The study evaluates ExpeRepair, a framework that models human memory systems to store and reuse historical software repair experiences. It compares performance on SWE-Bench Lite and SWE-Bench Verified, showing 60.3% and 74.6% pass@1 scores respectively, outperforming other open-source methods. The system uses episodic memory to store concrete repair examples and semantic memory to capture abstract insights, combining both during inference to generate context-aware prompts. Results indicate strong performance even when paired with less capable models, suggesting robustness across different foundation models.
Introduction
Automated Program Repair (APR) aims to automatically identify and correct bugs in source code, offering the potential to significantly reduce developer effort and improve software reliability. Traditional APR techniques have predominantly focused on function-level APR, targeting small, isolated code fragments. However, this narrow scope diverges from real-world software maintenance practices, which typically require reasoning over large codebases, interpreting complex issue descriptions, and addressing inter-file dependencies. Recent advances in Large Language Models (LLMs), particularly in code generation, have shifted attention toward applying LLMs to repository-level APR. Unlike function-level APR, repository-level APR involves navigating large codebases, understanding intricate program logic, and identifying subtle bugs embedded across multiple files, introducing new and underexplored challenges.
To address these challenges, recent LLM-based APR methods fall into two main categories: agentic and procedural. Agentic approaches treat the LLM as an autonomous agent that interacts with tools, navigates repositories, modifies code, and runs tests to resolve bugs. Procedural approaches, in contrast, follow predefined pipelines, where the LLM sequentially performs tasks such as bug localization and patch generation using fixed prompts, without autonomous decision-making. While both paradigms show promise, they exhibit two key limitations.
Neglecting Historical Repair Experience. Current approaches treat each issue in isolation and primarily rely on feedback from the ongoing resolution process, while largely ignoring valuable historical experience accumulated from previously resolved issues within the same repository. In practice, software projects often exhibit recurring bug patterns, such as incorrect API usage, type mismatches, or improper resource management. These patterns may manifest as syntactically similar changes or as diverse edits with similar underlying repair logic. Effectively capturing and leveraging historical repair knowledge could improve both repair efficiency and success rates.
Patch Validation
After a candidate patch successfully passes the reproduction test, it is not immediately accepted as the final patch. This is because we empirically observed that reproduction scripts typically focus narrowly on the specific symptoms described in the issue, leading to false positives where patches pass limited tests but fail in broader contexts. To mitigate this, we revise and augment the patch by instructing the patch agent to address concerns such as edge case handling, regression risks, and adherence to language-specific best practices. Next, we augment the reproduction test suite by generating additional validation tests. The test agent is instructed to create tests targeting boundary conditions and corner cases. This process reduces the risk of narrow, brittle fixes that only address the reported symptom without addressing the underlying defect comprehensively.
To select the final patch, we first execute all candidate patches against the expanded test suite, which includes both reproduction and validation tests. Then, we pass candidate patches and their corresponding test results to the LLM, which selects the final patch based on criteria such as correctness and adherence to best practices.
Memory Storage
After the program repair module processes a new issue, the memory module collects the complete repair trajectory, which consists of all detailed artifacts associated with that specific repair instance, including the issue description, reproduction scripts, candidate patches, and the test execution results before and after each patch is applied. ExpeRepair begins by extracting issue-specific demonstrations for both the test agent and the patch agent, which are stored in episodic memory. Specifically, for each trajectory, it collects two types of demonstrations: (1) (input, successful output) pairs, representing successful repair attempts, and (2) (input, failed output, feedback, successful output) tuples, capturing failed attempts along with their outputs, feedback, and corrected versions. The successful/failed output refers to whether the test script successfully reproduces the issue (as determined by the LLM) or whether the patch passes the reproduction test. All collected demonstrations are ultimately stored in episodic memory.
Then, ExpeRepair performs a summarize-and-update process to maintain the semantic memory, which stores high-level natural language insights. We prompt the LLM to analyze the complete repair trajectory and explain why specific attempts to reproduce the issue or generate a patch succeeded or failed. This generates reflective insights that may include general repair strategies, common failure causes, and effective heuristics. The newly generated insights are compared with those already stored in semantic memory, and ExpeRepair updates the memory by applying up to three operations: (1) ADD, to introduce a novel or valuable insight; (2) REMOVE, to discard contradictory, outdated, or redundant information; and (3) EDIT, to merge, generalize, or refine overlapping insights for improved clarity and utility. To maintain a manageable memory size, we impose a maximum number of insight entries per agent. When this limit is reached, ExpeRepair must first REMOVE an existing insight before applying a new ADD.
Implementation
Test and Patch Generation. For each issue, the test agent iteratively generates a reproduction script for up to 3 rounds. Upon successfully reproducing the issue, the patch agent performs up to 3 iterations of patch generation, producing 4 candidate patches per iteration. Failed patches and execution results are fed back to guide new candidates, while passing patches proceed to validation.
Patch Validation. To reduce false positives, ExpeRepair samples 3 validation tests by prompting the LLM to generate edge cases and boundary conditions from the reproduction script. The patch agent then generates 4 augmented patches addressing these cases, regression risks, and language-specific best practices. All candidates are executed against validation tests, and an LLM reviews the results to select the best-performing patch.
Memory Activation. For episodic memory, ExpeRepair retrieves the top 3 most relevant demonstrations via the BM25 algorithm, which are then used as in-context examples for the agents. For semantic memory, stored insights are appended to the prompts as high-level repair guidelines, enhancing the agents’ reasoning and decision-making capabilities.
Overall Performance
Overall, ExpeRepair achieves state-of-the-art performance across both benchmarks. Using Claude 3.5 Sonnet, ExpeRepair resolves 48.3% of issues on SWE-Bench Lite and 57.2% on SWE-Bench Verified, surpassing all previously published open-source approaches, including PatchPilot and DARS. When paired with Claude 4 Sonnet, ExpeRepair further improves performance, achieving 60.3% resolution on SWE-Bench Lite and 74.6% on SWE-Bench Verified. These results demonstrate both the adaptability of ExpeRepair and the potential benefits of leveraging more powerful underlying LLMs.
In addition to effectiveness, ExpeRepair maintains a competitive inference cost. For example, while DARS achieves a pass@1 of 47.0% on SWE-Bench Lite, its average cost is 12.24 USD per instance, which is roughly six times higher than ExpeRepair’s 1.89 USD using Claude 3.5 Sonnet. This highlights that ExpeRepair not only improves repair effectiveness but also offers practical efficiency suitable for real-world deployment. Compared with other strong baselines, ExpeRepair consistently outperforms PatchPilot and OpenHands, which achieve 45.3% and 41.7% resolution on SWE-Bench Lite, respectively, with comparable or slightly higher costs. Similarly, Agentless-1.5 attains 40.7% resolution with an inference cost of 1.12 USD, indicating that while it is cost-efficient, its effectiveness remains substantially lower than that of ExpeRepair.
Ablations on Episodic Memory and Semantic Memory Components
We evaluate the contributions of Episodic and Semantic Memory by disabling them individually or jointly: (1) w/o Memory Module, which removes both Episodic and Semantic Memory and treats each issue in isolation, as in prior methods; (2) w/o Episodic Memory, which removes the in-context demonstrations provided to LLM agents during test and patch generation; and (3) w/o Semantic Memory, which removes reflective insights distilled from prior repair experiences.
Disabling Episodic Memory also degrades performance notably. The pass@1 decreases to 44.7% on SWE-Bench Lite and 52.8% on SWE-Bench Verified, accompanied by ESR and RSR reductions of 14.0/13.7 pp on Lite and 16.2/17.6 pp on Verified. This suggests that the demonstrations stored in the episodic memory provide effective in-context guidance during both test and patch generation. In contrast, removing the Semantic Memory leads to a relatively smaller performance drop. The resolution rates decrease modestly to 47.0% on Lite and 56.2% on Verified, while ESR and RSR drop by 4.7/6.4 pp on Lite and 6.4/5.6 pp on Verified. This indicates that while the insights distilled in semantic memory improve the quality of generated patches, their effect is less pronounced compared to issue-specific demonstrations.
Overall, these results reveal a clear hierarchy in component contributions: the Memory Module has the largest impact, followed by Episodic Memory, and then Semantic Memory. The combination of Episodic and Semantic Memory yields a synergistic effect, producing the highest pass@1, ESR, and RSR metrics across both benchmarks. These findings validate the design rationale of ExpeRepair: leveraging prior experience to provide both in-context demonstrations and reflective insights delivers substantial gains in autonomous program repair.
Semantic Memory
the expected output is Max[x,2], which conforms to valid Mathematica syntax. Instead, the current implementation produces Max(2, x), which violates Mathematica’s function-call conventions. This behavior arises because the mathematica_code printer mishandles variadic functions such as Max, generating syntactically invalid code. Although the issue is framed in terms of Max, the same underlying problem affects its counterpart function Min. This highlights the need for solutions that systematically handle symmetric or related operations to ensure consistent code generation.
Initially, the patch agent attempted to resolve the issue without activating semantic memory. The generated patch introduced a specialized _print_Max method to enforce Mathematica’s square-bracket notation. While this patch correctly formats Max, it fails to address the counterpart function Min, leaving it incorrectly printed. Consequently, although Max expressions are valid, the patch produces asymmetric and incomplete code generation.
Subsequently, the patch agent was allowed to activate semantic memory, incorporating all previously stored reflective insights into its system prompt. Notably, the fourth insight, “When implementing display, printing, formatting, or code generation, systematically handle symmetric or related operations to ensure consistent and complete coverage, avoiding partial fixes that address only one case.”, which was derived from resolving similar issues such as SymPy-13031, guides the agent to consider not only the explicitly reported Max function but also Min and other symmetric operators. As a result, the newly generated patch resolves the reported Max defect and simultaneously addresses Min, yielding a robust and comprehensive solution. This ensures consistent and syntactically valid Mathematica code generation across all relevant variadic functions, effectively preventing asymmetric or incomplete code generation.
Episodic Memory
In the initial attempt, the test agent tried to reproduce the issue without leveraging episodic memory. The generated script was ineffective due to an incomplete test setup: it did not establish a full Django application with proper INSTALLED_APPS, lacked complete database table creation and test data population, and did not force query execution to generate SQL. Consequently, the queries either did not execute or did not reflect the field restrictions necessary to trigger the regression.
In a subsequent attempt, the agent accessed episodic memory to retrieve prior examples of testing scripts. The retrieved example correctly sets up a temporary Django application, creates the relevant models and test data, and executes queries in a controlled environment. Guided by these examples, the agent produced a fully functional test script that successfully reproduced the issue: when combining select_related with only, all fields of the reverse OneToOneField model were included in the generated SQL, confirming the regression in Django 4.2.
Limitation
While our approach improves test generation and patch generation by leveraging accumulated episodic and semantic memories, it currently places less emphasis on optimizing bug localization, which is also a critical factor in program repair performance. The primary challenge lies in the difficulty of verifying localization correctness. Unlike test generation and patch generation, whose correctness can be directly validated through execution outcomes (e.g., triggering issues or passing test cases), bug localization lacks an automated oracle. The correctness of a localization prediction cannot be reliably determined based on the success or failure of the subsequent patch. One possible solution is to selectively accumulate localization experiences only from successful repair attempts, assuming that a correct patch implies the localization was correct. However, this conservative strategy would result in memories containing only a narrow subset of successful localization cases, limiting both diversity and coverage. We leave the integration of reliable, memory-based bug localization into our framework as an important direction for future work.
Threats to Validity
The first threat to validity is the potential for data leakage. Since LLMs are often trained on open-source repositories, public benchmarks may inadvertently overlap with their training corpora. This raises the risk that evaluation results reflect prior exposure rather than genuine generalization. To mitigate this concern, we avoid long-standing APR benchmarks (e.g., Defects4J ), which are more likely to have been included in model training corpora. Instead, we adopt SWE-Bench, a more recent benchmark that is less susceptible to contamination and has gained broad adoption in recent studies. Moreover, our evaluation emphasizes the reasoning process of models rather than their ability to recall existing solutions. Across experiments, our approach consistently outperforms strong baselines built on the same underlying models, suggesting that the observed gains stem from our methodology rather than memorization. In future work, we plan to extend our assessment to contamination-free datasets, such as live-updatable benchmarks, to further strengthen the robustness of our findings.
A second threat arises from the limited scope of our experiments, primarily constrained by computational resources. Although we evaluate four models from three different providers, our study still covers only a limited set of representative LLMs rather than the full spectrum of open- and closed-source architectures. This may introduce model-selection bias and limit the generalizability of our findings. To mitigate this concern, we draw on prior work in repository-level APR, which has shown the validity of evaluation on a limited number of models. Moreover, the consistent improvements observed across the evaluated models indicate that our approach is not tied to a particular model and is adaptable to diverse architectures.
The third threat concerns the generalizability of our approach beyond Python codebases. Our evaluation is limited to open-source projects implemented in Python, constraining our ability to demonstrate cross-language effectiveness. However, ExpeRepair is designed to be language-agnostic. It leverages experiential knowledge from test generation and bug repair patterns, rather than relying on language-specific syntax or semantics. This design suggests that our approach can extend to other programming languages, such as C# and Ruby.
Repository-Level Automatic Program Repair
Repository-level APR has attracted increasing attention from both academia and industry, motivated by the growing complexity of managing bug reports and issue tracking in collaborative platforms such as GitHub. With the rapid progress of LLMs in generative software engineering, LLM-based solutions have become the dominant paradigm for this problem space.
Early methods primarily relied on Retrieval-Augmented Generation (RAG), which retrieves relevant code snippets to guide LLMs during patch generation. More recently, agent-based frameworks treat LLMs as planning agents that iteratively interact with external tools to perform end-to-end issue resolution. Representative examples include SWE-agent, which introduced a general agent–computer interface, together with Moatless, OpenHands, AutoCodeRover, and SpecRover, which extend this paradigm with improved localization, multi-agent collaboration, and tighter tooling integration. SWE-Search and DARS further enhance agent capabilities through better search and exploration strategies.
In parallel, procedural methods follow expert-designed, fixed workflows that decompose repair into structured phases (e.g., reproduction, localization, patching, validation), as exemplified by Agentless and PatchPilot. Training-based pipelines such as SWE-Fixer and MCTS-Refined CoT further improve performance via continued training on real-world or synthetic repair data.


