Authors: Zijun Wang, Yifan Ji, Haidong Xin, Zhenghao Liu, Yukun Yan, Zulong Chen, Yu Gu, Ge Yu, Maosong Sun
Organizations: School of Computer Science and Engineering, Northeastern University, China · Department of Computer Science and Technology, Tsinghua University, China · Alibaba Group, China
Large Language Models (LLMs) struggle to answer questions over long interaction histories, where relevant evidence may be scattered across distant sessions. Existing memory systems typically construct and maintain sophisticated memory representations offline, before user queries are observed, incurring substantial overhead and limiting their ability to adapt memory construction to query-specific information needs. In this paper, we propose T2Mem, a Test-Time Memory construction framework that defers memory construction to inference and progressively builds memory along the reasoning process. Specifically, T2Mem extracts lightweight episode-level metadata offline to capture key events and temporal associations as retrieval cues, while retaining links to the original interactions to facilitate the reconstruction of dependencies across episodes. At test time, the LLM adaptively retrieves and organizes metadata and raw interactions, progressively constructing query-specific memory as reasoning unfolds. Experiments on LoCoMo and LongMemEval show the effectiveness of T2Mem by consistently outperforming strong baselines across different backbone LLMs while substantially reducing the overhead of memory construction. Further analysis demonstrates that deferring memory construction to inference enables the memory construction process to dynamically adapt to the information needs of individual queries. All code is available at https://github.com/OpenBMB/T2Mem.
Figures & tables
Figure 1: Overall Architecture of Our Proposed T 2 Mem Framework.
Method
# Token ( ×103 )
Multi-Hop
Temporal
Open-Domain
Single-Hop
Avg.
Qwen3.5-27B
Naive RAG ( 2020 )
1,012
32.98
60.12
38.54
64.68
56.30
Search-o1 ( 2025 )
2,380
49.29
61.68
53.12
60.64
58.31
MemoryOS ( 2025 )
6,460
51.77
41.12
42.71
72.77
60.45
LightMem ( 2026 )
6,178
58.51
70.72
40.62
74.55
68.70
EverMemOS ( 2026a )
12,955
51.77
66.36
58.33
69.20
64.74
Table 1: Overall Performance of T 2 Mem and Baseline Methods on the LoCoMo Dataset. The best and second-best results are highlighted.
Method
Single
Single
Single
Multi
Knowledge
Temporal
Avg.
User
Assistant
Preference
Session
Update
Reasoning
Qwen3.5-27B
Naive RAG ( 2020 )
92.86
87.50
36.67
69.92
79.49
58.65
71.60
Search-o1 ( 2025 )
88.57
89.29
40.00
57.14
75.64
59.40
67.60
MemoryOS ( 2025 )
90.00
82.14
36.67
60.15
69.23
48.87
63.80
LightMem ( 2026 )
91.43
25.00
76.67
78.20
87.18
85.71
77.40
Table 2: Overall Performance of T 2 Mem and Baseline Methods on the LongMemEval Dataset.
Method
# Token ( ×103 )
Multi-Hop
Temporal
Open-Domain
Single-Hop
Avg.
Qwen3.5-27B
T 2 Mem (Summary)
6,809
57.80
71.96
51.04
73.01
68.64
T 2 Mem (Graph)
7,943
52.13
59.19
45.83
69.92
62.92
T 2 Mem
8,765
59.22
75.70
50.00
76.81
71.69
w/o Metadata
11,792
59.92
68.84
47.91
75.86
69.74
w/o Rawdata
7,415
56.03
77.88
56.52
68.85
67.60
Table 3: Ablation Study on the LoCoMo Dataset.
Figure 2: Analysis of T 2 Mem. We examine (a) the quality of the constructed memory, (b) token consumption during offline memory construction and LLM inference, and (c) QA performance across different test-time token budgets.
Appendix figures & tables12 assets
Supplementary material from the paper’s appendix.
Appendix
LoCoMo
LongMemEval
Category
# Questions
Category
# Questions
Single-Hop
841
Single-Session User
70
Multi-Hop
282
Single-Session Assistant
56
Temporal
321
Single-Session Preference
30
Open Domain
96
Multi-Session
133
-
-
Knowledge-Update
78
Appendix
Table 4: Statistics of the LoCoMo and the LongMemEval Datasets.
Method
Single
Single
Single
Multi
Knowledge
Temporal
Avg.
User
Assistant
Preference
Session
Update
Reasoning
Qwen3.5-27B
T 2 Mem (Summary)
85.71
94.64
60.00
60.90
82.05
73.68
74.80
T 2 Mem (Graph)
84.29
100.00
70.00
59.40
82.05
79.70
77.00
T 2 Mem
92.86
98.21
83.33
70.68
92.31
84.96
84.80
w/o Metadata
90.00
94.64
53.33
62.41
89.74
75.19
77.00
Appendix
Table 5: Ablation Study on the LongMemEval Dataset.
Figure 3: Performance of T 2 Mem at Different Memory Construction Steps on the LoCoMo Dataset.
Figure 4: Performance Gains of T 2 Mem over Search-o1 across Different Memory Construction Steps on the LoCoMo Dataset.
Figure 5: Case Study of T 2 Mem.
Figure 6: Token Saliency and Answer Specificity for LightMem and T 2 Mem on the Same LoCoMo Query.
Figure 7: Prompt Template for Constructing Wiki-style Metadata from Interaction Sessions.
Figure 8: Prompt Template for Iterative Reasoning and Information Access During Test-time Memory Construction.
Figure 9: Prompt Template for Answering the User Question.
Figure 10: Prompt Template for Response Judgement on the LoCoMo Dataset.
Figure 11: Prompt Template for Response Judgement on the LongMemEval Dataset.
Figure 12: Prompt Template for Evaluating the Quality of Constructed Memory.