ConceptioArchivearXiv CS
arXiv CSopen access

Enhancing Software Engineering Through Closed-Loop Memory Optimization

Unknown · 2026 · arxiv_cs
arXiv CS · Papers · License: Open Access · 2026
Open Source ↗Direct PDF ↓
softwarearchitecturesoftwareengineeringtesting
software engineering, software architecture, testing

Enhancing Software Engineering Through Closed-Loop Memory Optimization

Xuehang Guo1 , Zora Zhiruo Wang2 , Qingyun Wang1 , Graham Neubig2,3 , Xingyao Wang3,4

arXiv:2606.05646v1 [cs.SE] 4 Jun 2026

1

William & Mary

2

Carnegie Mellon University

3

OpenHands

4

University of Illinois Urbana-Champaign

Abstract Large language models (LLMs) have enabled powerful software engineering (SE) agents capable of navigating complex codebases and resolving real-world issues. However, these agents remain fundamentally episodic: they fail to retain, refine, and reuse experiences across tasks, repeatedly reconstructing context from scratch and reproducing similar mistakes. Even with memory support, they offer no remedy for the absence of a principled, task-agnostic memory utility, making them difficult to evaluate rigorously or generalize across agents and settings. To tackle these limitations, we introduce MemOp, a closed-loop framework for memory augmentation in SE agents. MemOp grounds memory utility in validated downstream impact, establishing utility as both a task-agnostic evaluation benchmark and an annotation-free optimization signal. Through complementary evaluation on single-episode and cross-episode memory augmentation, results demonstrate that MemOp consistently improves SE agents across settings, achieving absolute gains of up to ↑ 5.25% in success rate and ↑ 4.63% in resolve efficiency, while substantially reducing computational cost by ≥ 9.79%. Our project page: https://xhguo7.github.io/MemOp/.

1

Introduction

The emergence of large language models has catalyzed a paradigm shift in software engineering, enabling LLM agents capable of addressing complex real-world SE tasks (Jin et al., 2025; Guo et al., 2025b). Through tool use, code execution, and multi-step reasoning, LLMpowered SE agents have demonstrated remarkable capabilities in repository-level code generation (Yang et al., 2024; Zhang et al., 2024; Tao et al., 2024). Recent advances, such as SWEagent (Yang et al., 2024), OpenHands (Wang et al., 2025b), and Claude Code (Anthropic, 2025b), showcase the great potential of SE agents to autonomously navigate codebases, understand complex requirements, and implement solutions that span multiple files and functions within continuously evolving SE environments.

Figure 1: Memory-Augmented Software Engineering. Compared with no-Mθ SE agent (left), MemOp (right) equips SE agents with adaptively distilled memories to better tackle dynamic realworld SE challenges.

Despite these advances, SE agents remain fundamentally episodic: they fail to develop an adaptive and evolvable mental model across tasks. When solving repository-level issues, SE agents repeatedly reconstruct context from scratch, rediscover codebase structure, repeat ineffective implementation strategies, and overlook transferrable knowledge and lessons (§A & Figs. 6-13). This limitation is Correspondence to: Xuehang Guo ([email protected]), Xingyao Wang ([email protected])

especially acute in software engineering, where repositories evolve continuously and many tasks share project-specific conventions, debugging patterns, and architectural constraints. These failures are not due to inherent capability limits, but stem from the absence of principled memory mechanisms that continuously distill experience into reusable knowledge (Wang et al., 2026b). However, simply augmenting agents with memory fails to resolve the problem. Existing memoryaugmented approaches lack a principled and general definition of memory utility: they can store, retrieve, or summarize past experience, but whether a given memory actually improves downstream performance, and whether that judgment transfers across different tasks and agents, remains fundamentally unclear. As a result, memory design and optimization typically rely on task-specific heuristics (Wang et al., 2025a; Ong et al., 2025; Yan et al., 2025; Fang et al., 2025), complex memory architectures (Chen et al., 2024), and human expertise to determine what should be remembered and how memories should be refined (Wang et al., 2026a; Chen et al., 2024) (§5). Yet without a task-agnostic notion of memory utility, it remains unclear (i) how to determine whether a memory is genuinely beneficial, (ii) which properties make memory effective, and (iii) how to leverage utility to guide memory optimization in a generalizable, annotation-free manner. These shortcomings make existing methods difficult to evaluate rigorously, optimize effectively, and transfer across agents, tasks, and settings. To address these limitations, we introduce MemOp (§2), a closed-loop memory optimization framework for SE agents. MemOp grounds memory utility in validated downstream impact: a memory is useful if and only if it measurably improves SE agent performance on downstream tasks. As such, MemOp turns memory from a hand-designed prompt artifact into an optimizable component: the system learns what to remember by measuring what improves downstream performance. MemOp present two key innovations: ❶ Principled memory utility as dual harness: MemOp introduces a formal notion of memory utility grounded in validated downstream impact (§2.2): a memory is useful if and only if it causally improves SE agent performance on downstream tasks. This outcome-grounded definition serves a dual role: (i) an evaluation benchmark that enables rigorous, task-agnostic memory assessment (§3.1), and (ii) an optimization signal that directly drives memory optimization without costly annotation (§3.2). By anchoring utility to empirical SE performance rather than heuristic preferences (§5), MemOp transforms memory quality from an ill-defined property into a measurable, optimizable quantity. ❷ Closed-loop memory optimization: Building on this utility definition, MemOp implements closed-loop training that adaptively optimizes memory without external supervision (§2.3). Trajectory-level reflection distills candidate memories from completed SE trajectories, and performance-grounded validation converts each candidate into training signal by measuring its causal impact on downstream outcomes (§3.3). To systematically evaluate memory effectiveness, we study MemOp under two regimes (§3.4): singleepisode memory generation, where memory is distilled from one trajectory and immediately reused, and cross-episode memory evolution, where memory is progressively refined as the agent accumulates experience across tasks. Results show that MemOp notably improves SE agents in both settings (∆abs up to ↑ 5.25% in SR), with trained memory models achieving high-quality reflections (§4.2) and robust adaptability (§4.3) at substantially reduced computational cost (∆rel ≥ 9.79%, Fig.1, §F).

2

Memory Augmentation for Agentic Software Engineering

2.1

Problem Formulation

We consider an SE agent operating on a repository R to solve the k-th task Tk (k = 1, 2, 3, . . .). Starting from the initial state Sk−1 , the SE agent interacts with R through a sequence of actions A = {a1 , a2 , . . . , an } (n ≤ NA , NA is the maximum problem-solving iterations allowed for the SE agent), including code navigation, file reading, command execution, and function modification. Upon task completion at state Sk , this interaction produces a problem-solving trajectory τk = {(a1 , o1 ), (a2 , o2 ), . . . , (an , on )}, where oi represents the outputs and observations of ai (1 ≤ i ≤ n). Memory-Augmented SE Agent. Motivated by our preliminary studies that expose fundamental limitations in how agents process and retain problem-solving experience (§A.1), we augment the SE 2

agent with an evolving memory state Mk , stored in Memory.md (§A.2), that distills lessons learned to facilitate the SE agent on future tasks. In deployment, MemOp operates in two phases: ❶ Reflective Memory Evolution: After completing task Tk on repository R, a dedicated memory model Mθ reflects on problem-solving trajectory τk to evolve memory state: Mk = Mθ (R, Sk ), where Sk = S(Mk−1 , τk ) incorporates prior memory and current trajectory, and S(·) constructs the agent state from previous memory state and current trajectory. ❷ Memory-Augmented Execution: When solving Tk+1 , the agent is equipped with Mk , which provides distilled insights guiding more effective navigation, reasoning, and problem-solving. This raises two fundamental challenges that MemOp addresses: (1) how to measure whether a memory is useful, and (2) how to optimize memory toward utility. 2.2

Memory Utility: If It Doesn’t Help, It Doesn’t Count

Grounding Utility in Downstream Impact. Memory-augmented agentic systems face a critical problem: there is no principled way to quantify whether a given memory is genuinely useful (§5). Without such measures, it is impossible to distinguish good memory from noise, or even to leverage quality signals to drive learning (§5&B). We tackle this with a concrete, outcomegrounded definition: a memory is useful if and only if it demonstrably improves SE agent performance on downstream tasks. Performance-Grounded Memory Utility. Given Figure 2: Memory Utility. We tackles the fundamental challenge a candidate memory Mj (§2.2) by proposing memory utility with performance-grounded memgenerated from trajectory τk ory evaluation and trajectory-level rejection sampling. on task Tk in repository R, we measure the performance change ∆i (Mj ) for each metric i (i ∈ {1, . . . , NQ }, where NQ = 10 multi-dimensional metrics defined in §3.1) by comparing memory-augmented problem-solving against no-memory baseline. Memory Acceptance Criterion. Based on empirical measurements, we establish a rigorous criterion for memory quality. A candidate memory Mj is accepted as high-quality if and only if it satisfies: ∀i : ∆i (Mj ) ≥ 0

∃i : ∆i (Mj ) > 0

(1)

Memory candidates that fail this criterion are rejected. This acceptance criteria serves as a dual role in MemOp: (1) an evaluation benchmark for rigorous, task-agnostic memory assessment (§3.1), and (2) an optimization signal that drives memory learning without external annotation (§3.2). 2.3

MemOp For Closed-Loop Memory Optimization

From Experience to Memory. At the core of MemOp is to learn a memory model Mθ : Sk → Mk that distills agent experience into memory, mapping current agent state Sk = S(Mk−1 , τk ) to a new memory state Mk that captures key patterns, observations, and actionable insights (§A): Mk = Mθ (R, Sk ) = Mθ (R, (Mk−1 , τk ))

(2)

Each memory encodes lessons learned, codebase structures identified, reasoning patterns discovered, and task-relevant contextual information that the SE agent can leverage in future problem-solving. Our preliminary study on memory structure (§A.2) and generation instructions (§A.3) informs how Mk is represented and how Mθ is guided to generate it effectively. Memory Optimization Objective. Our goal is to learn Mθ such that the SE agent augmented with memory Mk achieves superior performance on future tasks Tk′ (k ′ > k): Mθ∗ = arg max ETk′ ,R [Q(Ak′ |R, Sk′ )] Mθ

3

(3)

Figure 3: Memory Model Finetuning. By preparing training datasets (Tab. 4) through trajectorybased rejection sampling (§3.2), Mθ is finetuned through two-stage training via SFT and RL (§3.3). where Q(·) is a composite memory utility function combining all NQ multi-dimensional metrics (§3.1) across task performance and problem-solving efficiency, and Mθ∗ is the optimal memory evolution function MemOp aims to learn. Crucially, Q is precisely the utility signal defined in §2.2, directly connecting how we measure memory quality to what we optimize for. This alignment is the conceptual core of MemOp: by anchoring the training objective to empirical SE outcomes rather than heuristic proxies, memory quality becomes a measurable, optimizable quantity.

3

Memory Optimization via Performance-Validated Finetuning

Turning memory utility into optimization signals, we first define how memory utility is measured (§3.1), then use that signal to curate training data (§3.2), and finally train Mθ in a closed loop (§3.3). 3.1

Grounding Memory Utility in Downstream Performance

To ensure the evaluation quality and comprehensiveness during both memory training datasets curation (§3.2) and SE performance evaluation (§4), we employ a systematic set of eight evaluation metrics covering the effectiveness and efficiency of SE agent’s problem-solving. Success Rate (SR) (Eq. 4) measures the proportion of tasks successfully resolved. SR =

