MemScope: Evolving Agent Memory Architectures through Localized Code Repair
Authors: Miao Su, Yucan Guo, Zixuan Li, Long Bai, Zhongni Hou, Xiaolong Jin, Jiafeng Guo
Organizations: State Key Laboratory of AI Safety · Institute of Computing Technology, Chinese Academy of Sciences · University of Chinese Academy of Sciences · Meituan
Agent memory architectures define how LLM agents store and reuse experience across tasks, but they are typically fixed after deployment, limiting their adaptability across task types. Recent self-evolving approaches instead adapt these memory architectures using execution feedback, typically represented as evaluation scores or compressed summaries. However, such coarse-grained feedback is insufficient for precise failure localization in current agent systems, where long-horizon task execution involves multiple interacting components. Without a precise failure location, existing approaches lack a clear code-level target for modification, leaving the update scope weakly constrained and often leading to large-scale rewrites of an otherwise capable memory architecture. We propose MemScope, a framework for evidence-grounded, localized evolution of an existing memory architecture. Its tool-using Patch Agent jointly inspects raw execution traces, runtime memory state, and current architecture code to identify repair targets and apply bounded, in-place edits under provider-identity and memory-compatibility constraints. On GAIA, the trace-and-memory inspection variant achieves 86.67% accuracy, compared with 70.00% for trace-only and 63.33% for summary-only feedback. Under xBench tasks, the evolved memory architecture improves over its original version from 49 to 55 correct answers with DeepSeek V3.2 and from 50 to 53 with Kimi K2.7 Code. On disjoint ALFWorld unseen tasks, success rises from 50.75% to 71.64%. Across archived architecture-snapshot transitions, the median code-change ratio is 4.4%. These results support fine-grained execution evidence as a basis for localized, in-place memory-architecture evolution.
Figures & tables
Figure 1: Feedback and update granularity in memory-architecture evolution. Prior architecture-level approaches use outcome-level feedback to propose complete executable architectures. MemScope makes the repair target explicit by jointly inspecting execution traces, runtime memory state, and provider code, then applies a localized, in-place edit to the existing provider. In the illustrated update, only the highlighted code region is modified.
Figure 2: Overview of MemScope. (a) Evolution Target. Following the Agent Skills format, each reusable memory skill contains a required SKILL.md file and an executable provider under scripts/ ; the activated provider maintains a separate skill-specific runtime memory bank Mt . (b) MemScope Evolution Loop. Execution produces metrics and raw success and failure traces. When repair is triggered, the Patch Agent inspects these traces, the active memory bank, the current provider, and Patch History. A local edit changes pt into pt+1 without replacing the skill, while the patch and its later outcome are recorded for subsequent evolution.
Index available cases; inspect a task result and step map; read selected native steps; search matching events across traces.
Memory Inspection ( memory_store )
stats
Summarize record counts, fields, schemas, and outcome distribution.
list
List compact record summaries, optionally filtered by outcome.
read
Return one complete raw memory record.
Table 1: Evidence sources for failure localization.
System
Model Family
GAIA
xBench
Avg.
L1
L2
L3
Closed-Source Agent Frameworks
Alita (pass@1)
Claude Sonnet 4, GPT-4o
75.15
77.36
76.74
65.38
—
Langfun Agent
Claude 3.7 etc.
71.52
83.02
68.60
57.69
—
TraseAgent
Claude etc.
70.30
83.02
69.77
46.15
—
OpenAI Deep Research
o1, o3 etc.
67.36
74.29
69.06
47.60
—
Table 2: GAIA validation and xBench DeepSearch-2505 accuracy (%).
Backbone
C → C
I → C
C → I
I → I
DeepSeek V3.2
47
8
2
13
Kimi K2.7 Code
46
7
4
13
Table 3: Paired xBench outcomes on 70 questions. C/I denote correct/incorrect; transitions are from the original to the evolved provider.
System
Success
DynamicCheatsheet
34/67 (50.75)
ALMA
45/67 (67.16)
MemScope
48/67 (71.64)
Table 4: ALFWorld valid_unseen success under DeepSeek V3.2 (correct/67, %).
Experimental setting
Diagnostic inputs
Task accuracy (%)
Resources
Setting
Provider
Evidence
Memory
History
Overall
L1
L2
L3
Time (s)
Steps
No Memory
×
None
×
×
56.67
75.0
58.82
20.0
517.61
11.30
Original Provider
✓
None
×
×
56.67
62.5
64.71
20.0
771.05
32.53
Summary-only
✓
Summary
×
×
63.33
75.0
70.59
20.0
993.14
40.17
Trace-only
✓
Raw Trace
×
×
70.00
87.5
70.59
40.0
921.93
30.37
Trace + Memory Inspection
✓
Raw Trace
✓
×
86.67
75.0
94.12
80.0
804.41
25.73
Table 5: GAIA diagnostic ablation: accuracy (%), mean time, and steps.
Aspect
Summary-only
Trace-only
Evidence
Grouped failure reports
Zero-length traces; empty guidance steps
Proposed diagnosis
Insufficient cross-verification
Early-return guard under MemoryStatus.IN may suppress guidance
Edit
Add a verification rule to the storage prompt
Remove the early-return guard
Table 6: A recorded GAIA repair case under different diagnostic interfaces.
Figure 3: GAIA guidance during online memory updates. Original versus evolved provider coverage: 98.8% versus 99.4%; accuracy among guided tasks: 65.6% versus 84.1%. Code and memory state both vary.
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
Original field
Recorded value
patch_type
"no_patch"
needs_new_provider
false
edited_files
[]
patch_history_decision
"not_repeating_failed_direction"
Appendix
Table 7: A recorded no_patch decision in xBench.
Metric
Snapshot change
Provider-size proxy
Lines
16.5
369
Functions
1
16
Median recorded normalized fraction
4.4%
100%
Appendix
Table 8: Syntactic changes across archived provider snapshots.