Executive Summary
Current AI software engineering agents struggle with long-horizon reasoning because they remember past projects as monolithic blocks. This leads to a "granularity mismatch," where surface-level similarities between tasks trigger the retrieval of irrelevant memories. This paper introduces Structurally Aligned Subtask-Level Memory, a novel architecture that breaks down agent experiences into functional stages (e.g., analyzing, editing, verifying) to provide precise, stage-specific guidance. By aligning memory with the agent's functional workflow, this approach improves performance on the SWE-bench Verified benchmark by an average of 4.7 percentage points, with even higher gains on complex, long-horizon tasks.
The Problem: Granularity Mismatch in Agent Memory
Building autonomous software engineering (SWE) agents requires more than just code completion; it demands long-horizon reasoning across entire repositories. While researchers have augmented agents with "memory" of past tasks, most systems operate at an instance-level. They store and retrieve entire problem-solving episodes based on how similar the global issue description is to the current one.
The authors identify a fundamental flaw in this approach: granularity mismatch. This mismatch manifests in two primary ways:
- False Positives: Issues like "Fix Login Button" and "Fix Login Timeout" sound similar globally. However, the former is a frontend UI fix, while the latter is a backend or database issue. Retrieving the "Button" fix for a "Timeout" problem provides misleading guidance.
- False Negatives: "Modify Search Bar" and "Fix Login Button" are globally dissimilar, yet they might share the exact same subtask, such as updating a frontend event listener. Instance-level memory misses these reusable micro-skills.
Structurally Aligned Subtask-Level Memory
To resolve this mismatch, the authors propose a memory architecture that aligns with the agent’s functional workflow. Instead of storing an entire "project," the system stores "subtasks."
- Subtask Modeling: The reasoning process is partitioned into functional categories. For bug fixing, these are
ANALYZE,REPRODUCE,EDIT, andVERIFY. - Structured Memory Entries: Each memory entry is stored as a triple: $(z, d, e)$.
- $z$ (Category): The functional label (e.g.,
EDIT). - $d$ (Intent): A structured description of the specific sub-goal and relevant keywords.
- $e$ (Experience): Actionable insights distilled from the trajectory, stripped of instance-specific noise like local file paths.
- Two-Stage Retrieval: When an agent starts a subtask, it first applies a Category Filter (a hard constraint) to ensure it only retrieves memories from the same functional stage. It then performs Semantic Matching to find the most relevant intent within that category.
- Experience Extraction: After completing a subtask, an LLM-based "Extractor" processes the raw execution logs to summarize transferable lessons, which are then added to the memory bank.
Key Insights and Results
The primary evaluation was conducted on SWE-bench Verified, a rigorous benchmark of 500 real-world GitHub issues, with additional testing on FEA-Bench Lite to demonstrate flexibility beyond bug fixing.
Performance Gains Across Models
The method was tested across four major LLM backbones, showing consistent improvements over vanilla agents:
- Gemini 2.5 Pro: +6.8 percentage points (pp) improvement.
- Gemini 2.5 Flash: +5.6 pp improvement.
- Claude 3.7 Sonnet: +3.9 pp improvement.
- Average Improvement: Across all models, the subtask-level memory improved the "Pass@1" rate by +4.7 pp.
Unlike instance-level memory, which sometimes degraded performance due to noisy retrievals, the subtask-level approach stabilized performance and reduced run-to-run variability.
Why It Works
- Global Similarity is a Trap: The paper proves that surface-level resemblances in issue descriptions often mask distinct underlying logic. Forcing memory to be "category-isolated" prevents cross-stage noise.
- Abstraction is a Noise Filter: Simply storing raw interaction logs only provided a +1.2% boost. Using an LLM to abstract those logs into generalizable insights provided a +3.9% boost, confirming that raw details (like specific file paths) act as noise.
- Harder Tasks Benefit More: The memory system provided a massive +8.7% boost on "Hard" tasks (those requiring >28 steps). It acts as a computational shortcut, preventing the agent from getting lost in long trial-and-error loops.
- The "Cold Start" Effect: The authors observed a slight performance dip in the first 200 tasks as the agent incurred retrieval overhead without a rich memory bank. However, as the memory state populated (tasks 301-500), the system exhibited "accelerated knowledge transfer," and gains jumped significantly.
Limitations and Future Work
- Task-Specific Taxonomy: The current categories are tailored for bug fixing. While adaptable (e.g., to
DESIGN/IMPLEMENTfor feature requests), the system still requires a predefined functional decomposition. - LLM Extractor Reliability: The system relies on an LLM to accurately distill experiences. If the extractor produces causally incorrect or overly specific abstractions, it introduces noise.
- Memory Maintenance: The current implementation is append-only. As memory banks grow to thousands of entries, future research must explore forgetting mechanisms for rarely used memories and more scalable indexing.
- Signal Dependency: The evaluation focused on tasks with clear executable correctness signals (like unit tests). Applying this framework to more ambiguous engineering tasks remains an open challenge.
Summary updated