1 X 1(SRt = 1) |T |

(4)

Tt ∈T

where T is the set of all tasks, 1(·) is the indicator function, and SRt ∈ {0, 1} indicates whether the t-th task is successfully resolved. Localization Accuracy (LA) (Eq. 5) evaluates the SE agent’s ability to localize required targets at two levels, including: (a) file (LAfile ): accurately identifying the target files, and (b) function (LAfunc ): accurately pinpointing the target functions; and two criteria, including: (a) first success (LA(1) ): measures whether the agent successfully localizes at least one required target, and (b) full success (LA(−1) ): measures whether the agent successfully localizes all required targets. (e)

LAf =

1 X (e) 1(LAf,t = 1) |T |

(5)

Tt ∈T

where e ∈ {1, −1} denotes the success criterion (first vs. full), and f ∈ {file, func} denotes the target granularity. For a given task Tt , let Ft∗ and Gt∗ denote the ground-truth target files and functions, respectively, and let Ft,i and Gt,i represent the files and functions accessed by the agent at step i. First success (e = 1) measures whether the agent identifies any target during problem-solving: the agent achieves first file localization if it accesses at least one target file across all steps, and similarly for functions. Full success (e = −1) measures whether the agent identifies all targets: the agent achieves full file localization only if all target files are eventually accessed, and similarly for functions. 4

Resolve Efficiency (Eresolve ) (Eq. 6) measures the average proportion of SE agent’s problem-solving iterations saved when resolving tasks. 1 X Eresolve = Eresolve,t (6) |T | Tt ∈T

where Eresolve,t = 1 − NnAt . Higher values indicate faster resolution, with Eresolve,t = 0 when the agent uses up all NA iterations on task Tt . Localization Efficiency (LE) (Eq. 7) measures the average efficiency in localizing required targets at two levels (file & function) and two criteria (first & full): (a) first success: LE (1) evaluates SE agent efficiency in localizing the first required targets; and (b) full success: LE (−1) evaluates SE agent efficiency in localizing all required targets. 1 X (e) (e) LEf = LEf,t (7) |T | Tt ∈T

where e ∈ {1, −1} denotes the efficiency criterion (first vs. full), f ∈ {file, func} denotes the target (e) (e) (e) granularity, and LEf,t = 1 − nf,t/NA with nf,t as the number of steps to achieve localization success. (1)

For first success (e = 1), nf,t is the step at which the agent first identifies any target file or function; (−1)

for full success (e = −1), nf,t is the step by which all targets are identified. Performance Difference is measured by absolute difference (∆abs ) (Eq. 8) and relative difference (∆rel ) (Eq. 9) in performance for each quality metric above (Eqs. 4-7). ∆abs,i = (Qi,MemOp − Qi,baseline ) × 100%

(8)

∆rel,i = (Qi,MemOp − Qi,baseline )/Qi,baseline × 100%

(9)

where Qi,MemOp and Qi,baseline denote the i-th metric with MemOp and baseline, respectively. 3.2

Curating Performance-Validated Memory Utility

The quality of memory instances directly determines their utility for SE agent problem-solving. To construct high-quality training data, we propose trajectory-based rejection sampling, a rigorous data curation method that applies our evaluation module (§2.2) to filter memory candidates, retaining only those empirically validated to improve SE agent performance. Alg. 1 formalizes this rejection sampling algorithm on NR repositories randomly sampled from SWE-Bench-Verified (Jimenez et al., 2024), with NT SE tasks for each repository. The SE agent attempts to solve each task with Nτ rollouts, during which each trajectory is used to generate NM memory candidates. Our memory acceptance criteria (Eq. 1) then determines whether Mp is categorized to the accepted set Daccept or rejected set Dreject . As such, this rejection sampling yields two datasets for our two-stage training: ❶ Stage I Dataset DSFT : The Stage I dataset, comprising accepted memory samples filtered from Daccept to train the memory model to generate performance-enhancing memories. ❷ Stage II Dataset DRL : The Stage II dataset, where the ground-truth memory of each sample is drawn from Daccept , and contrastive candidates are drawn from the filtered subset of Dreject corresponding to the same SE task and repository. 3.3

Training Memory Model from Validated Reflections

Stage I: Supervised Finetuning for Memory Generation. The memory model Mθ is first trained through supervised finetuning (SFT) on DSFT (§3.2) to acquire fundamental memory generation abilities from SE agents’ trajectories. Given a trajectory-memory pair (τ, M) ∈ DSFT , we optimize: JStageI = −E(τ,M)∼DSFT [log Pθ (M|τ, T , R)]

(10)

This stage teaches Mθ the critical characteristics of effective memories, establishing the foundation for high-quality memory generation and evolution. Stage II: Reinforcement Learning with Preference Optimization. As Stage I equips Mθ with foundational memory generation abilities, Stage II further optimizes Mθ toward generating highquality memory that improves SE agent performance via RL on DRL (§3.2). Mθ is trained with 5

Algorithm 1 Trajectory-Based Rejection Sampling R Input: Repositories {Ri }N i=1 , tasks per repo NT , trajectory rollouts per task Nτ , memory candidates per trajectory NM Output: Accepted dataset Daccept , rejected dataset Dreject Models: Memory model Mθ , SE agent AGENT Metrics: NQ =10 multi-dimensional metrics (SR, LA, Eresolve , LE) defined in §3.1 1: function S AMPLE M EMORY (R, T , τ ) ▷ Memory sampling function definition (§3.2) 2: S COREbase ← Q(AGENT(R, T , ∅)) ▷ Baseline utility (§2.3) 3: for p = 1 to NM do 4: Mp ← Mθ (R, τ ) ▷ Generate candidate (Eq. 2) 5: S COREp ← Q(AGENT(R, T , Mp )) ▷ Candidate memory utility (§2.3) 6: ∆(Mp ) ← S COREp − S COREbase ▷ Utility gain (Eq. 8) 7: if (∀ℓ ∈ {1, . . . , NQ } : ∆ℓ (Mp ) ≥ 0) ∧ (∃ℓ : ∆ℓ (Mp ) > 0) then ▷ Criterion (Eq. 1) 8: Daccept ← Daccept ∪ {(R, τ, Mp )} 9: else 10: Dreject ← Dreject ∪ {(R, τ, Mp )} 11: end if 12: end for 13: end function 14: Daccept ← ∅, Dreject ← ∅ 15: for i = 1 to NR do ▷ Iterate over NR repositories 16: for j = 1 to NT do ▷ Iterate over NT tasks 17: for t = 1 to Nτ do ▷ Iterate over Nτ trajectories 18: S AMPLE M EMORY(Ri , Tij , τijt ) ▷ Memory sampling 19: end for 20: end for 21: end for 22: return Daccept , Dreject ▷ Dataset curation (§3.3)

the reward (Eq. 11) grounded in memory utility (§2.2), directly optimizing memory generation toward validated downstream SE impact. Concretely, for each sample in DRL , Mθ generates c memory candidates {M1 , M2 , . . . , Mc } from the same task T R on repository R, where groundtruth memory is drawn from Daccept and the remaining (c − 1) candidates are drawn from Dreject . The reward function directly measures the SE performance improvement induced by each generated memory: NQ 1 X r(Mi ) = ∆ℓ (Mi ) (11) NQ ℓ=1

where ∆ℓ (Mi ) is the performance change on metric ℓ when the SE agent is augmented with Mi compared to the no-memory baseline (Eq. 8). This grounds the RL signal directly in downstream SE outcomes, where Mθ is rewarded for generating memory that measurably improves agent performance, and penalized for generating memory that is redundant or harmful. Accordingly, Stage II optimizes Mθ to maximize the expected reward advantage relative to the group baseline: JStageII = −E(T ,R,Mi )∼DRL [Ai log Pθ (Mi |T , R)] (12) Pc 1 where Ai = r(Mi )− r̄ is the advantage of Mi , and r̄ = c j=1 r(Mj ) is the group baseline reward computed over a rollout batch of c generated memory candidates. Through Stage II optimization, Mθ learns to generate memory that shares properties with validated high-quality memories while avoiding patterns common in rejected candidates. 3.4

Evaluation Regimes for Effective Reflection & Adaptive Evolution

A useful memory framework should be effective across downstream tasks and adaptive in memory evolution. Therefore, we evaluate MemOp in two modes: Single-Episode Memory Generation. MemOp generates a memory Mk from each completed SE trajectory τk , which is immediately reused to augment the SE agent. This regime evaluates the most 6

Table 1: Single-Episode Memory Augmentation. Single-episode accuracy and efficiency of SE agents (§3.1). Comparing baselines to SE agents with non-finetuned Mθ (NFT) or finetuned (FT) MemOp, absolute performance differences (Eq. 8) are shown as positive ↑ ∆abs % or negative ↓ ∆abs %. “-T" indicates thinking mode. Accuracy (%) Mθ

(1) LAfile

(1) LAfunc

Efficiency (%)

(−1) (−1) LAfile LAfunc

SR

(1) LEfile

(1) LEfunc

LEfile

(−1)

LEfunc

(−1)

Eresolve

SE Agent: Devstral-Small-2507 (Baseline)

69.75

62.50

64.89

51.10

39.25

32.43

27.51

27.23

15.34

10.01

Claude-4-Sonnet DeepSeek-1.5B DeepSeek-7B Qwen2.5-3B Qwen2.5-7B Qwen3-4B Qwen3-4B-T

↑1.50 ↓3.50 ↓1.75 ↓2.00 ↓0.50 ↓2.00 ↓1.50

↑1.50 ↓3.75 ↓1.50 ↓2.00 ↓1.00 ↓1.25 ↓0.50

↑2.37 ↓2.22 ↓2.06 ↓2.02 ↓0.97 ↓1.81 ↓1.13

↑1.01 ↓3.26 ↓2.65 ↓2.50 ↓0.97 ↓2.77 ↓1.46

↑2.00 ↓4.50 ↓3.25 ↓4.25 ↓1.75 ↓4.00 ↓3.25

↑2.83 ↓3.79 ↓2.82 ↓2.71 ↓1.07 ↓2.57 ↓1.52

↑3.13 ↓3.29 ↓2.53 ↓1.87 ↓0.84 ↓2.34 ↓0.56

↑3.75 ↓1.56 ↓0.69 ↓2.06 ↓0.62 ↓2.41 ↓0.60

↑3.83 ↓1.72 ↓0.98 ↓1.07 ↓0.53 ↓1.20 ↓0.59

↑3.74 ↓1.63 ↓0.42 ↓1.03 ↓0.68 ↓1.24 ↓0.61

↑0.50 ↑1.33 ↑0.63 ↑0.75 ↑1.19 ↑3.00 ↑2.78 ↑3.01 ↑4.75 ↑1.35 ↑0.75 ↑1.03 ↑0.71 ↑0.75 ↑0.76 ↑2.00 ↑2.35 ↑4.64 ↑5.25 ↑1.74 ↑1.25 ↑2.45 ↑1.37 ↑1.75 ↑2.26 ↑1.75 ↑3.48 ↑1.45 ↑2.50 ↑3.17 SE Agent: Qwen3-Coder-30B-A3B

↑0.65 ↑2.70 ↑0.63 ↑2.99 ↑1.16 ↑3.47

↑1.34 ↑2.51 ↑1.04 ↑2.21 ↑2.49 ↑3.91

↑1.39 ↑4.13 ↑0.89 ↑4.01 ↑3.46 ↑4.78

