Large language model (LLM) agents work in scenarios with very different memory needs. A question about past conversations needs the exact facts it names, while a multi-step task needs a trace of the steps already taken together with details that the next step cannot name. Existing memories are each designed and tested for one kind of scenario. Retrieval memories such as A-Mem miss steps that the current query does not express, summaries drop exact strings, and pairing the two fixes the split of the budget in advance. We propose FlexA-Mem, a general memory that writes each unit of history once into an immutable store and renders a fresh memory for every call. The rendered memory is a compact timeline of records plus detail that a fixed rule fits into the remaining room without an LLM call. The detail is either relevant units as raw text or excerpts or the verbatim pieces that best match the query. With one store, FlexA-Mem serves both kinds of scenario. On AppWorld challenge tasks at 4k, it outperforms the second-best method by 11.5%, and on 147 unused tasks with predictions fixed in advance it outperforms A-Mem with a summary by 12.2%. On LongMemEval and LoCoMo, it matches a dedicated keyword retriever that writes no memory, while memories built on text written by an LLM fall far behind at tight budgets. Ablations show that the timeline carries AppWorld completion, whereas recovery mainly saves steps there and decides accuracy on exact facts. Code is available at https://github.com/WujiangXu/Flex-Amem
Figures & tables
Figure 1: Retrieval suits fact recall but loses the trace of a multi-step task, a summary keeps the trace but loses exact facts, and FlexA-Mem serves both needs within a single token budget.
Figure 2: Overview of FlexA-Mem. Each unit is written once and keeps its raw text in the store. Every call shows a compact timeline of records and fills the rest of the budget by unit or piece recovery.
AppWorld
SWE-bench
LongMemEval
LoCoMo
Normal
Challenge
issues at 8k
Method
4k
6k
4k
6k
95
480
4k
8k
16k
32k
2k
4k
8k
Full history
78.6
62.1
69.5
67.9
88.4
83.4
Truncation
26.2
55.4
8.6
22.5
63.2
62.3
10.9
15.0
24.1
35.5
14.0
25.9
39.6
Masking ( Lindenbauer et al., 2025 )
35.7
60.1
9.6
27.3
67.4
64.2
–
–
–
–
–
–
–
Masking + rule log
58.3
66.7
27.6
42.7
–
–
–
–
–
–
–
–
–
Table 1: Main results, completion on AppWorld, resolve rate on SWE-bench, accuracy on 440 LongMemEval questions and J on LoCoMo. Blue, orange and green mark the best, second and third method with a budget per column. Gray numbers, from the mode FlexA-Mem does not use on that task, and timeline only are not ranked. Appendix B lists the results from separate runs.
Setting
FlexA-Mem
Baseline
Gap
AppWorld Test-Normal
8k
75.0
A-Mem 67.3
+ 7.7
4k, 150 steps
80.4
masking 33.9
+ 46.4
4k, second run
65.5
masking 38.1
+ 27.4
6k, second run
74.4
masking 59.5
+ 14.9
SWE-bench Verified, 8k
Table 2: FlexA-Mem against the strongest baseline run in further settings.
Completion
Steps
Method
4k
6k
4k
6k
Full history
77.6
16.0
Observation masking
38.8
70.7
41.5
24.1
Summary+A-Mem
64.6
74.1
34.8
24.4
Timeline only
76.2
79.6
32.2
28.7
FlexA-Mem, piece recovery
70.7
81.0
28.8
20.9
Table 3: Confirmation on 147 unused AppWorld tasks, with steps per episode. Timeline only drops recovery.
Figure 3: Completion or accuracy against tokens per task, memory construction included. FlexA-Mem uses unit recovery on AppWorld and piece recovery on LongMemEval, the mode set for each.
Method
GPT
Gemini
Haiku
AppWorld Test-Normal, agent, 4k
Full history
78.6
94.6
79.2
Truncation
26.2
67.3
45.2
Observation masking
35.7
87.5
58.3
Piece retrieval
20.2
74.4
53.6
FlexA-Mem w/o excerpts
64.3
91.1
67.3
Table 4: AppWorld with three agents and LongMemEval with three readers.
AppWorld
SWE-bench
LongMemEval
Variant
4k
6k
8k
4k
8k
16k
32k
FlexA-Mem (control)
65.5
76.2
66.3
69.5
75.0
81.4
86.1
without timeline
− 15.5
− 10.1
− 1.1
+ 0.5
+ 3.6
+ 1.1
− 0.9
without recovery
− 1.8
− 8.3
+ 3.2
− 28.2
− 12.3
− 10.9
− 15.7
without excerpts
+ 0.0
+ 2.4
− 3.2
− 15.7
− 1.1
− 1.4
− 1.1
random candidates
− 0.6
− 1.8
–
− 47.5
− 40.9
− 32.5
− 17.0
Table 5: Change in completion or accuracy (%) when one part of FlexA-Mem with unit recovery is removed or changed. Appendix B gives the control of each row.
Figure 4: (a) Unit minus piece recovery (%). (b) LongMemEval accuracy at 4k, grouped by the BM25 rank of the best evidence piece of each question.
Figure 5: Test-Normal episodes that end at the 60-step limit at 4k (filled, value printed) and 6k (open).
Records written by
Recovery
4k
6k
GPT-5.4 mini
none
67.3
75.0
fixed rules, no LLM
none
61.3
61.3
fixed rules, with masking
none
58.3
66.7
Claude Haiku 4.5
none
51.8
–
GPT-5.4 mini
raw text only
64.3
80.4
Claude Haiku 4.5
raw text only
62.5
–
Table 6: AppWorld Test-Normal completion with records from different writers.
Figure 6: Share of memory tokens of FlexA-Mem on records, excerpts and raw text.
Method
Recall
Hit rate
Bal. acc.
Full history
22/22
98.6
0.97
Truncation
17/22
19.2
0.59
Observation masking
17/22
95.2
0.96
A-Mem
11/22
25.3
0.61
Summary+A-Mem
12/22
47.9
0.73
ReadAgent
17/22
32.9
0.66
Table 7: Questions to the memory at 109 checkpoints of SWE-bench trajectories at 8k. Colors mark the best, second and third method with a budget, without the version without excerpts.
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
Setting
LongMemEval
Agentic tasks
Prompt length Bˉ
0.95B
0.95B
Recent window
none
within 0.25B
Unit size (tokens)
about 2,000
1,000
Timeline share ρ
0.3
0.5
Discount λ
0.5
0.9
Seeds k
10
10
Appendix
Table 8: Settings of FlexA-Mem, with tokens counted by the o200k tokenizer.
Operation
Reader
Agent
Unit seeds (cosine)
question
task + newest unit
Excerpt pieces (BM25)
question
newest unit
Piece recovery (BM25)
question
task, newest unit
Appendix
Table 9: Query of each operation. For seeds, task + newest unit is the normalized sum of their embeddings. BM25 uses the content words of the query.
Figure 7: (a) LongMemEval accuracy on 440 held-out questions. (b, c) AppWorld completion rate at 4k (filled) and 6k (open). Dashed lines mark the full history.
LoCoMo
AppWorld
Method
2k
4k
8k
4k
6k
AFM, paper thresholds
43.8
46.0
46.2
55.4
72.0
AFM, calibrated
45.0
60.0
62.7
48.2
57.7
FlexA-Mem, unit recovery
52.5
65.2
75.7
64.3
78.0
Appendix
Table 10: AFM with its paper and calibrated thresholds, against FlexA-Mem with unit recovery.
Benchmark
Budget
Units
Pieces
Units − pieces
Test-Normal
4k
65.5
58.3
+ 7.1 (23/11)
6k
75.6
70.8
+ 4.8 (23/15)
Test-Challenge
4k
40.3
30.2
+ 10.1 ∗ (67/25)
6k
62.4
52.8
+ 9.6 ∗ (80/40)
SWE-bench
8k
70.5
64.2
+ 6.3 (9/3)
LongMemEval
4k
69.5
78.0
− 8.4 ∗ (33/70)
Appendix
Table 11: Unit and piece recovery paired by task or question. ∗ marks p<0.05 .
4k
Pieces − units
Type
Units
Pieces
4k
8k
16k
32k
SS user
85
93
+ 8.3
+ 5.0
+ 5.0
+ 0.0
SS assistant
98
91
− 6.5
− 6.5
− 2.2
+ 0.0
SS preference
85
80
− 5.0
+ 5.0
− 10.0
+ 0.0
multi-session
54
62
+ 7.3
+ 4.9
+ 4.9
+ 0.8
temporal
60
77
+ 17.1
+ 9.8
+ 5.7
+ 0.8
Appendix
Table 12: Unit and piece recovery by LongMemEval question type at 4k and their gap at each budget.
Agent
Full
FlexA-Mem
w/o exc.
Base
Share
GPT
77.4
64.9
65.5
27.9
75
Gemini
94.6
94.0
91.1
76.4
89
Haiku
79.2
67.3
67.3
52.4
56
Appendix
Table 13: Share of the 4k budget loss that the memory recovers on AppWorld Test-Normal, by agent.
AppWorld
Method
Normal
Challenge
SWE
LME
Full history
134.4
218.7
210.4
104.9
Truncation
156.7
181.9
233.5
7.1
Masking
134.3
181.6
156.2
–
Piece retrieval
192.6
223.4
521.9
8.0
Unit retrieval
165.0
–
459.9
7.8
Appendix
Table 14: Thousands of tokens per task, memory construction included, at 4k on AppWorld and 8k on SWE-bench and LongMemEval (LME).
Variant
4k
8k
16k
32k
FlexA-Mem ( E=300 )
69.5
75.0
81.4
86.1
excerpts of 150 tokens
73.2
78.2
–
–
excerpts of 600 tokens
64.5
74.5
–
–
raw text first
55.5
74.8
–
–
first pieces instead of best
70.0
76.1
–
–
A-Mem
52.0
71.6
84.5
88.6
Appendix
Table 15: Excerpt variants and the fit-or-degrade plug-in on 440 held-out LongMemEval questions.
Method
Backbone
Setting
Reported
Reference in the same paper
LongMemEval
MemGAS ( Xu et al., 2026a )
GPT-4o mini
reader input cut at 8k and 16k, GPT-4o judge
59.8, 60.3
full history 50.6
Nemori ( Ma et al., 2026 )
GPT-4.1 mini, GPT-4o mini
context of 3.7k to 4.8k tokens
74.6, 64.2
full context 65.6, 55.0
LightMem ( Fang et al., 2026 )
GPT-4o mini
no token budget, GPT-4o mini judge
64.3 to 68.6
A-Mem 62.6, full text 56.8
SWE-bench Verified
AttnCompress ( Zeng et al., 2026 )
Gemini 3 Flash
200 issues, no token budget
71.5
full history 72.5, masking 67.5
Appendix
Table 16: Numbers that other papers report in their own settings, not comparable to ours.
AppWorld
SWE-bench
LongMemEval
Variant
4k
6k
8k
4k
8k
16k
32k
FlexA-Mem (control)
65.5
76.2
66.3
69.5
75.0
81.4
86.1
without timeline
− 15.5 ∗
− 10.1 ∗
− 1.1
+ 0.5
+ 3.6 ∗
+ 1.1
− 0.9
without recovery
− 1.8
− 8.3 ∗
+ 3.2
− 28.2 ∗
− 12.3 ∗
− 10.9 ∗
− 15.7 ∗
without links
+ 1.2
− 0.6
+ 5.3
+ 1.4
+ 0.5
− 0.7
− 3.4 ∗
without excerpts
+ 0.0
+ 2.4
− 3.2
− 15.7 ∗
− 1.1
− 1.4
− 1.1
Appendix
Table 17: All variants of Table 5 , change in completion or accuracy (%), where ∗ marks p<0.05 . Appendix B gives the control of each row.
Long-term memory systems allow LLM agents to preserve information beyond a single context window, but most systems focus on storing and retrieving facts after extraction, leaving the write decision under-specified. What deserves memory can depend on the user's current task, topic, activity, or interaction partner, while uniform extraction applies one notion of importance across these different situations. We formulate this challenge as preference-conditioned write control and introduce AdaMem, which uses adaptive natural-language Memory Policies to personalize what an agent writes to memory. Each policy represents the user's memory preference for a particular interaction context, is updated from periodic feedback, and controls subsequent memory writing. We evaluate this loop in AdaMem-Bench, which assigns different memory preferences to six concurrent interaction personas across five ten-week stories. Across two extraction models and two feedback modes, AdaMem improves average QA accuracy over Mem0 from 80.0% to 84.35% while reducing persistent memory by 9.27%. Our analyses show that explicit feedback helps models learn better memory policies, but current models still struggle to translate those policies into reliably selective writing behavior. AdaMem thus demonstrates the promise of adaptive write control while exposing policy execution as a central limitation of current memory agents. Our code is publicly available: https://github.com/galaxyChen/AdaMem
Long-term memory enables LLM agents to leverage past interactions, but dialogue histories quickly exceed the context window, forcing agents to retrieve relevant subsets at query time. Because useful evidence is sparse and scattered across verbose conversations, retrieval faces a fundamental tension: broadening recall improves coverage but floods downstream reasoning with noise, while compressing memories at write time eases retrieval but irreversibly discards details that future queries may need. We introduce LazyMem, which resolves this tension by deferring all memory construction to query time. Given a retrieved candidate pool, a lightweight model processes it in overlapping parallel windows, selectively retaining and compressing only query-relevant content. The model is trained with supervised fine-tuning followed by reinforcement learning, using a reward that jointly encourages the identification of relevant messages and the generation of compressions that are faithful to the source and useful for answering the query. On LongMemEval, LazyMem-4B achieves an LLM-judge accuracy of 0.85, outperforming the strongest non-oracle baseline while using only 213 answer-context memory tokens, 21.0 times fewer than the baseline. It further generalizes to LoCoMo without target-domain training and reduces mean latency relative to the prior query-time baseline. Code is available at https://github.com/allacnobug/LazyMem.
Jing Yu, Yibo Zhao, Jiaming Zhang +1
School of Data Science and Engineering, East China Normal University
Large language model (LLM) agents are increasingly expected to operate over long-term interactions, where information from past dialogues must be preserved and recalled to support future tasks. However, as interactions accumulate, the memory store grows without bound and fills with redundant entries that inflate storage cost and degrade retrieval by crowding out the most useful evidence. Furthermore, this is especially limiting on resource-constrained platforms with hard memory budgets, motivating us to formulate storage-budgeted memory management, the task of keeping an already constructed memory store within a fixed budget while preserving information useful for future interactions. To this end, we then propose MemRefine, an LLM-guided framework that, since surface similarity poorly reflects factual value, uses similarity only to propose candidate pairs and defers delete, merge, and preserve decisions to an LLM judge based on factual content, iterating until the budget is met. Across multiple memory frameworks and long-term conversation benchmarks, MemRefine consistently meets target budgets while preserving downstream performance and outperforming rule-based baselines under tight budgets.