Structurally Aligned Subtask-Level Memory for Software Engineering Agents
Abstract
Large Language Models (LLMs) have demonstrated significant potential as autonomous software engineering (SWE) agents. Recent work has further explored augmenting these agents with memory mechanisms to support long-horizon reasoning. However, these approaches typically operate at a coarse instance granularity, treating the entire problem-solving episode as the atomic unit of storage and retrieval. We empirically demonstrate that instance-level memory suffers from a fundamental granularity mismatch, resulting in misguided retrieval when tasks with similar surface descriptions require distinct reasoning logic at specific stages. To address this, we propose Structurally Aligned Subtask-Level Memory, a method that aligns memory storage, retrieval, and updating with the agent’s functional decomposition. Extensive experiments on SWE-bench Verified demonstrate that our method consistently outperforms both vanilla agents and strong instance-level memory baselines across diverse backbones, improving mean Pass@1 over the vanilla agent by +4.7 pp on average (e.g., +6.8 pp on Gemini 2.5 Pro). Performance gains grow with more interaction steps, showing that leveraging past experience benefits long-horizon reasoning in complex software engineering tasks.
Lay Summary
Large language models are increasingly used as software engineering agents that can inspect code, run commands, edit files, and test their own fixes. A key challenge is that these agents often need to learn from past tasks, but existing memory methods usually store an entire previous problem-solving attempt as one memory. This can be misleading: two software issues may look similar overall but require very different debugging steps, while two different issues may share the same useful editing or testing pattern. We propose a memory method that stores experience at the level of smaller functional steps, such as analyzing the problem, reproducing the bug, editing the code, and verifying the fix. When the agent works on a new task, it retrieves memories that match its current step rather than only the overall issue description. Experiments on real repository-level software tasks show that this more targeted memory helps agents solve more issues, especially on harder tasks that require longer interactions. Our results suggest that future software agents can benefit from remembering not just whole past tasks, but the specific reasoning steps that made those tasks succeed.