↑2.20 ↑3.81 ↑1.92 ↑2.67 ↑2.22 ↑4.63

DeepSeek-1.5B (FT) ↑0.75 DeepSeek-7B (FT) ↑2.25 Qwen2.5-3B (FT) ↑1.00 Qwen2.5-7B (FT) ↑2.25 Qwen3-4B (FT) ↑2.00 Qwen3-4B-T (FT) ↑2.75 (Baseline)

52.75

48.50

49.06

40.42

33.75

33.25

30.29

28.69

21.06

17.96

Claude-4-Sonnet DeepSeek-1.5B DeepSeek-7B Qwen2.5-3B Qwen2.5-7B Qwen3-4B Qwen3-4B-T

↑4.00 ↓4.75 ↓1.75 ↓4.25 ↓2.75 ↓4.50 ↓3.50

↑2.75 ↓4.00 ↓1.50 ↓4.00 ↓1.25 ↓3.75 ↓3.00

↑4.19 ↓4.31 ↓1.28 ↓4.24 ↓1.73 ↓4.33 ↓3.19

↑2.70 ↓1.60 ↓2.05 ↓2.40 ↓0.85 ↓2.50 ↓0.65

↑2.25 ↓2.75 ↓1.75 ↓2.75 ↓0.75 ↓1.75 ↓1.00

↑5.02 ↓2.47 ↓1.94 ↓2.91 ↓0.94 ↓2.98 ↓1.61

↑4.14 ↓2.14 ↓1.45 ↓3.08 ↓1.35 ↓2.87 ↓1.68

↑5.07 ↓2.46 ↓1.07 ↓1.93 ↓0.97 ↓2.55 ↓1.17

↑4.36 ↓1.92 ↓1.53 ↓2.48 ↓1.03 ↓2.29 ↓1.21

↑3.78 ↓2.09 ↓2.24 ↓2.28 ↓2.04 ↓2.47 ↓1.85

DeepSeek-1.5B (FT) ↑1.25 DeepSeek-7B (FT) ↑2.00 Qwen2.5-3B (FT) ↑0.75 Qwen2.5-7B (FT) ↑2.50 Qwen3-4B (FT) ↑2.00 Qwen3-4B-T (FT) ↑4.25

↑2.50 ↑3.00 ↑0.50 ↑3.50 ↑1.25 ↑3.25

↑2.27 ↑3.62 ↑0.94 ↑3.86 ↑2.37 ↑5.44

↑2.12 ↑2.81 ↑0.62 ↑3.56 ↑1.46 ↑3.21

↑1.25 ↑2.50 ↑0.50 ↑3.50 ↑1.00 ↑2.25

↓0.27 ↑3.07 ↑0.19 ↑3.93 ↑3.03 ↑5.50

↑1.36 ↑3.88 ↑1.69 ↑4.37 ↑2.42 ↑4.80

↑1.83 ↑5.04 ↑0.82 ↑5.15 ↑3.29 ↑5.93

↑1.72 ↑2.05 ↑0.82 ↑3.82 ↑2.09 ↑5.12

↑1.68 ↑1.42 ↑0.69 ↑3.61 ↑1.41 ↑4.10

fundamental ability of MemOp: whether memory distilled from a single trajectory can effectively improve downstream SE performance. It validates the quality of MemOp’s memory generation in isolation, independent of cross-task transfer or cross-episode generalization. Cross-Episode Memory Evolution. MemOp evolves memory progressively across a sequence of tasks. When SE agent performs the (k+1)-th task, it is equipped with the latest Mk generated at Sk = S(Mk−1 , τk ). This regime validates the adaptability and robustness of MemOp: whether memory can remain coherent, non-redundant, and increasingly useful as the SE agent encounters a growing diversity of tasks.

4

Experiments

4.1

Setup

Model. For SE agents, we evaluate two LLMs, including Devstral-Small-2507 (AI & AI, 2025) and Qwen3-Coder-30B-A3B (Yang et al., 2025a). During training dataset construction (§3.2), we employ Claude-4-Sonnet (Anthropic, 2025a) as Mθ to generate memory candidates. For MemOp, we finetune six LLMs for memory reflection, including Qwen2.5 (3B & 7B) (Yang et al., 2025b), DeepSeek-R1 (1.5B & 7B) (Guo et al., 2025a), together with Qwen3-4B and Qwen3-4B-Thinking (Yang et al., 2025a). 7

Table 2: Cross-Episode Memory Augmentation. Cross-episode accuracy and efficiency of SE agents (§3.1). Comparing baselines to SE agents with non-finetuned Mθ (NFT) or finetuned (FT) MemOp, absolute performance differences (Eq. 8) are shown as ↑ ∆abs % or ↓ ∆abs %. Accuracy (%) Mθ

Efficiency (%)

(1) LAfile

(1) LAfunc

(Baseline)

69.75

62.50

64.89

51.10

39.25

32.43

Claude-4-Sonnet DeepSeek-7B Qwen2.5-7B Qwen3-4B

↑0.75 ↓6.00 ↓3.25 ↓5.25

↑1.25 ↓7.25 ↓5.25 ↓7.25

↑1.47 ↓4.54 ↓2.52 ↓4.05

↑0.68 ↓6.37 ↓3.38 ↓6.32

↑1.25 ↓5.25 ↓3.50 ↓4.75

↑2.35 ↓8.07 ↓4.01 ↓4.78

DeepSeek-7B (FT) ↑1.00 Qwen2.5-7B (FT) ↑1.25 Qwen3-4B (FT) ↑1.75

↑0.25 ↑1.00 ↑1.25

(−1) (−1) LAfile LAfunc

(1) LEfile

(1) LEfunc

LEfile

(−1)

LEfunc

(−1)

Eresolve

27.51

27.23

15.34

10.01

↑2.34 ↓4.08 ↓2.27 ↓2.64

↑2.41 ↓5.47 ↓0.61 ↓2.86

↑2.07 ↓3.59 ↓2.23 ↓1.96

↑2.63 ↓4.49 ↓1.65 ↓1.95

↑0.48 ↑0.42 ↑1.00 ↑0.64 ↑0.47 ↑1.19 ↑0.86 ↑2.75 ↑2.36 ↑2.74 ↑1.69 ↑0.78 ↑1.75 ↑2.28 ↑1.81 SE Agent: Qwen3-Coder-30B-A3B

↑0.65 ↑1.52 ↑2.35

↑0.39 ↑2.43 ↑2.59

↑0.68 ↑2.73 ↑1.33

SR

SE Agent: Devstral-Small-2507

(Baseline)

52.75

48.50

49.06

40.42

33.75

33.25

30.29

28.69

21.06

17.96

Claude-4-Sonnet DeepSeek-7B Qwen2.5-7B Qwen3-4B

↑1.75 ↓6.25 ↓4.25 ↓6.00

↑1.50 ↓7.75 ↓3.75 ↓7.50

↑1.70 ↓6.42 ↓3.74 ↓6.77

↑1.44 ↓7.16 ↓3.53 ↓6.78

↑1.25 ↓4.50 ↓2.50 ↓4.25

↑1.37 ↓6.61 ↓4.47 ↓5.82

↑0.85 ↓6.63 ↓5.11 ↓6.13

↑1.92 ↓6.02 ↓3.32 ↓4.98

↑1.57 ↓5.79 ↓3.29 ↓4.85

↑0.70 ↓5.18 ↓3.85 ↓4.34

DeepSeek-7B (FT) ↑0.50 Qwen2.5-7B (FT) ↑1.25 Qwen3-4B (FT) ↑2.75

↑1.25 ↑1.75 ↑2.25

↑1.80 ↑2.26 ↑3.17

↑0.90 ↑1.88 ↑2.45

↑1.75 ↑3.00 ↑2.50

↑0.38 ↑1.21 ↑2.08

↑0.59 ↑1.08 ↑1.89

↑0.55 ↑2.17 ↑2.15

↑1.21 ↑1.92 ↑2.26

↑0.38 ↑1.33 ↑2.22

Data. We leverage SWE-Bench-Verified (Jimenez et al., 2024) for training and evaluation. (1) During training dataset construction (§3.2), we randomly sampled NT = 100 tasks across NR = 10 repositories. We employ two LLMs (Devstral-Small-2505 (AI & AI, 2025) and Qwen3-Coder-480B-A35B Yang et al. (2025a)) to power SE agents on these 1, 000 tasks, where we generate Nτ = 4 trajectories per task and NM = 4 memory per trajectory (Alg. 1), contributing to 3, 200 memory candidates. Through performance filtering, we summarize our datasets in Tab. 4 (§E). (2) During evaluation (§3.4), we assess MemOp in both single-episode and cross-episode settings. To avoid evaluation circularity (§E), we randomly sample 100 evaluation instances (Fig. 18) non-overlapped with the NT = 100 instances used to construct our training dataset (§3.2). We compute avg@4 across all metrics for evaluation accuracy. 4.2

Reflective Memory Augmentation for SE Agent

MemOp consistently improves SE agents in single-episode software engineering. Compared to no-Mθ baselines (Tab. 1), MemOp-augmented SE agents consistently outperform across ten metrics (§3.1), achieving absolute gains of up to ↑ 5.25% in SR and ↑ 4.63% in Eresolve . Notably, most variants of FT-Mθ surpass Claude-4-Sonnet by as much as ∆abs =↑ 3.25% in SR. In contrast, NFT-Mθ consistently degrades SE performance, indicating that, without MemOp, base models alone are insufficient for effective SE memory augmentation. Collectively, MemOp exhibits significant improvements on single-episode SE, underscoring the effectiveness of memory reflection in enhancing intra-episode reasoning and problem-solving. MemOp generalizes effectively to cross-episode software engineering. Tab. 2 shows consistent performance gains over baseline no-Mθ SE agents, with absolute improvements of up to ↑ 3.00% in SR and ↑ 3.17% in LA. Cross-episode reflective memory evolution is inherently challenging, as Mθ needs to determine which information to retain and share across episodes versus what to update. As a result, NFT-Mθ exhibits degraded performance compared to their single-episode counterparts (Tab. 1). In contrast, MemOp demonstrates strong adaptability in cross-episode reflective memory evolution, allowing Mθ to accumulate repository-level shared knowledge base while updating critical information. As shown in Tab. 2, MemOp-powered Mθ variants outperform both no-Mθ baselines (∆abs ≥ 1.00%) and NFT-Mθ (∆abs ≥ 3.28%) across evolution episodes, most of which surpass Claude by up to ∆abs =↑ 1.75% in SR. Qwen3-4B also showcases robust reflective memory 8

evolution ability, presenting ↑ 1.50% higher than its single-episode SR. These observations highlight the effectiveness of MemOp in progressively refining and leveraging knowledge across episodes to enable more informed problem-solving and improved long-horizon software engineering. 4.3

Generalizability of MemOp

MemOp is generalizable across different SE agents and Mθ backbones. As shown in Tabs.1-2, for both Devstral-Small-2507 and Qwen3-Coder-30B-A3B, MemOpaugmented SE agents consistently outperform no-Mθ baselines and six NFT-Mθ across singleepisode and cross-episode scenarios, achieving ∆abs of up to ↑9.00% in SR and ↑5.24% in Eresolve for Devstral-Small-2507, and ↑6.75% in SR and ↑7.45% in Eresolve for Qwen3Coder-30B-A3B. Meanwhile, the computational cost is notably reduced by ∆rel ≥9.79% (Tab. 6). All training stages contributes to performance improvements. As shown in Fig. 4, both training stages (§3.3) independently contribute to SE performance gains, where Stage I equips Mθ with foundational generation capabilities, while Stage II further refines memory quality via comparative performance signals. Notably, while Stage I or II alone independently improves SE performance, Stage I+II yields superior gains, demonstrating their complementary roles in memory optimization.

