Structurally Aligned Subtask-Level Memory for Software Engineering Agents
Kangning Shen, Jingyuan Zhang, Chenxi Sun et al.
arXiv:2602.21611 (2026)
🔗 Original paper: https://arxiv.org/abs/2602.21611
✨ One-line summary
This paper addresses this:
❌ Before: AI only “learned experience for the entire task,” which made it easy to misapply
✅ Now: AI learns experience by reasoning step and only calls on it at the matching stage → more stable, more accurate, more reusable
On SWE-bench Verified:
- Average improvement: +4.7% Pass@1
- Up to +8.7% on hard tasks
- At the same time, significantly reduces result variance
For a benchmark that is already very hard to improve, a gain like this is genuinely valuable.
🧠 Background: Why are current Agents’ “memories” not useful?
Many SWE Agents currently remember things like this:
Finish an issue → write a complete retrospective → next time find “the most similar task”
The problem:
Looking similar ≠ reasoning the same way
For example:
| issue | What it really is |
|---|---|
| Login button won’t respond | Frontend event binding |
| Logged out after a while | Backend session timeout |
Both texts contain “login,” but the solution paths are completely different.
This leads to:
- Retrieving the wrong experience
- Strong models end up being misled
- Performance variance increases
🧩 Core idea: Memory must align with the reasoning structure
Software engineering tasks naturally break into stages:
- ANALYZE — understand the problem
- REPRODUCE — reproduce the bug
- EDIT — modify the code
- VERIFY — verify the fix
The paper’s core design:
Stop remembering by “whole task”
Start remembering by “subtask stage”
🗂 What does the new memory unit look like?
Each memory becomes a triple:
(z, d, e)
1️⃣ z: Stage label
For example:
- ANALYZE
- EDIT
- VERIFY
2️⃣ d: The local goal at the time (intent)
A structured description of:
- What needs to be solved right now
- Key clues (function names / error messages)
3️⃣ e: Abstracted experience
It doesn’t store the entire process; it distills:
✅ Transferable strategies
❌ Repository-specific details
For example:
When a+b works but b+a throws an error → check radd
This is experience that can be reused across projects.
🔍 Retrieval mechanism: Look only in “the drawer for the current stage”
Traditional approach:
Semantic similarity matching across the entire memory store ❌
The paper’s approach:
Filter by stage first
Then do semantic matching
Effect:
- Avoids cross-stage interference
- Top-1 retrieval is stable enough
🧠 How is experience generated?
At the end of each subtask, do a reflection:
Success → summarize the pattern
Failure → summarize the anti-pattern
Then abstract it into an experience card and write it to memory.
This is an online self-evolving system:
The more tasks it handles → the more the Agent acts like a veteran employee
📊 Experimental results
Overall performance
On SWE-bench Verified:
| Model | Improvement |
|---|---|
| Gemini 2.5 Pro | +6.8% |
| Average | +4.7% |
Impact on strong models
Instance-level memory:
- Performance drops
- Variance increases ❌
Subtask-level memory:
- Performance improves
- More stable ✅
This shows:
Strong models aren’t afraid of having no memory
They’re afraid of wrong memory
Biggest gains on hard tasks
By trajectory length:
| Difficulty | Improvement |
|---|---|
| Easy | +1.8% |
| Hard | +8.7% |
Because hard tasks depend most on reusing experience.
🧪 Key ablations
❌ Only forcing step-by-step thinking (no memory storage)
Only +1%
→ The real gain comes from “experience reuse”
❌ No stage-based retrieval
The improvement drops to just +1.6%
→ Stage alignment is key
❌ Storing raw trajectories
Improvement: +1.2%
→ Abstraction is essential
🏗 Engineering perspective: Why does this matter?
The most valuable part of this paper is:
No need to train a new model
You can improve just through system design
Real-world systems can reuse this directly:
- Cursor / Devin-style Agents
- Internal company code Agents
- Automated repair bots
What it means for teams
AI is no longer:
An intern who starts from zero every time
It becomes:
A veteran employee who accumulates project experience
What this changes:
- Faster fixes for recurring problems
- More stable CI auto-repair
- Lower onboarding costs
🌍 This paradigm can transfer to all Agents
Not just coding:
Data analysis Agent
Stages:
- Understand the requirement
- Find data
- Build the model
- Explain the results
Customer service Agent
Stages:
- Clarify the issue
- Check policy
- Propose a solution
- Follow up
Research Agent
Stages:
- Search the literature
- Form a hypothesis
- Design experiments
- Analyze results
⚠️ Limitations
The paper has not yet solved:
1️⃣ Unbounded memory growth
Needed:
- Eviction mechanisms
- Compression
- Hierarchical memory
2️⃣ Contamination from bad experience
Current systems:
If it’s written down, it’s trusted
Future work must address:
- Memory credibility
- Automatic downweighting
- Version control
3️⃣ Subtask segmentation is still manually designed
Future direction:
Automatically learn the stage structure
🔮 Directions worth watching
I think the three with the most potential are:
1️⃣ Memory governance systems
Similar to:
- Git for memory
- memory diff / rollback
2️⃣ Multi-Agent shared experience libraries
Team-level AI knowledge accumulation.
3️⃣ Long-running code stewards
The real:
AI veteran employee
🏁 My take
The value of this paper is:
It didn’t build a bigger model
It answered a more fundamental question:
How should Agents “learn experience”?
This is a crucial step in the journey from LLMs to truly intelligent agents.
📌 Takeaway
If you’re building Agent systems, this paper offers a design principle you can put into practice directly:
✅ The right memory design
- Memory unit = reasoning subtask
- Store only abstracted experience
- Retrieval must be stage-aligned
Rather than:
- Storing entire conversations
- Global similarity retrieval
🧵 Final thoughts
If you’re working on:
- AI coding tools
- Enterprise code Agents
- Automated repair systems
This paper is the kind of work that:
You can use to directly change your system design
Rather than “just another 1% on the leaderboard.”