Program evolution provides a promising approach to discover agent memory designs and study the choices underlying their effectiveness. We introduce MAPE, a framework that evolves whole memory programs from minimal seeds through a standardized lifecycle interface and an iterative diagnosis-proposal loop. Experiments on LoCoMo and LongMemEval yield an absolute accuracy gain of up to 12% over manually designed baselines at 35% of the serving cost, with further evaluations supporting transfer across serving backbones and benchmarks. Empirical analyses and ablations identify and validate two recurring design patterns: retaining raw conversations as retrievable evidence preserves details omitted from extracted memories, while composing retrieved evidence according to query intent helps the answering model use it effectively. Transplanting the composition module into five existing memory systems improves accuracy across all five. Beyond these patterns, the search objective shapes where computation goes: optimizing serving cost alongside accuracy shifts computation from LLM-based memory construction to selective processing at query time while retaining competitive accuracy. Together, these findings offer empirical lessons for agent memory design. Code is available at https://github.com/ash-ding/MAPE.
Figures & tables
Figure 1: Overview of MAPE ’s program evolution framework. Candidate programs are proposed using archived designs and diagnostic feedback, checked for execution errors, and evaluated on the search set. Their implementations, results, and diagnoses are retained to guide subsequent proposals. Evolution follows either an accuracy-only objective ( MAPE-A ) or joint accuracy–cost objectives ( MAPE-P ). Shortlisted programs undergo held-out evaluation for final selection.
Method
Multi
Open
Single
Temp
Avg
Cost (/1k)\downarrow$
GPT-4.1 mini
Full Context
71.55
62.65
91.06
66.67
80.87
12.54
RAG
33.47
39.76
59.70
47.29
51.19
0.25
Mem0
62.34
51.81
85.01
70.93
75.98
1.10
A-Mem
50.63
54.22
75.38
63.95
67.25
8.60
LightMem
59.00
42.17
68.09
52.71
61.74
0.56
Table 1: Accuracy and lifecycle serving cost on the LoCoMo evaluation set with two serving backbones. Multi, Open, Single, and Temp denote multi-hop, open-domain, single-hop, and temporal questions, respectively; Avg denotes accuracy over all questions. Accuracy is reported in % and cost in dollars per 1,000 queries. Within each backbone, the highest and second-highest accuracies per column are bold and underlined , respectively.
Method
Temp
Multi
Know
User
Asst
Pref
Avg
Cost (/1k)\downarrow$
Qwen3-30B-A3B-Instruct-2507
Full Context
43.40
41.51
74.60
91.07
93.33
37.50
59.75
22.27
RAG
43.40
53.77
85.71
94.64
97.78
41.67
66.00
2.62
Mem0
31.13
38.68
60.32
80.36
48.89
41.67
47.25
93.55
A-Mem
42.45
45.28
60.32
82.14
100.00
41.67
58.00
661.97
LightMem
49.06
57.55
79.37
96.43
26.67
37.50
59.50
26.59
Table 2: Accuracy and lifecycle serving cost on the LongMemEval evaluation set with Qwen3-30B-A3B-Instruct-2507 as the serving backbone. Temp, Multi, Know, User, Asst, and Pref denote temporal reasoning, multi-session, knowledge-update, single-session-user, single-session-assistant, and single-session-preference questions, respectively; Avg denotes accuracy over all questions. Accuracy is reported in % and cost in dollars per 1,000 queries. The highest and second-highest accuracies in each column are bold and underlined , respectively.
Figure 2: Pipeline of MAPE-A LME , evolved under the accuracy-only objective on LongMemEval. Build retains both extracted atomic notes and raw conversations. Retrieve combines dense and sparse rankings through reciprocal rank fusion (RRF) and returns relevant notes and raw conversational evidence. Compose implements Query-Routed Scaffolding (RQS), which routes queries to type-specific scaffolds according to query intent, preparing context for the answering model.
Method
Overall Accuracy
LoCoMo
LongMemEval
MAPE-A LME
75.90
77.00
w/o raw rounds
63.73
70.50
w/o RQS
71.46
70.75
w/o both
63.12
63.00
Table 3: Ablation of MAPE-A LME on the LoCoMo and LongMemEval evaluation sets using the Qwen3-30B-A3B-Instruct-2507 serving backbone. W/o raw rounds retains only retrieved notes; w/o RQS bypasses Query-Routed Scaffolding (RQS); w/o both applies both ablations. Accuracy is reported in %.
Figure 3: RQS transplanted from MAPE-A LME into five human-designed memory systems, evaluated on the LongMemEval evaluation set with Qwen3-30B-A3B-Instruct-2507 as the serving backbone. Bold values indicate absolute accuracy gains in %.
Appendix figures & tables12 assets
Supplementary material from the paper’s appendix.
Appendix
Category
Search
Evaluation
Total
Multi-hop
43
239
282
Temporal
63
258
321
Open-domain
13
83
96
Single-hop
114
727
841
Evaluated questions
233
1,307
1,540
Adversarial (excluded)
71
375
446
Appendix
Table 4: LoCoMo partition sizes. Questions inherit the partition of their conversation; adversarial questions are excluded from evaluation.
Question type
Search
Evaluation
Total
Temporal reasoning
27
106
133
Multi-session
27
106
133
Knowledge update
15
63
78
Single-session user
14
56
70
Single-session assistant
11
45
56
Single-session preference
6
24
30
Appendix
Table 5: LongMemEval-S question counts under the fixed stratified partition. Each question and its associated history are assigned together.
Method
Temp
Multi
Know
User
Asst
Pref
Avg
Cost (/1k)\downarrow$
Qwen3-30B-A3B-Instruct-2507
Full Context
43.40
41.51
74.60
91.07
93.33
37.50
59.75
22.27
RAG
43.40
53.77
85.71
94.64
97.78
41.67
66.00
2.62
Mem0
31.13
38.68
60.32
80.36
48.89
41.67
47.25
93.55
A-Mem
42.45
45.28
60.32
82.14
100.00
41.67
58.00
661.97
LightMem
49.06
57.55
79.37
96.43
26.67
37.50
59.50
26.59
Appendix
Table 6: Cross-benchmark transfer from LoCoMo to LongMemEval without further evolution, using a fixed input adapter and the Qwen3-30B-A3B-Instruct-2507 serving backbone. Baseline results are reproduced from Table 2 . Accuracy is reported in %; Avg denotes overall accuracy across 400 questions, and cost is measured in dollars per 1,000 queries. Column abbreviations follow Table 2 . The highest and second-highest accuracies in each column are bold and underlined , respectively. Transfer details are provided in Appendix D.1 .
Method
Multi
Open
Single
Temp
Avg
Cost (/1k)\downarrow$
Qwen3-30B-A3B-Instruct-2507
Full Context
58.16
53.01
89.41
31.78
70.01
7.07
RAG
27.62
38.55
58.05
16.67
43.08
0.14
Mem0
60.25
56.63
77.44
41.86
65.95
0.61
A-Mem
44.77
37.35
67.95
24.42
53.18
5.71
LightMem
54.81
45.78
76.20
28.68
60.98
0.48
Appendix
Table 7: Cross-benchmark transfer from LongMemEval to LoCoMo without further evolution, using a fixed input adapter and the Qwen3-30B-A3B-Instruct-2507 serving backbone. Baseline results are reproduced from Table 1 . Accuracy is reported in %; Avg denotes overall accuracy across 1,307 questions, and cost is measured in dollars per 1,000 queries. Column abbreviations follow Table 1 . One context-overflow case for MAPE-A LME is counted as incorrect. The highest and second-highest accuracies in each column are bold and underlined , respectively. Transfer details are provided in Appendix D.1 .
Figure 4: A LoCoMo temporal example comparing MAPE-A LCM and MAPE-P LCM across serving backbones. The programs differ in the date representation and answer context passed to the QA model. Qwen answers are taken from held-out traces; GPT-4.1 mini answers are illustrative. Evidence and context excerpts are abbreviated.
Figure 5: LongMemEval search trajectories using Qwen3-30B-A3B-Instruct-2507 on the 100-question search set. Panels a and b show accuracy-only and accuracy–cost search, respectively. Blue lines show candidate accuracy, dashed lines show the best accuracy so far, and bars show lifecycle serving cost per 1,000 queries. Stars mark selected programs; orange circles mark the final Pareto frontier. Callouts identify representative design changes.
Figure 6: LoCoMo search lineages using GPT-4.1 mini on the 233-question search set. Panels a and b show accuracy-only and accuracy–cost search, respectively. Nodes represent candidates; colour encodes serving cost on a logarithmic scale. Grey edges indicate primary parents, and orange paths trace the lineages of the highest-accuracy candidates. Dashed lines mark maximum search accuracy; dark rings mark the final Pareto frontier. The no-memory seed is displayed off-scale at the bottom.
Method
Temp
Multi
Know
User
Asst
Pref
Avg
MAPE-A LME
80.19
58.49
88.89
89.29
93.33
54.17
77.00
w/o raw rounds
70.75
53.77
84.13
92.86
73.33
50.00
70.50
w/o RQS
60.38
56.60
80.95
94.64
95.56
50.00
70.75
w/o both
54.72
52.83
74.60
92.86
66.67
37.50
63.00
Appendix
Table 8: Component ablation of MAPE-A LME on LongMemEval with the Qwen3-30B-A3B-Instruct-2507 serving backbone, providing the question-type breakdown of Table 3 . The bold row denotes the full system. W/o raw rounds omits the five retrieved conversation rounds from the returned evidence while retaining them in the index; w/o RQS bypasses composition and uses the default evidence rendering; w/o both applies both ablations. Values are accuracies in %, with Avg computed over all questions. Column abbreviations follow Table 2 .
Method
Multi
Open
Single
Temp
Avg
MAPE-A LME
60.67
62.65
86.24
65.12
75.90
w/o raw rounds
49.37
56.63
74.00
50.39
63.73
w/o RQS
58.16
50.60
90.51
36.82
71.46
w/o both
52.30
49.40
77.03
38.37
63.12
Appendix
Table 9: Component ablation of MAPE-A LME transferred to LoCoMo using the fixed input adapter described in Appendix D.1 and the Qwen3-30B-A3B-Instruct-2507 serving backbone. Results provide the question-type breakdown of Table 3 . The bold row denotes the full system; ablation definitions follow Table 8 . Values are accuracies in %, with Avg computed over all questions. Column abbreviations follow Table 1 .
Figure 7: Evidence completeness among incorrect answers with the Qwen3-30B-A3B-Instruct-2507 serving backbone. Panels a and b show LongMemEval and LoCoMo, respectively. Each bar sums to 100% of the analysed errors for one system. Blue denotes complete retrieved evidence despite an incorrect answer; orange denotes incomplete evidence. Classification details are provided in Appendix D.4 .
Figure 8: Estimated overall evidence completeness and answer accuracy on LongMemEval in panel a and LoCoMo in panel b. Systems are ordered by estimated completeness. The estimate combines accuracy with the error labels shown in Figure 7 , assuming complete evidence for every correct answer. The calculation and correlation analysis are detailed in Appendix D.4 .
Method
RQS
Temp
Multi
Know
User
Asst
Pref
Avg
SimpleMem
without
39.62
34.91
52.38
67.86
82.22
41.67
49.25
with
56.60
38.68
60.32
76.79
84.44
58.33
58.50
Δ
+16.98
+3.77
+7.94
+8.93
+2.22
+16.67
+9.25
LightMem
without
50.00
58.49
79.37
94.64
26.67
29.17
59.25
with
73.58
57.55
90.48
91.07
26.67
58.33
68.25
Δ
+23.58
−0.94
+11.11
−3.57
0.00
+29.17
+9.00
Appendix
Table 10: RQS transplantation into five human-designed memory systems on the LongMemEval evaluation set with the Qwen3-30B-A3B-Instruct-2507 serving backbone. Results provide the question-type breakdown of the overall gains shown in Figure 3 . For each system, without uses the default evidence rendering, while with applies RQS to the same retrieved evidence. Values are accuracies in %; Δ denotes the absolute accuracy change from adding RQS in %. Deltas are computed before rounding. Avg is computed over all questions, and column abbreviations follow Table 2 .