Figure 4: Adaptability to Different FT Stages.

MemOp is generalizable across repositories. Compared with no-Mθ baselines, Fig. 16 highlights the generalizability of MemOp to different SE repositories. Specifically, by evaluating repositorywise performance across 9 repositories and 90 instances with and without MemOp, respectively, results demonstrate consistent performance gains across ten metrics, underscoring the generalizability and robustness of MemOp across diverse repository structures and contexts. MemOp is also useful when applying different RL algorithms. As shown in Fig. 5, by adapting three RL algorithms, including GRPO (Shao et al., 2024), DAPO (Yu et al., 2025), and GSPO (Zheng et al., 2025), MemOp yields consistent gains over both noMθ baselines and NFT-Mθ , with ∆abs of up to ↑ 3.50% on SR and ↑ 4.03% on LA. These demonstrate that MemOp is algorithmagnostic and can be seamlessly integrated with various algorithms for improved reflective memory modeling.

Figure 5: MemOp Algorithm Generalizability.

9

5

Related Work

Memory-Augmented LLM Agents. As LLM agents become more capable (Wang et al., 2025b; Yang et al., 2024), their real-world deployment demands complex reasoning (Liu et al., 2023; Kuratov et al., 2024; Li et al., 2024; Hosseini et al., 2025) and long-context understanding (Chen et al., 2024), underscoring the need for principled memory augmentation. Existing approaches range from human-inspired memory organization (Fang et al., 2025) to sophisticated workflows (Chen et al., 2024; Yan et al., 2025), yet sharing critical limitations (§B.2): (1) build upon complex architectural pipelines that are difficult to adapt and generalize, (2) lack a principled, task-agnostic definition of memory utility that can support rigorous evaluation and memory optimization, and (3) rely on task-specific designs or costly annotations that impede transfer across agents and problem settings. Memory for SE Agents. LLM agents deployed in SE tasks interact with complex environments, identifying problematic code lines, executing commands, and implementing revisions across multiple files and repository levels (Wang et al., 2025b; Yang et al., 2024; Anthropic, 2025a). Each action expands the reasoning chain and accumulates environmental observations, overwhelming agents with redundant contextual information while driving up computational cost (§1). Prior work attempts to address this through task-specific memory heuristics (Ong et al., 2025), but without a unified and generic notion of what makes a memory useful, such approaches fail to determine whether retained information is genuinely beneficial or how to systematically improve it (§B.1).

6

Conclusion

In this work, we propose MemOp, a closed-loop framework that equips SE agents with memory augmentation through a principled notion of memory utility (§2-3). Experiments across single-episode and cross-episode settings demonstrate consistent gains across multi-dimensional metrics at reduced computational cost (§4). We hope our work motivates broader exploration of memory utility as a first-class design principle for building adaptive, generalizable, and continually-improving agents.

References Mistral AI and All Hands AI. Devstral model, 2025. URL https://mistral.ai/news/ devstral. Anthropic. Claude 4 sonnet, 2025a. claude-4.

URL https://www.anthropic.com/news/

Anthropic. Claude code, 2025b. URL https://claude.com/product/claude-code. Yash Kumar Atri, Ahmed Alaa, and Thomas Hartvigsen. Lifelong model editing with graph-based external memory. In Wanxiang Che, Joyce Nabende, Ekaterina Shutova, and Mohammad Taher Pilehvar (eds.), Findings of the Association for Computational Linguistics: ACL 2025, pp. 13336– 13352, Vienna, Austria, July 2025. Association for Computational Linguistics. ISBN 979-8-89176256-5. doi: 10.18653/v1/2025.findings-acl.690. URL https://aclanthology.org/2025. findings-acl.690/. Nuo Chen, Hongguang Li, Juhua Huang, Baoyuan Wang, and Jia Li. Compress to impress: Unleashing the potential of compressive memory in real-world long-term conversations. ArXiv, abs/2402.11975, 2024. URL https://arxiv.org/abs/2402.11975. Qinwen Chen, Wenbiao Tao, Zhiwei Zhu, Mingfan Xi, Liangzhong Guo, Yuan Wang, Wei Wang, and Yunshi Lan. ComRAG: Retrieval-augmented generation with dynamic vector stores for real-time community question answering in industry. In Georg Rehm and Yunyao Li (eds.), Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 6: Industry Track), pp. 749–763, Vienna, Austria, July 2025. Association for Computational Linguistics. ISBN 979-8-89176-288-6. doi: 10.18653/v1/2025.acl-industry.53. URL https: //aclanthology.org/2025.acl-industry.53/. Jizhan Fang, Xinle Deng, Haoming Xu, Ziyan Jiang, Yuqi Tang, Ziwen Xu, Shumin Deng, Yunzhi Yao, Mengru Wang, Shuofei Qiao, Huajun Chen, and Ningyu Zhang. Lightmem: Lightweight and efficient memory-augmented generation, 2025. URL https://arxiv.org/abs/2510. 18866. 10

Daya Guo, Dejian Yang, Haowei Zhang, Junxiao Song, Peiyi Wang, Qihao Zhu, Runxin Xu, Ruoyu Zhang, Shirong Ma, Xiao Bi, Xiaokang Zhang, Xingkai Yu, Yu Wu, Z. F. Wu, Zhibin Gou, Zhihong Shao, Zhuoshu Li, Ziyi Gao, Aixin Liu, Bing Xue, Bingxuan Wang, Bochao Wu, Bei Feng, Chengda Lu, Chenggang Zhao, Chengqi Deng, Chong Ruan, Damai Dai, Deli Chen, Dongjie Ji, Erhang Li, Fangyun Lin, Fucong Dai, Fuli Luo, Guangbo Hao, Guanting Chen, Guowei Li, H. Zhang, Hanwei Xu, Honghui Ding, Huazuo Gao, Hui Qu, Hui Li, Jianzhong Guo, Jiashi Li, Jingchang Chen, Jingyang Yuan, Jinhao Tu, Junjie Qiu, Junlong Li, J. L. Cai, Jiaqi Ni, Jian Liang, Jin Chen, Kai Dong, Kai Hu, Kaichao You, Kaige Gao, Kang Guan, Kexin Huang, Kuai Yu, Lean Wang, Lecong Zhang, Liang Zhao, Litong Wang, Liyue Zhang, Lei Xu, Leyi Xia, Mingchuan Zhang, Minghua Zhang, Minghui Tang, Mingxu Zhou, Meng Li, Miaojun Wang, Mingming Li, Ning Tian, Panpan Huang, Peng Zhang, Qiancheng Wang, Qinyu Chen, Qiushi Du, Ruiqi Ge, Ruisong Zhang, Ruizhe Pan, Runji Wang, R. J. Chen, R. L. Jin, Ruyi Chen, Shanghao Lu, Shangyan Zhou, Shanhuang Chen, Shengfeng Ye, Shiyu Wang, Shuiping Yu, Shunfeng Zhou, Shuting Pan, S. S. Li, Shuang Zhou, Shaoqing Wu, Tao Yun, Tian Pei, Tianyu Sun, T. Wang, Wangding Zeng, Wen Liu, Wenfeng Liang, Wenjun Gao, Wenqin Yu, Wentao Zhang, W. L. Xiao, Wei An, Xiaodong Liu, Xiaohan Wang, Xiaokang Chen, Xiaotao Nie, Xin Cheng, Xin Liu, Xin Xie, Xingchao Liu, Xinyu Yang, Xinyuan Li, Xuecheng Su, Xuheng Lin, X. Q. Li, Xiangyue Jin, Xiaojin Shen, Xiaosha Chen, Xiaowen Sun, Xiaoxiang Wang, Xinnan Song, Xinyi Zhou, Xianzu Wang, Xinxia Shan, Y. K. Li, Y. Q. Wang, Y. X. Wei, Yang Zhang, Yanhong Xu, Yao Li, Yao Zhao, Yaofeng Sun, Yaohui Wang, Yi Yu, Yichao Zhang, Yifan Shi, Yiliang Xiong, Ying He, Yishi Piao, Yisong Wang, Yixuan Tan, Yiyang Ma, Yiyuan Liu, Yongqiang Guo, Yuan Ou, Yuduan Wang, Yue Gong, Yuheng Zou, Yujia He, Yunfan Xiong, Yuxiang Luo, Yuxiang You, Yuxuan Liu, Yuyang Zhou, Y. X. Zhu, Yanping Huang, Yaohui Li, Yi Zheng, Yuchen Zhu, Yunxian Ma, Ying Tang, Yukun Zha, Yuting Yan, Z. Z. Ren, Zehui Ren, Zhangli Sha, Zhe Fu, Zhean Xu, Zhenda Xie, Zhengyan Zhang, Zhewen Hao, Zhicheng Ma, Zhigang Yan, Zhiyu Wu, Zihui Gu, Zijia Zhu, Zijun Liu, Zilin Li, Ziwei Xie, Ziyang Song, Zizheng Pan, Zhen Huang, Zhipeng Xu, Zhongyu Zhang, and Zhen Zhang. Deepseek-r1 incentivizes reasoning in llms through reinforcement learning. Nature, 645(8081):633–638, 2025a. ISSN 1476-4687. doi: 10.1038/s41586-025-09422-z. URL http://dx.doi.org/10.1038/s41586-025-09422-z. Jiale Guo, Suizhi Huang, Mei Li, Dong Huang, Xingsheng Chen, Regina Zhang, Zhijiang Guo, Han Yu, Siu-Ming Yiu, Pietro Lio, and Kwok-Yan Lam. A comprehensive survey on benchmarks and solutions in software engineering of llm-empowered agentic system, 2025b. URL https: //arxiv.org/abs/2510.09721. Zexue He, Leonid Karlinsky, Donghyun Kim, Julian McAuley, Dmitry Krotov, and Rogerio Feris. Camelot: Towards large language models with training-free consolidated associative memory, 2024. URL https://arxiv.org/abs/2402.13449. Peyman Hosseini, Ignacio Castro, Iacopo Ghinassi, and Matthew Purver. Efficient solutions for an intriguing failure of LLMs: Long context window does not mean LLMs can analyze long sequences flawlessly. In Owen Rambow, Leo Wanner, Marianna Apidianaki, Hend Al-Khalifa, Barbara Di Eugenio, and Steven Schockaert (eds.), Proceedings of the 31st International Conference on Computational Linguistics, pp. 1880–1891, Abu Dhabi, UAE, January 2025. Association for Computational Linguistics. URL https://aclanthology.org/2025.coling-main. 128/. Mengkang Hu, Tianxing Chen, Qiguang Chen, Yao Mu, Wenqi Shao, and Ping Luo. HiAgent: Hierarchical working memory management for solving long-horizon agent tasks with large language model. In Wanxiang Che, Joyce Nabende, Ekaterina Shutova, and Mohammad Taher Pilehvar (eds.), Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 32779–32798, Vienna, Austria, July 2025. Association for Computational Linguistics. ISBN 979-8-89176-251-0. doi: 10.18653/v1/2025.acl-long.1575. URL https://aclanthology.org/2025.acl-long.1575/. Carlos E Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, and Karthik R Narasimhan. SWE-bench: Can language models resolve real-world github issues? In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview. net/forum?id=VTF8yNQM66. 11

