TL;DR
MemOp is a closed-loop framework that optimizes memory for large language model (LLM) software engineering (SE) agents based on actual downstream performance. By treating memory utility as an optimizable signal rather than a hand-crafted prompt, MemOp achieves up to a 5.25% absolute gain in task success rate and a 4.63% boost in efficiency while cutting computational costs by over 9.79%.
What Problem Does This Paper Address?
Modern LLM-powered SE agents can navigate complex codebases and fix bugs, but they are fundamentally episodic. They approach every new task from scratch, repeatedly reconstructing context, rediscovering codebase structures, and making the same mistakes across different problems.
While adding a "memory" component seems like an obvious fix, existing approaches suffer from a major flaw: they lack a principled definition of memory utility. Current systems rely on hand-crafted heuristics or proxy metrics (like retrieval similarity) to decide what to remember. Unfiltered or poorly optimized memory often introduces noise, distracts the agent, and balloons token costs.
Methods
The core philosophy of MemOp is simple: If a memory doesn't help downstream performance, it doesn't count. The authors transform memory from a static prompt artifact into an optimizable component through two key innovations:
- Memory Utility as a Dual Harness: MemOp establishes a formal acceptance criterion based on 10 multi-dimensional metrics (including Success Rate, Localization Accuracy, and Resolve Efficiency). A candidate memory is accepted if and only if it causally improves or maintains performance across all metrics, with a strict improvement in at least one.
- Closed-Loop Memory Optimization:
- Trajectory-Based Rejection Sampling: The system runs agent rollouts, generates candidate memories, and filters them through the acceptance criteria to automatically curate high-quality training datasets without human annotation.
- Two-Stage Training: A dedicated memory model ($M_\theta$) is first trained via Supervised Fine-Tuning (SFT) to generate structured reflections (
Memory.md). It is then optimized via Reinforcement Learning (RL) with Preference Optimization (using algorithms like GRPO or DAPO) to maximize the downstream reward of the agent.
The framework is evaluated under two regimes: Single-Episode (immediate reuse of memory from a single task) and Cross-Episode (progressive memory evolution and refinement across a sequence of tasks).
Datasets
The authors utilized SWE-Bench-Verified for both dataset curation and evaluation:
- Training Data: 100 tasks across 10 repositories were sampled. Agents powered by Devstral-Small and Qwen3-Coder generated 3,200 trajectories, which were filtered into an SFT dataset (2,796 samples) and an RL preference dataset.
- Evaluation Data: 100 non-overlapping instances across 9 repositories were used to test the models, ensuring zero data contamination.
Key Insights and Ideas
- Naïve Memory is Harmful: Simply throwing past trajectories or unguided summaries into an agent's context window (Non-Finetuned Memory, or NFT) consistently degraded performance. Without optimization, memory acts as distracting noise.
- Structure is Essential: In preliminary testing, allowing the model to choose its own memory format yielded poor results. Highly structured formats—specifically the markdown-based
Memory.mdstructure designed in this paper—are significantly easier for SE agents to comprehend and utilize. - Episode-Level > Action-Level Evolution: Trying to update an agent's memory after every single action step severely degrades efficiency (making problem-solving up to 11.82x slower) and tanks the success rate. Evolving memory at the end of an entire task episode provides the optimal balance of effectiveness and speed.
Key Results
MemOp was tested using multiple backbone models (including Qwen2.5, DeepSeek-R1, and Qwen3 variants) acting as the memory model for base SE agents.
- Performance Gains: In single-episode settings, MemOp achieved absolute gains of up to $\uparrow$5.25% in Success Rate (SR) and $\uparrow$4.63% in Resolve Efficiency. Finetuned small memory models (like Qwen3-4B-T) frequently outperformed commercial giants like Claude-4-Sonnet.
- Cross-Episode Evolution: In sequential task environments, MemOp maintained robust adaptability, boosting success rates by up to $\uparrow$3.00% and localization accuracy by $\uparrow$3.17%.
- Cost and Variance Reduction: Because optimized memories helped agents pinpoint bugs faster, the number of required interaction loops dropped. This led to a relative computational cost reduction of $\geq$9.79% and significantly tighter performance variance bands, stabilizing agent behavior against stochasticity.
Limitations and Future Work
- Scope of Evaluation: The framework was primarily validated on Python repositories using GitHub-style issue tasks. The authors note that cross-benchmark and multi-language validation is an essential next step.
- Exploration Blind Spots: The quality of the generated memory is fundamentally bounded by the base agent's capability. If an agent fails to explore the correct parts of a codebase during a task, the resulting memory will inherently contain blind spots.
- Configuration Sensitivity: The dataset curation process is highly sensitive to rollout configurations (e.g., batch sizes and thresholds), requiring careful tuning for custom implementations.
Summary updated