Source-linked AI summary

Structurally Aligned Subtask-Level Memory for Software Engineering Agents

Kangning Shen, Jingyuan Zhang, Chenxi Sun, Wencong Zeng, Yang Yue

arXiv:2602.21611v1cs.SEcs.AI

TL;DR

Instance-level memory can misalign with software engineering subtasks because similar surface symptoms may require different reasoning paths, while related subtasks may be reusable across dissimilar tasks. The paper proposes structurally aligned subtask-level memory and finds consistent gains over vanilla agents and instance-level baselines, including +4.7 pp mean Pass@1 improvement and stronger benefits with more interaction steps.

  • Problem

    Instance-level memory has a granularity mismatch with compositional software engineering, where global similarity can miss stage-specific reasoning needs.

  • Method

    Structurally aligned subtask-level memory aligns memory storage, retrieval, and updating with the agent’s functional decomposition of trajectories.

  • Results

    Across four backbones on SWE-bench Verified, the method consistently outperforms vanilla agents and instance-level baselines, improving Pass@1 over vanilla agents by +4.7 pp on average and up to +6.8 pp on Gemini 2.5 Pro.

  • Takeaways & Limitations

    Performance gains become more pronounced as interaction steps increase, indicating that past experience is particularly beneficial for long-horizon reasoning in complex software engineering tasks.

  • Takeaways & Limitations

    The contextual retrieval formulation uses a fixed embedding model.

Abstract

from arXiv · show

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.

1. Introduction

Software engineering agents solve repository-level issues through heterogeneous subtasks, but instance-level memory retrieves by global similarity, which can misalign with stage-specific reasoning. Structurally Aligned Subtask-Level Memory stores, retrieves, and updates experience at the subtask level, improving results on SWE-bench Verified.

  • Repository-level software engineering tasks involve heterogeneous subtasks including problem analysis, bug reproduction, fault localization, code editing, and validation.
  • Instance-level memory treats entire problem-solving episodes as storage and retrieval units, relying on global task similarity.
  • Global similarity can mislead reasoning when surface-similar issues require different paths, such as frontend logic versus backend or database debugging.
  • Subtask-level retrieval also recovers reusable operations across globally dissimilar tasks, which instance-level memory may miss.
  • The proposed method models reasoning as discrete functional subtasks and maintains fine-grained entries containing category, localized intent, and abstracted experience.
  • +4.7 pp average Pass@1 improvement over the vanilla agent was achieved across four backbones, reaching +6.8 pp on Gemini 2.5 Pro.

2. Related Work

Related work has advanced repository-level software engineering agents and memory mechanisms that reuse prior experience. The proposed method builds on this landscape by organizing memory around functional subtasks rather than whole episodes.

  • SWE-bench evaluates whether language models can resolve real-world GitHub issues, motivating increasingly practical software engineering agents.
  • Software engineering memory systems distill prior trajectories into reusable lessons or construct repository-anchored memory for test-time reuse.
  • The method’s overview contrasts subtask-aligned retrieval and updating with instance-level approaches.

3. Method

The method decomposes software-engineering trajectories into functional subtasks and aligns memory retrieval and updating with those units. It stores structured experiences, retrieves category-matched guidance, and incrementally updates memory after each subtask.

  • Task Formulation and Structural Alignment: Software-engineering trajectories are modeled as sequences of reasoning-aligned subtasks rather than flat interaction histories.Each subtask corresponds to a discrete functional unit within the overall trajectory.
  • Task Formulation and Structural Alignment: Memory is retrieved and updated on decomposed subtasks π(k), matching the functional granularity of the agent’s reasoning.This replaces monolithic instance-level trajectories as the basic memory unit.
  • Subtask Modeling via Dynamic Segmentation: Subtasks use functional categories such as ANALYZE, REPRODUCE, EDIT, and VERIFY, with transitions predicted during the interaction stream.The agent predicts the next category and description when a reasoning phase concludes.
  • Subtask Modeling via Dynamic Segmentation: Each subtask intent combines a functional category with a structured description containing an objective and mechanism-level keywords.The associated trajectory segment records execution for that localized intent.
  • Structured Memory State: Memory entries store a category, localized description, and abstracted experience, retaining actionable patterns rather than instance-specific logs.The experience extractor distills each subtask trajectory and filters information into transferable guidance.
  • Contextual Retrieval and Experience Accumulation: At each subtask’s start, retrieval filters entries by category before semantic matching, then injects the selected experience into the initial context without parameter updates.After completion, the system extracts and appends a new subtask entry, enabling online accumulation of experiences.

4. Experiments

Experiments on SWE-bench Verified show that subtask-level memory consistently improves performance and robustness across backbones, especially on complex long-horizon tasks. Ablations and case studies attribute the gains to category-isolated retrieval, abstracted insights, and accumulated experience.

  • Main Results: Across four backbones, subtask-level memory improves Pass@1 by +4.7 pp on average and remains consistent across models and random seeds.The method improves lightweight Gemini 2.5 Flash by +5.6 pp and frontier Claude 4.0 Sonnet by +2.3 pp.
  • Main Results: Instance-level memory degrades Claude 3.7 Sonnet from 52.2% to 51.1% and leaves Claude 4.0 Sonnet nearly unchanged, whereas subtask-level memory outperforms it across all models.The Claude 3.7 Sonnet baseline also shows high variance of ±2.27.
  • Ablation Studies: The full method delivers +3.9% over Vanilla, while structured prompting alone yields only +1.0%, indicating that retrieved experience supplies the decisive improvement.The structural scaffold primarily functions as an alignment index for retrieval in this ablation.
  • Ablation Studies: Category-isolated retrieval achieves +3.9% over Vanilla, exceeding global retrieval's +1.6% because Top-1 global selection can return semantically similar but functionally irrelevant memories.Category isolation keeps retrieved insights aligned with the agent's current objective.
  • Ablation Studies: Abstracted insights achieve +3.9%, whereas raw trajectories gain only +1.2% because task-specific artifacts such as file paths hinder adaptation.The extraction operator filters execution details to retain generalizable strategies.
  • Temporal Dynamics: Online accumulation begins with a −1 dip over instances 1–200, recovers to +3 over 201–300, and strengthens as the subtask memory becomes populated.The initial decline reflects retrieval overhead when few relevant matches exist.
  • Complexity Analysis: Hard tasks gain +8.7% in Pass@1, rising from 35.5% to 44.2%, while Easy tasks improve only +1.8%.The larger Hard-task gain is associated with prolonged exploration and obscure environment configurations.
  • Case Study: The case study resolves SymPy's reflected multiplication issue by retrieving distinct ANALYZE and EDIT experiences aligned with their functional objectives.The retrieved insights identify a missing reflected operator method and recommend delegating the reflected operation to the forward implementation.

5. Conclusion

The paper proposes structurally aligned subtask-level memory, aligning retrieval with functional decomposition to address granularity mismatch in software engineering agents. Experiments show consistent gains across diverse backbones, especially as interaction steps increase.

  • Structurally aligned subtask-level memory aligns memory retrieval with the agent’s functional decomposition.This addresses the granularity mismatch in existing software engineering agents.
  • The method decouples actionable reasoning experience from global task descriptions.The paper frames this as mitigating reasoning interference in compositional workflows.
  • Performance gains become more evident as interaction steps increase.The result highlights the importance of incorporating past experience for long-horizon reasoning in complex software engineering tasks.
Loading 2602.21611v1…