Haolin Jin, Linghan Huang, Haipeng Cai, Jun Yan, Bo Li, and Huaming Chen. From llms to llmbased agents for software engineering: A survey of current, challenges and future, 2025. URL https://arxiv.org/abs/2408.02479. Thomas Joshi, Shayan Chowdhury, and Fatih Uysal. Swe-bench-cl: Continual learning for coding agents, 2025. URL https://arxiv.org/abs/2507.00014. Savini Kashmira, Jayanaka L. Dantanarayana, Joshua Brodsky, Ashish Mahendra, Yiping Kang, Krisztian Flautner, Lingjia Tang, and Jason Mars. TOBUGraph: Knowledge graph-based retrieval for enhanced LLM performance beyond RAG. In Saloni Potdar, Lina Rojas-Barahona, and Sebastien Montella (eds.), Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing: Industry Track, pp. 1349–1356, Suzhou (China), November 2025. Association for Computational Linguistics. ISBN 979-8-89176-333-3. doi: 10.18653/v1/2025.emnlp-industry.93. URL https://aclanthology.org/2025.emnlp-industry.93/. Yuri Kuratov, A. Bulatov, Petr Anokhin, Ivan Rodkin, Dmitry Sorokin, Artyom Y. Sorokin, and M. Burtsev. Babilong: Testing the limits of llms with long context reasoning-in-a-haystack. ArXiv, abs/2406.10149, 2024. URL https://arxiv.org/pdf/2406.10149.pdf. Jiaqi Li, Mengmeng Wang, Zilong Zheng, and Muhan Zhang. LooGLE: Can long-context language models understand long contexts? In Lun-Wei Ku, Andre Martins, and Vivek Srikumar (eds.), Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 16304–16333, Bangkok, Thailand, August 2024. Association for Computational Linguistics. doi: 10.18653/v1/2024.acl-long.859. URL https://aclanthology.org/2024.acl-long.859/. Tobias Lindenbauer, Georg Groh, and Hinrich Schuetze. From knowledge to noise: CTIM-rover and the pitfalls of episodic memory in software engineering agents. In Ehsan Kamalloo, Nicolas Gontier, Xing Han Lu, Nouha Dziri, Shikhar Murty, and Alexandre Lacoste (eds.), Proceedings of the 1st Workshop for Research on Agent Language Models (REALM 2025), pp. 411–427, Vienna, Austria, July 2025. Association for Computational Linguistics. ISBN 979-8-89176-264-0. doi: 10. 18653/v1/2025.realm-1.30. URL https://aclanthology.org/2025.realm-1.30/. Nelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, F. Petroni, and Percy Liang. Lost in the middle: How language models use long contexts. Transactions of the Association for Computational Linguistics, 12:157–173, 2023. URL https://www.aclanthology. org/2024.tacl-1.9.pdf. Kai Tzu-iunn Ong, Namyoung Kim, Minju Gwak, Hyungjoo Chae, Taeyoon Kwon, Yohan Jo, Seung-won Hwang, Dongha Lee, and Jinyoung Yeo. Towards lifelong dialogue agents via timeline-based memory management. In Luis Chiruzzo, Alan Ritter, and Lu Wang (eds.), Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), pp. 8631–8661, Albuquerque, New Mexico, April 2025. Association for Computational Linguistics. ISBN 979-8-89176-189-6. doi: 10.18653/v1/2025.naacl-long.435. URL https://aclanthology.org/2025.naacl-long.435/. Hongjin Qian, Zheng Liu, Peitian Zhang, Kelong Mao, Defu Lian, Zhicheng Dou, and Tiejun Huang. Memorag: Boosting long context processing with global memory-enhanced retrieval augmentation, 2025. URL https://arxiv.org/abs/2409.05591. Rana Salama, Jason Cai, Michelle Yuan, Anna Currey, Monica Sunkara, Yi Zhang, and Yassine Benajiba. Meminsight: Autonomous memory augmentation for llm agents, 2025. URL https: //arxiv.org/abs/2503.21760. Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Xiao Bi, Haowei Zhang, Mingchuan Zhang, Y. K. Li, Y. Wu, and Daya Guo. Deepseekmath: Pushing the limits of mathematical reasoning in open language models, 2024. URL https://arxiv.org/abs/ 2402.03300. Kangning Shen, Jingyuan Zhang, Chenxi Sun, Wencong Zeng, and Yang Yue. Structurally aligned subtask-level memory for software engineering agents, 2026. URL https://arxiv.org/ abs/2602.21611. 12

Haoran Sun, Shaoning Zeng, and Bob Zhang. H-MEM: Hierarchical memory for high-efficiency long-term reasoning in LLM agents. In Vera Demberg, Kentaro Inui, and Lluís Marquez (eds.), Proceedings of the 19th Conference of the European Chapter of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 341–350, Rabat, Morocco, March 2026. Association for Computational Linguistics. ISBN 979-8-89176-380-7. doi: 10.18653/v1/2026.eacl-long.15. URL https://aclanthology.org/2026.eacl-long.15/. Wei Tao, Yucheng Zhou, Wenqiang Zhang, and Yu-Xi Cheng. Magis: Llm-based multi-agent framework for github issue resolution. ArXiv, abs/2403.17927, 2024. URL https://arxiv. org/pdf/2403.17927.pdf. Boshi Wang, Weijian Xu, Yunsheng Li, Mei Gao, Yujia Xie, Huan Sun, and Dongdong Chen. Improving code localization with repository memory. ArXiv, abs/2510.01003, 2025a. URL https://arxiv.org/abs/2510.01003. Qihao Wang, Ziming Cheng, Shuo Zhang, Fan Liu, Rui Xu, Heng Lian, Kunyi Wang, Xiaoming Yu, Jianghao Yin, Sen Hu, Yue Hu, Shaolei Zhang, Yanbing Liu, Ronghao Chen, and Huacan Wang. Memgovern: Enhancing code agents through learning from governed human experiences, 2026a. URL https://arxiv.org/abs/2601.06789. Xingyao Wang, Boxuan Li, Yufan Song, Frank F. Xu, Xiangru Tang, Mingchen Zhuge, Jiayi Pan, Yueqi Song, Bowen Li, Jaskirat Singh, Hoang H. Tran, Fuqiang Li, Ren Ma, Mingzhang Zheng, Bill Qian, Yanjun Shao, Niklas Muennighoff, Yizhe Zhang, Binyuan Hui, Junyang Lin, Robert Brennan, Hao Peng, Heng Ji, and Graham Neubig. Openhands: An open platform for ai software developers as generalist agents, 2025b. URL https://arxiv.org/abs/2407.16741. Zheng Wang, Shu Xian Teo, Jieer Ouyang, Yongjun Xu, and Wei Shi. M-rag: Reinforcing large language model performance through retrieval-augmented generation with multiple partitions, 2024. URL https://arxiv.org/abs/2405.16420. Zora Zhiruo Wang, John Yang, Kilian Lieret, et al. Position: Humans are missing from ai coding agent research, 2026b. URL https://zorazrw.github.io/files/position-haicode. pdf. B. Y. Yan, Chaofan Li, Hongjin Qian, Shuqi Lu, and Zheng Liu. General agentic memory via deep research, 2025. URL https://arxiv.org/abs/2511.18423. An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, Chujie Zheng, Dayiheng Liu, Fan Zhou, Fei Huang, Feng Hu, Hao Ge, Haoran Wei, Huan Lin, Jialong Tang, Jian Yang, Jianhong Tu, Jianwei Zhang, Jianxin Yang, Jiaxi Yang, Jing Zhou, Jingren Zhou, Junyang Lin, Kai Dang, Keqin Bao, Kexin Yang, Le Yu, Lianghao Deng, Mei Li, Mingfeng Xue, Mingze Li, Pei Zhang, Peng Wang, Qin Zhu, Rui Men, Ruize Gao, Shixuan Liu, Shuang Luo, Tianhao Li, Tianyi Tang, Wenbiao Yin, Xingzhang Ren, Xinyu Wang, Xinyu Zhang, Xuancheng Ren, Yang Fan, Yang Su, Yichang Zhang, Yinger Zhang, Yu Wan, Yuqiong Liu, Zekun Wang, Zeyu Cui, Zhenru Zhang, Zhipeng Zhou, and Zihan Qiu. Qwen3 technical report, 2025a. URL https://arxiv.org/abs/2505.09388. An Yang, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chengyuan Li, Dayiheng Liu, Fei Huang, Haoran Wei, Huan Lin, Jian Yang, Jianhong Tu, Jianwei Zhang, Jianxin Yang, Jiaxi Yang, Jingren Zhou, Junyang Lin, Kai Dang, Keming Lu, Keqin Bao, Kexin Yang, Le Yu, Mei Li, Mingfeng Xue, Pei Zhang, Qin Zhu, Rui Men, Runji Lin, Tianhao Li, Tianyi Tang, Tingyu Xia, Xingzhang Ren, Xuancheng Ren, Yang Fan, Yang Su, Yichang Zhang, Yu Wan, Yuqiong Liu, Zeyu Cui, Zhenru Zhang, and Zihan Qiu. Qwen2.5 technical report, 2025b. URL https://arxiv.org/abs/2412.15115. John Yang, Carlos E. Jimenez, Alexander Wettig, Kilian Adriano Lieret, Shunyu Yao, Karthik Narasimhan, and Ofir Press. Swe-agent: Agent-computer interfaces enable automated software engineering. ArXiv, abs/2405.15793, 2024. URL https://arxiv.org/pdf/2405.15793. pdf. Qiying Yu, Zheng Zhang, Ruofei Zhu, Yufeng Yuan, Xiaochen Zuo, Yu Yue, Weinan Dai, Tiantian Fan, Gaohong Liu, Lingjun Liu, Xin Liu, Haibin Lin, Zhiqi Lin, Bole Ma, Guangming Sheng, 13

Yuxuan Tong, Chi Zhang, Mofan Zhang, Wang Zhang, Hang Zhu, Jinhua Zhu, Jiaze Chen, Jiangjie Chen, Chengyi Wang, Hongli Yu, Yuxuan Song, Xiangpeng Wei, Hao Zhou, Jingjing Liu, WeiYing Ma, Ya-Qin Zhang, Lin Yan, Mu Qiao, Yonghui Wu, and Mingxuan Wang. Dapo: An open-source llm reinforcement learning system at scale, 2025. URL https://arxiv.org/ abs/2503.14476. Kechi Zhang, Jia Li, Ge Li, Xianjie Shi, and Zhi Jin. Codeagent: Enhancing code generation with tool-integrated agent systems for real-world repo-level coding challenges. In Annual Meeting of the Association for Computational Linguistics, 2024. URL https://api.semanticscholar. org/CorpusId:266999556. Chujie Zheng, Shixuan Liu, Mingze Li, Xiong-Hui Chen, Bowen Yu, Chang Gao, Kai Dang, Yuqiong Liu, Rui Men, An Yang, Jingren Zhou, and Junyang Lin. Group sequence policy optimization, 2025. URL https://arxiv.org/abs/2507.18071. Wanjun Zhong, Lianghong Guo, Qiqi Gao, He Ye, and Yanlin Wang. Memorybank: Enhancing large language models with long-term memory, 2023. URL https://arxiv.org/abs/2305. 10250.

14

A

Preliminary: Memory-Augmented AI Software Engineering

A.1

Preliminary Exploration on SE Agent Failures

How do SE agents fail in software engineering tasks? Understanding the nature of SE agent failures is critical for improving their problemsolving. Motivated by this, we perform a preliminary analysis on key failure patterns in SE agents, categorizing common causes to inform potential directions for enhancement. Our preliminary study manually examines the complete problem-solving trajectories of 50 software engineering failures (SR = 0.00%) of the SE agent powered by GPT-4o-mini, identifying seven key causes of failures in AI agent software engineering. For each category, we present a representative case from our study. As shown in Figs. 7-13, these cases illustrate different fail- Figure 6: Preliminary Analysis on SE Agent ure patterns and their impact on intermediate Failures. Through manual analysis, we identify progress: repository structure (Fig. 7), repeti- seven failure patterns in SE agent problem-solving. tion (Fig. 8), reasoning (Fig. 9), coding (Fig. 10), execution (Fig. 11), inconsistency (Fig. 12), and hallucination (Fig. 13). As shown in Fig. 6, AI agent’s misinterpretation and incorrect understanding of repository structure constitute the primary causes of problem-solving failures. As the number of actions and episodes increases, repetition in long-context reasoning emerges as the second major contributor, followed by reasoning errors as well as syntax and execution errors. These failures expose critical limitations of SE agents in comprehending, distilling, and memorizing key structures and patterns of the codebase, underscoring the significance of memory augmentation and optimization in complex software engineering tasks that demand long-context reasoning and problem-solving.

Table 3: Preliminary Exploration of Memory Structures. To investigate which memory structure can most effectively benefit SE agents, we perform a preliminary evaluation of nine memory structures compared to the no-memory baseline (highlighted in gray ). The absolute performance differences (Eq. 8) are shown as positive ↑ ∆abs % or negative ↓ ∆abs %. Memory

Structure

SR

LAf ile

(1)

LAf unc

LEf ile

(1)

LEf unc

× ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓

– String Dictionary List Tree Graph Python Given Discretionary Ours

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

56.57 63.33 ↑6.76 76.67 ↑20.10 53.33 ↓3.24 60.00 ↑3.43 66.67 ↑10.10 73.33 ↑16.76 60.00 ↑3.43 63.33 ↑6.76 76.67 ↑20.10

16.67 43.33 ↑26.66 46.67 ↑30.00 26.67 ↑10.00 30.00 ↑13.33 46.67 ↑30.00 40.00 ↑23.33 36.67 ↑20.00 33.33 ↑16.66 50.00 ↑33.33

35.50 41.85 ↑6.35 50.35 ↑14.85 42.00 ↑6.50 43.00 ↑7.50 46.50 ↑11.00 56.35 ↑20.85 42.65 ↑7.15 45.15 ↑9.65 53.15 ↑17.65

11.00 31.65 ↑20.65 28.85 ↑17.85 20.35 ↑9.35 21.50 ↑10.50 28.35 ↑17.35 33.00 ↑22.00 23.50 ↑12.50 26.35 ↑15.35 29.65 ↑18.65

15

(1)

(1)

Repository Structure Let me check what unit test files exist:

SE Agent

<function=execute_bash> <parameter=command> ls -la /workspace/django__django__3.0/django/tests </parameter> </function>

EXECUTION RESULT of [execute_bash]: ls: cannot access '/workspace/django__django__3.0/django/tests': No such file or directory [The command completed with exit code 1.] [Current working directory: /workspace/django__django__3.0] [Python interpreter: /opt/miniconda3/envs/testbed/bin/python] [Command finished with exit code 1]

Output

Figure 7: Failure Case of Repository Structure. The SE agent fails due to its incorrect understanding of the repository structure.

Repetition Let me try to see how to run the tests:

SE Agent

<function=execute_bash> <parameter=command> cd /workspace/django__django__3.0 && python -m pytest --version </parameter> </function>

EXECUTION RESULT of [execute_bash]: /opt/miniconda3/envs/testbed/bin/python: No module named pytest [The command completed with exit code 1.] [Current working directory: /workspace/django__django__3.0] [Python interpreter: /opt/miniconda3/envs/testbed/bin/python] [Command finished with exit code 1]

Output

... Now, let me run the tests:

SE Agent

<function=execute_bash> <parameter=command> cd /workspace/django__django__3.0 && python -m pytest --version </parameter> </function>

EXECUTION RESULT of [execute_bash]: /opt/miniconda3/envs/testbed/bin/python: No module named pytest [The command completed with exit code 1.] [Current working directory: /workspace/django__django__3.0] [Python interpreter: /opt/miniconda3/envs/testbed/bin/python] [Command finished with exit code 1]

Output

Figure 8: Failure Case of Repetition. The SE agent repeats the same error as in earlier attempts. 16

Reasoning

... EXECUTION RESULT of [str_replace_editor]: Here's the result of running `cat -n` on /workspace/django__django__3.0/tests/responses/tests.py: 1 import io 2 3 from django.conf import settings 4 from django.core.cache import cache 5 from django.http import HttpResponse 6 from django.http.response import HttpResponseBase 7 from django.test import SimpleTestCase 8 9 UTF8 = 'utf-8' 10 ISO88591 = 'iso-8859-1' 11 12 13 class HttpResponseBaseTests(SimpleTestCase): 14 def test_closed(self): 15 r = HttpResponseBase() 16 self.assertIs(r.closed, False) 17 18 r.close() 19 self.assertIs(r.closed, True) 20

Output

Since it extends SimpleTestCase, settings should be autoconfigured. Let me run tests to see if the environment works properly:

SE Agent

<function=execute_bash> <parameter=command> cd /workspace/django__django__3.0 && python -m pytest tests/responses/tests.py::HttpResponseTests::test_status_code -v </parameter> </function>

EXECUTION RESULT of [execute_bash]: /opt/miniconda3/envs/testbed/bin/python: No module named pytest [The command completed with exit code 1.] [Current working directory: /workspace/django__django__3.0] [Python interpreter: /opt/miniconda3/envs/testbed/bin/python] [Command finished with exit code 1]

Output

Figure 9: Failure Case of Reasoning Error. The SE agent fails due to its incorrect reasoning across multiple attempts.

17

Coding Error

SE Agent

<function=execute_bash> <parameter=command> cd /workspace && python simple_reproduction.py </parameter> </function>

EXECUTION RESULT of [execute_bash]: === Current get_inline_instances behavior === Traceback (most recent call last): File "simple_reproduction.py", line 112, in <module> test_current_get_inline_instances() File "simple_reproduction.py", line 74, in test_current_get_inline_instances ma = MyModelAdmin(None, None) # Pass None for testing purposes File "/testbed/django/contrib/admin/options.py", line 576, in __init__ self.opts = model._meta AttributeError: 'NoneType' object has no attribute '_meta' [The command completed with exit code 1.] [Current working directory: /workspace] [Python interpreter: /opt/miniconda3/envs/testbed/bin/python] [Command finished with exit code 1]

Output

Figure 10: Failure Case of Coding Error. The SE agent fails due to coding errors, such as SyntaxError, NameError, AttributeError, etc.

Execution Error

SE Agent

Let me try a completely different angle - what if `list(cv)` is still called somewhere else even in this fixed approach? But I think actually the fundamental understanding must be incorrect - I just realized maybe the problem isn't what I suspected. Looking carefully at it - why exactly does that `list(cv)` approach in the original code cause a problem? I have to make the simpler and most correct fix, which is the simplest possible. Looking more carefully at existing working cases with regular cv objects... Let me try the minimal change which is to simply prevent the original code from modifying the input, by storing a copy of the cv: ## Best approach - re-implement the simplest correct fix Let me revert the file completely to understand what originally does work first, then find and fix the exact issue: <function=execute_bash> <parameter=command> cd /workspace/scikit-learn__scikit-learn__1.3 && git st </parameter> </function>

EXECUTION RESULT of [execute_bash]: git: 'st' is not a git command. See 'git --help'. The most similar commands are status reset stage stash [The command completed with exit code 1.] [Current working directory: /workspace/scikit-learn__scikit-learn__1.3] [Python interpreter: /opt/miniconda3/envs/testbed/bin/python] [Command finished with exit code 1]

Output

Figure 11: Failure Case of Execution Error. The SE agent fails due to execution errors. 18

Inconsistency Let me actually create a test within the Django testing framework format to validate our changes:

SE Agent

<function=execute_bash> <parameter=command> cd /workspace/django__django__3.0 && python -m django test modeladmin.tests.ModelAdminTestCase.test_get_inline_instances -verbosity=2 </parameter> </function>

EXECUTION RESULT of [execute_bash]: Traceback (most recent call last): File "/opt/miniconda3/envs/testbed/lib/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/opt/miniconda3/envs/testbed/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/workspace/django__django__3.0/django/__main__.py", line 9, in <module> management.execute_from_command_line() File "/workspace/django__django__3.0/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute()

Output

[...] File "/workspace/django__django__3.0/django/test/utils.py", line 301, in get_runner test_runner_class = test_runner_class or settings.TEST_RUNNER File "/workspace/django__django__3.0/django/conf/__init__.py", line 76, in __getattr__ self._setup(name) File "/workspace/django__django__3.0/django/conf/__init__.py", line 61, in _setup % (desc, ENVIRONMENT_VARIABLE)) django.core.exceptions.ImproperlyConfigured: Requested setting TEST_RUNNER, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. [The command completed with exit code 1.] [Current working directory: /workspace/django__django__3.0] [Python interpreter: /opt/miniconda3/envs/testbed/bin/python] [Command finished with exit code 1]

Figure 12: Failure Case of Inconsistency. The SE agent fails due to the inconsistency between its reasoning and action.

19

Hallucination Let me run one final check to ensure existing similar functionality tests wouldn't be affected by making sure I haven't introduced regression patterns:

SE Agent

<function=execute_bash> <parameter=command> cd /workspace/django__django__3.0 && python -c " # Quick verification of our fix addresses the issue exactly as presented import os os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django.conf.global_settings') from django.conf import settings if not settings.configured: settings.configure(DEBUG=True, SECRET_KEY='test', DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}, INSTALLED_APPS= ['django.contrib.contenttypes', 'django.contrib.auth']) import django django.setup() from django.http import HttpResponse import memoryview # Exact reproduction from issue description # String content (correct) response = HttpResponse('My Content') print('String result:', response.content) # Bytes content (correct) response = HttpResponse(b'My Content') print('Bytes result:', response.content) # memoryview content (was broken, should now be fixed) response = HttpResponse(memoryview(b'My Content')) print('Memoryview result:', response.content) print('All results should be b\"My Content\" - fix verified!') " </parameter> </function>

EXECUTION RESULT of [execute_bash]: cd /workspace/django__django__3.0 && python -c " # Quick verification of our fix addresses the issue exactly as presented [...]

Output

print('All results should be b\"My Content\" - fix verified!') " Traceback (most recent call last): File "<string>", line 12, in <module> ModuleNotFoundError: No module named 'memoryview' [The command completed with exit code 1.] [Current working directory: /workspace/django__django__3.0] [Python interpreter: /opt/miniconda3/envs/testbed/bin/python] [Command finished with exit code 1]

Figure 13: Failure Case of Hallucination. The SE agent fails due to hallucinating actions or experiences.

20

A.2

Preliminary Exploration on Memory Structure

Which memory structure can most effectively benefit SE agents? The answer to this critical question informs the effective design of memory representation, shaping how memory is constructed, formatted, and evolved within memory-augmented frameworks. To investigate this question, we conduct a preliminary study on memory structures, examining the impact of nine different memory structure settings on the performance of memory-augmented SE agents: ❶ String: Represent memory as a simple textual string, showing information in a linear format. ❷ Dictionary: Represent memory hierarchically using a JSON dictionary, where keys categorize high-level information and values store details. ❸ List: Represent memory as an ordered JSON list, showing elements in sequence. ❹ Tree: Represents memory in a tree-like structure, displaying parent-child relationships between concepts or items. ❺ Graph: Represents memory as a graph-like structure, capturing relationships and connections between multiple elements. ❻ Python: Represents memory using Python code, enabling structured representation and potential implementation. ❼ Given: Represents memory using a fixed hierarchical structure with predefined fields and categories. ❽ Discretionary: Represents memory in a flexible format determined by the model, allowing adaptation to different types of information or structural arrangements. ❾ Ours: Represents memory in a markdown-based structured format Memory.md, integrating key knowledge and information into hierarchical organization. Concretely, we employ GPT-4o-mini to power the SE agent, and GPT-4o as Mθ to learn from past experiences and generate memory instances. Both baseline setting (without memory) and memory-augmented setting (with memory) SE leverage the same test set that comprises 30 instances randomly sampled from SWE-Bench-Verified (Jimenez et al., 2024). The SE agent is allowed a maximum of 20 interaction turns to complete each task. To isolate the fundamental effects of each memory structure, all experiments are performed under the single-episode mode (§4.1). As the 20turn limit results in SR = 0% across all settings, we evaluate SE performance using full localization (−1) (−1) accuracy LAf (Eq. 5) and full efficiency LEf (Eq. 7). Table 3 summarizes the evaluation results across all settings. Compared with the no-memory baseline, all nine memory structures are able to improve SE agent’s performance in terms of localization accuracy and efficiency. Surprisingly, allowing the model to decide memory structures autonomously results in relatively modest improvements (∆abs ≤ 16.66%), indicating limited adaptive memory reflection and evolution abilities in LLMs. On the other hand, highly structured formats, such as dictionaries (∆abs ≥ 14.85%) and Python code (∆abs ≥ 16.76%), lead to substantial gains, while the memory structure of MemOp delivers the most pronounced improvement (∆abs ≥ 17.65%), especially in localization accuracy (∆abs ≥ 20.10%), which is an essential prerequisite for successful SE problem-solving. This finding suggests a fundamental design principle: Memory structures that are easier for the SE agent to understand are also more effective. A.3

Preliminary Exploration on Memory Generation Instructions

Following the memory principle (§A.2), generating effective memory faces a key challenge: How to instruct Mθ to perform memory generation and evolution more effectively? Both memory generation and memory evolution critically depend on high-quality reflection and distillation. In long-horizon software engineering (SE) trajectories characterized by diverse actions, execution outputs, environmental feedback, intermediate reasoning, etc., it is critical for Mθ to continuously identify salient structures, extract reusable knowledge, capture useful patterns, and distill key insights. However, without explicit guidance, Mθ struggles to distinguish essential information from incidental details (Figs. 14-15), leading to suboptimal memory construction. Therefore, the central problem is how to guide Mθ to conduct reliable and effective learning and reflection over complex, multi-step software engineering processes. 21

To investigate this question, we conduct a preliminary study on the behaviors of Mθ under different memory generation instructions. Specifically, we examine three types of prompts with increasing levels of guidance: ❶ Concise Instruction Without Targeted Requirements is designed to assess and expose the intrinsic reasoning and reflection capabilities of LLMs in the absence of external guidance, allowing us to uncover their inherent limitations and typical failure modes in memory generation. ❷ High-Level Instruction delineates the categories of information that should be prioritized for reflection and retention, while explicitly indicating non-essential content to be excluded. This formulation introduces principled constraints on the scope of reflection and distillation without prescribing a rigid structure, thereby encouraging structured yet flexible abstraction. ❸ Fine-Grained Instruction imposes explicit structural and content-level requirements on memory generation, supplemented with illustrative examples. This setting provides detailed operational specifications intended to standardize the abstraction process and reduce ambiguity in what constitutes high-quality memory. Fig. 15 presents these three versions of memory generation instructions: (1) general and concise, (2) high-level instruction, and (3) fine-grained instruction. Results in Fig. 14 reveal clear differences in memory quality across these settings. Understandably, instruction (1) yields the lowest memory quality. In the absence of explicit criteria or structural constraints, Mθ lacks a principled mechanism for reliably identifying what is worth memorizing and what should be reflected on to distill reusable knowledge. As a result, the generated memory tends to be overly generic, fragmented, or populated with low-value operational details and transient context. This uncovers the inherent weaknesses of LLMs in unguided memory construction, especially their limited ability to accurately identify important information and to effectively reflect upon and distill useful insights. Based on the failure analysis of Instruction (1) (Fig. 15 (1)), we define Instructions (2) and (3), which are able to provide more effective guidance, enabling Mθ to better differentiate between critical insights and peripheral information. By explicitly outlining what to focus on and what to disregard, they guide Mθ toward more task-relevant reflection and knowledge organization. Among all three variants, instruction (2) exhibits the optimal guidance. This result reveals that high-level guidance strikes an effective balance: It offers sufficient direction to mitigate the intrinsic weaknesses observed in setting (1), while still preserving flexibility for Mθ to generalize and distill across diverse software engineering repositories and scenarios. In comparison, instruction (3), although more detailed, can inadvertently over-constrain the reflection process or bias the model toward rigid compliance with specified formats and examples, potentially limiting broader abstraction. These findings suggest that identifying the intrinsic deficiencies of LLMs in unguided reflection is essential for designing effective memory generation instructions. Simply relying on intrinsic reasoning or over-specified details is insufficient, whereas carefully designed high-level guidance can substantially enhance memory generation and evolution to benefit long-horizon agentic SE.

Figure 14: Preliminary Study on Memory Instruction. In addition to qualitative analysis (Fig. 15), we summarize the quantitative results of three instructions (§A.3). 22

23

24

25

Figure 15: Memory Instruction. We conduct the preliminary study on memory reflection through three versions of instructions: (1) general and concise instruction, (2) high-level instruction, and (3) fine-grained instruction.

26

Figure 16: Repo-Wise Comparison between Baseline and MemOp. Compared to no-Mθ baseline SE agent (base LLM: Qwen3-Coder-30B-A3B), SE agent (base LLM: Qwen3-Coder-30B-A3B) with MemOp (backbone LLM: Qwen3-4B-T) consistently outperforms no-Mθ baseline across nine disparate repositories.

27

B

Related Work: Extended Discussion

We extend our discussion in §5 with additional related work that has emerged concurrently with MemOp, further contextualizing our contributions. B.1

Memory for SE Agents

Recent work has begun to explore memory augmentation, specifically in the context of software engineering agents. SWE-Bench-CL (Joshi et al., 2025) introduces a continual learning benchmark that organizes GitHub issues into chronologically ordered sequences to evaluate knowledge accumulation and transfer across tasks. However, it proposes no mechanism for how to optimize memory, leaving the core methodological challenge open. In addition to benchmark challenges, recent work on subtask-level memory (Shen et al., 2026) addresses retrieval granularity by aligning memory storage and retrieval with the SE agent’s functional decomposition, yet relies on heuristic designs without principled optimization signals or evaluation criteria. CTIM-Rover (Lindenbauer et al., 2025) further proposes a Mixture-Of-Experts (MoEs) inspired approach for SE agents, but finds that unfiltered memory retrieval introduces noise that actively degrades performance. This further highlights the fragility of existing approaches: without a principled utility signal to distinguish beneficial memories from noise, memory augmentation can actively harm agent performance. We propose MemOp to directly address this failure mode by grounding memory utility in validated downstream impact, providing both principled evaluation criteria and annotation-free optimization signals that close the loop between memory generation and memory quality, without relying on complex retrieval heuristics or task-specific designs. B.2

Broader Use of Memory

Memory augmentation for general LLM agents has been explored along several directions. One line of work augments agents with retrieval-based memory, where past experiences or contextual knowledge are stored and retrieved to support downstream generation (Qian et al., 2025; Chen et al., 2025; Wang et al., 2024). Across these approaches, a shared limitation persists: memory quality is assessed through proxy signals, such as retrieval similarity, coverage, or structural coherence, without empirical validation. Lacking such a principled utility signal, these systems fail to reliably distinguish memory that improves agent behaviors from memory that is redundant or harmful. A different line of work evolves memory through heuristic update rules, such as recency, novelty, similarity, or psychologically inspired forgetting schedules (He et al., 2024; Zhong et al., 2023; Salama et al., 2025). While these rules offer intuitive appeal, they are designed without downstream grounding, leaving memory evolution disconnected from the outcomes it is meant to support. Another direction organizes memory through hierarchical (Sun et al., 2026; Hu et al., 2025) or graph-based (Atri et al., 2025; Kashmira et al., 2025) structures, which improve interpretability but cannot adapt to the diversity of tasks encountered in practice. To address these limitations, MemOp defines memory utility as demonstrated causal improvement grounded in downstream performance (§2), deriving a principled, annotation-free optimization signal (§3) that is transferable across agents and generalizable across tasks and settings (§4).

C

Limitations

In this work, we introduce MemOp (§2), a closed-loop framework with performance-grounded memory utility serving a dual role (§1-3), enabling principled evaluation and annotation-free optimization of memory-augmented SE agents across single-episode and cross-episode settings (§3.4). Nevertheless, we acknowledge several limitations that we aim to address in future work. First, due to the high cost of extensive experiments, our work is evaluated primarily on Python repositories with GitHub issue-style tasks. Therefore, we view cross-benchmark validation as a natural and important next step. Second, as we focus on memory optimization, factors influencing performance include the intrinsic problem-solving abilities and behaviors of the SE agent. For example, if the agent consistently fails to explore relevant parts of the codebase, the resulting memory will reflect those blind spots while showing less informative guidance on best practices (§G), revealing the need for enhancing the intrinsic problem-solving abilities of SE agents themselves that we aim to address in future work. Third, as detailed in §F, the dataset size and computational efficiency of training 28

dataset curation are sensitive to rollout configuration, requiring configuration choices in custom use. In future work, we aim to extend MemOp to broader benchmarks and programming languages, and explore tighter integration between memory optimization and SE agent training to further improve problem-solving performance.

D

Broader Impact

MemOp advances memory-augmented AI software engineering, with the potential to meaningfully improve developer productivity and software quality (§G.4). By enabling SE agents to learn from past problem-solving experience and apply distilled knowledge to future tasks (§2), MemOp reduces the number of iterations required to resolve issues and increases the success rate of task resolution across single-episode and cross-episode settings (Tabs. 1-2). These efficiency gains could meaningfully lower the barrier to deploying automated AI software engineering agents in real-world tasks, particularly for open-source projects with limited human contributor bandwidth. Moreover, MemOp operates exclusively on the publicly available benchmark (§4.1), and does not involve additional collection of private codebases, user data, or personally identifiable information, thereby excluding privacy and data security concerns.

29

Figure 17: Instructions for Single-Episode and Cross-Episode Memory Generation. Our memory generation instructions for single-episode and cross-episode memory-augmented software engineering settings.

30

E

Dataset Construction for MemOp Optimization

Based on our trajectory-based rejection sampling (Alg. 1), we construct our memory optimization dataset via performance-validated memory supervision (§3.2). We begin by randomly sampling NT = 100 tasks across NR = 10 repositories, yielding NT × NR = 1, 000 tasks in total. Then, we deploy SE agents powered by Devstral-Small-2505 and Qwen3-Coder-480B-A35B-Instruct, respectively, with each executing these 1, 000 tasks. During trajectory-based rejection sampling (Alg. 1), we set Nτ = 4 and NM = 4, contributing to 3, 200 memory candidates. After performance filtering, the remaining samples form our curated memory optimization dataset for two-stage MemOp finetuning (Tab. 4). During experiments, to avoid evaluation circularity, we randomly sample 100 evaluation instances that have no overlap with the 100 instances used to construct our training dataset. In cross-episode evaluation, all instances of each repository are evaluated according to their temporal order to simulate real-world codebase evolution. As shown in Fig. 18, the 100 evaluation instances are distributed evenly across repositories to support reliable cross-episode evaluation. We assign django twice as many instances as it constitutes a primary portion of SWE-bench, while there is no 10th repository that reaches 10.00% of the total instances as others. This prevents any smaller repository from being overrepresented, thereby maintaining a balanced evaluation distribution.

Figure 18: Evaluation Set Distribution

Table 4: Training Data Overview. Summarization of training datasets in SFT and RL, constructed through trajectory-based rejection sampling (§3.2). NR DSFT

10

DPref (c = 2) DPref (c = 4)

10 10

F

Implementation Details

F.1

Memory Generation Instructions

Train SFT 2516 RL 1908 1310

Test

Total

280

2796

214 146

2122 1456

Supported by our preliminary studies (§A), the memory generation instruction prompts we used for single-episode and cross-episode memory generation are shown in Fig. 17.

F.2

Experiment Configuration

Our experiments involve various configuration settings in different stages. We summarize the key configurations during trajectory rollout, memory model finetuning, and performance evaluation in Tab. 5 to provide a clear and reproducible overview of our experimental setup. 31

Table 5: Experiment Configuration. This table summarizes the key configuration settings during dataset construction, supervised finetuning, reinforcement learning, and SE evaluation. NR , NT , Nτ , and NM denote the number of repositories, the number of tasks for each repository, the number of trajectories per task, and the number of memory candidates per trajectory, respectively. The number of evaluation metrics used to measure SE agent performance is set to NQ = 10 in both dataset construction and performance evaluation, complemented by ∆abs (Eq. 8) and ∆rel (Eq. 9) to quantify performance differences. For model finetuning, the learning rate is represented by lr, nepoch denotes the number of training epochs. During RL, nrollout denotes the number of rollouts, and c denotes the batch size of preference rollout in DRL (§3.3). Stage

NR

NT

NM

NA

NQ

lr

nepoch

nrollout

c

Construction SFT RL Evaluation

10 – – 9

10 – – 10

4 – – 1

4 – – 4

100 – – 100

10 – – 10

– 1 × 10−4 1 × 10−6 –

– 1 1 –

– – 4 –

– – 2/4 –

F.3

Computation Overhead

During dataset construction, we leverage LLM APIs to power both SE agents and Mθ . For model finetuning, the memory model is optimized through our two-stage training paradigm (§3.3) consisting of supervised finetuning and reinforcement learning. During evaluation, we use LLM APIs to support SE agents, while employing our finetuned memory models to instantiate Mθ . For computational resources, we use NVIDIA H100 (80GB) GPUs to serve and train LLMs. To provide a clear accounting of computation resources, we summarize the resource overhead for dataset construction, model finetuning, and performance evaluation in Tab. 6, and compare the computational time and efficiency across single-episode and cross-episode memory augmentation in Fig. 22.

Table 6: Computation Overhead. This table summarizes the API cost (averaged to per 100 instances) and computation overhead during training and evaluation. nM LLM denotes the number of different backbone MLLMs. During dataset construction, Mθ is used exclusively for memory candidate generation while does not perform any memory optimization, and the additional cost of SE agent w/ Mθ arises solely from Nτ × NM = 4 × 4 = 16 rollouts. Stage

API ($)

LLM

Computation (H100)

w/o Mθ

w/ Mθ

SE Agent

Construction

Devstral-Small Qwen3-Coder-480B Claude-4-Sonnet

11.73 86.18 –

43.52 329.98 53.89

– – –

– – –

SFT RL

– –

– –

– –

– –

80GB × 2 80GB × 4

Evaluation

Devstral-Small Qwen3-Coder-30B

11.73 9.97

10.26 8.94

– –

80GB × 1 80GB × 1

G

A Deeper Dive Beneath Results

We extend our experiments (§4) to in-depth analysis (§G), covering repository-wise generalizability (§G.1), memory evolution levels (§G.2), configuration effects of rollout batch size c in DRL (§G.3), and qualitative analysis (§G.6). 32

Figure 19: MemOp for Memory-Augmented Software Engineering. MemOp finetunes Mθ to augment SE agents through adaptive memory generation (§2.3 & §G.2). Our ablation studies include single-episode memory generation, episode-level memory evolution (§4), and action-level memory evolution (§G.2).

G.1

Repository-Wise Generalizability of MemOp

Extending our discussion in §4.3, Fig. 16 showcases consistent performance enhancement of MemOpaugmented SE agents, showcasing up to ∆abs =↑ 17.50% in SR and ∆abs =↑ 15.00% in LA. Only four degraded performance on localization efficiency and accuracy among 90 comparisons further demonstrates the robustness of MemOp when generalized to different repository contexts. G.2

Why Episode-Level over Action-Level Memory Evolution?

Determining the appropriate granularity of memory evolution is critical for balancing SE efficiency and memory optimization effectiveness. On this account, a key question is (Fig. 19): Should memory evolve at the action level or the episode level? To investigate this fundamental question, we employ Qwen3-Coder-30B-A3B to power SE agent, with MemOp using Qwen3-4B-T as Mθ backbone. We evaluate memory-augmented software engineering on the same test set under both action-level and episode-level memory evolution, respectively. As shown in Fig. 20, MemOp with episodelevel evolution yields reduced overhead in crossepisode settings (∆rel =↓ 2.23%). In con- Figure 20: Memory Evolution Granularity. We trast, action-level memory evolution severely de- compare SE agent performance among no-Mθ , grades efficiency, requiring up to ×11.82 more MemOp in cross-action, and MemOp in crosstime on average to solve SE tasks. More impor- episode memory evolution settings. tantly, this inefficiency is accompanied by a substantial drop in success rate (∆abs =↓ 12.50%), as compared to the improved success rate (∆abs =↑ 2.75%) of MemOp in cross-episode memory evolution. These results highlight that episode-level memory evolution provides a more favorable optimization for both efficiency and effectiveness, making it a better design choice for memoryaugmented SE agents. 33

G.3

Effects of Preference Batch Size on Memory Optimization

To investigate the effect of rollout batch size c in DRL (§3.2), we compare SE agent performance with Mθ using the same backbone LLM (Qwen3-4B-Thinking), finetuned on DRL with c = 2 and c = 4, respectively. Results in Fig. 21 demonstrate consistent gains from Stage II finetuning across different values of c, consistent with the effectiveness of Stage II observed in Fig. 4 (§4.3). Notably, c = 4 presents more robust and comprehensive Mθ optimization effects across ten metrics (e.g., c = Figure 21: Effects of Preference Rollout Batch Size Configura2 with ∆abs ≤ 0.75% in SR, as tion on Mθ Optimization. compared to c = 4 with ∆abs ≥ 2.25% in SR). G.4

MemOp for Improved SE Efficiency

Extending our study in (§G.2), we mploy Qwen3-Coder-30B-A3B to power SE agent, with MemOp using Qwen3-4B-T as Mθ (FT) backbone. Fig. 22 compares the average computational time used per task, SR, and Eresolve among no-Mθ baseline, single-episode MemOp, and crossepisode MemOp. Across both settings, MemOp showcases consistently improved task success rate and problem-solving efficiency while reducing computational cost, demonstrating that MemOp meaningfully enhances SE agent performance without sacrificing efficiency.

Figure 22: MemOp Improves SE Performance with Reduced Computational Cost. MemOp enhances SE agent across single-episode and cross-episode settings with reduced computational cost. G.5

MemOp for More Robust Software Engineering

To systematically compare the augmentation effects of MemOp, we use Qwen3-Coder-30B to power the SE agent with Qwen3-4B-T as the memory backbone of finetuned Mθ , and compare their mean performance and variance across all ten evaluation metrics (§3.1). As shown in Fig. 23, MemOp consistently achieves higher mean performance across all accuracy and efficiency metrics, while exhibiting notably tighter variance bands, particularly on localization accuracy (Fig. 23, left), as compared to the no-Mθ baseline that shows substantially wider performance spread across rollouts. 34

This suggests that MemOp not only improves average SE agent performance but also stabilizes problem-solving behaviors, reducing sensitivity to the stochasticity inherent in long-horizon agentic software engineering trajectories.

Figure 23: MemOp Enhances SE Agent Performance Robustness. Error bars across all evaluation metrics demonstrate that MemOp consistently improves SE agent performance with reduced variance, reflecting greater robustness over the no-Mθ baseline. G.6

Qualitative Analysis on Memory Augmentation Success & Failure

To better understand the effectiveness of Mθ in memory generation and evolution, we conduct case studies to qualitatively examine memory examples generated by MemOp-finetuned Mθ , analyzing their strengths in successful memory augmentation as well as their limitations in cases where SE agents fail, in hopes of meaningfully informing future research. Effective Memory Augmentation Examples (∆abs > 0 across all metrics). Fig. 24 shows a few examples of high-quality memory generation, where generated memories effectively enable the SE agent to successfully resolve the task with improved problem-solving efficiency. As shown in these examples, good memories are able to maintain a high level of abstraction, enhancing their applicability and generalizability for more adaptive problem-solving across different SE scenarios. Moreover, their effective distillation of repository structure, key patterns, and workflows allows the SE agent to quickly familiarize itself with the codebase and start problem-solving attempts with the support of best practices and informative insights. Ineffective Memory Augmentation Examples (∆abs ≤ 0 in SR). In contrast to effective memory augmentation (Fig. 24), ineffective memory reflection and distillation can misdirect the SE agent toward unproductive exploration and ultimately lead to task failure. Examples shown in Fig. 25 unveil several common issues: over-specific details, insufficient reflective synthesis, overly taskbound patterns, misdirected focus on suboptimal information, as well as repetitive and redundant content. Compared to successful examples (Fig. 24), effective memories emphasize codebase-level abstractions rather than task-specific details, underscoring the significance of distilling key structures, generalizable patterns, and actionable insights for memory-augmented software engineering.

35

36

37

Figure 24: Examples of Effective Memory Reflection. The generated memories effectively support SE agent to successfully resolve the task with enhanced problem-solving efficiency. Examples extracted from SE agent powered by Qwen3-Coder-30B-A3B and MemOp with Mθ powered by Qwen3-4B-T (FT). Trajectory history details are omitted as [...] for clarity. 38

39

40

Figure 25: Examples of Ineffective Memory Reflection. The generated memories fail to effectively support SE agent. Examples extracted from SE agent powered by Qwen3-Coder-30B-A3B and MemOp with Mθ powered by Claude-4-Sonnet (NFT). Trajectory history details are omitted as [...] for clarity. 41

Related documents

Record · ID 259546 · SHA-256 8992985441f24eea
Retrieved via Conceptio — every document is proof-bundled with source, license, and retrieval metadata.