arXiv:2610.29671cs.CLOct 2026

Manuscript Offprint

arXiv:2610.29671

Uni-Mem: Learning a Long-Horizon Agentic Memory Manager with Unified Online Policy Optimization

Zhiqian Xia, Jielong Tang, Ling-An Zeng, Shixiong Kai, Rong Yao, Hao Kong, Xiao Dong, Wei Wang, Mingxuan Yuan, Siyu Xia, Haifeng Xia

Abstract

Long-term agent memory is shifting from predefined workflows toward learnable policies for memory construction and retrieval. Existing learning-based methods either optimize construction alone or combine retrieval-side online reinforcement learning (RL) with offline construction supervision, limiting co-adaptation between the two stages. In this paper, we explore end-to-end online RL for a unified memory manager (UNI-MEM) that learns both capabilities under a shared policy. However, joint optimization with existing RL algorithms such as GRPO faces confounded group comparisons and sparse feedback over long memory-management trajectories. To this end, we propose Stage-Decoupled GRPO, which alternates construction and retrieval optimization while controlling variation from the other stage within each rollout group, yielding stage-specific learning signals. We further introduce Event-Wise Credit Assignment (ECA), which localizes feedback to responsible events and propagates event-level advantages to their constituent operations. Experiments on LoCoMo and LongMemEval show that UNI-MEM outperforms the strongest RL-based memory, demonstrating the effectiveness of jointly learning memory construction and retrieval via Stage-Decoupled GRPO and ECA.

1 Introduction

Long-term memory enables Large Language Model (LLM) agents to reuse information across interactions that exceed their context windows (Wang et al., 2023; Yu et al., 2026b). Early memory systems, such as MemGPT (Packer et al., 2023), Mem0 (Chhikara et al., 2025), and A-Mem (Xu et al., 2025), rely on manually specified prompts and predefined workflows to organize and access past information. Despite their effectiveness, these

Figure

Figure 1: Comparison of training paradigms in different methods. Construction-only RL keeps retrieval fixed, while asymmetric joint learning combines offline construction imitation with online retrieval RL. UNI-MEM jointly optimizes both stages under a shared policy through alternating online RL and event-wise credit.

systems remain constrained by frozen LLMs and rigid human priors, limiting the generalization of memory construction and retrieval to dynamic agent environments (Xiong et al., 2026).

To bridge this gap, recent works formulate memory management 1^{1} as a learnable policy optimized via reinforcement learning (RL). Methods such as Memory-R2 (Yan et al., 2026a) and Mem- α\alpha (Wang et al., 2025) keep retrieval fixed and train construction with RL. Such construction-only RL learns how to build memory without jointly learning how to retrieve it adaptively, limiting memory utility in downstream tasks. To jointly learn both capabilities within a shared-parameter memory manager, approaches such as Mem-T (Yue et al., 2026) combine online agentic RL of retrieval with offline imitation of hindsight-selected construction actions. Yet this asymmetric joint learning can introduce a training lag: online retrieval RL continually updates the shared policy, whereas offline construction supervision remains anchored to ear-

∗^{*}Equal contribution. Work done during internship.

†^{\dagger}Corresponding author.

1^{1}In this paper, memory management encompasses construction (creation, update, and deletion) and retrieval.

lier policy and memory states, hindering coordinated adaptation across the two stages. This motivates a central research question: How can a shared-parameter agentic memory manager, which operates through multi-turn tool interaction, jointly learn long-horizon construction and retrieval via end-to-end online RL?

Achieving this goal poses two main challenges. (1) Confounded group comparisons. Existing group-relative RL (e.g. GRPO (Shao et al., 2024)) derives advantages from reward differences among sampled rollouts. For a unified memory manager, each rollout couples construction trajectories with a retrieval continuation, so its final reward reflects decisions from both stages. When both stages vary across rollouts, trajectory-level group-relative advantages can conflate their contributions, obscuring the learning signal for each stage. (2) Long-horizon credit attribution. The manager policy performs hundreds of memory operations (tool calls) per rollout, yet receives the outcome reward only at answer time. Such sparse feedback neither localizes the query-relevant portions of a rollout nor reveals whether the required information was stored or successfully retrieved. Moreover, memory updates further complicate attribution by overwriting memory items produced by earlier decisions. Thus, feedback must be attributed to the relevant stage and operations within them.

In this work, we propose UNI-MEM, a unified memory manager that jointly learns agentic construction and retrieval through end-to-end online RL. Fig. 1 compares the training paradigms of existing methods with ours. To address confounded group comparisons, we introduce Stage-Decoupled GRPO, which decouples the two stages contributions in group-relative advantages. Specifically, we alternate construction and retrieval optimization while controlling variation from the other stage within each rollout group. For construction, we bypass learned retrieval: since each memory record retains the identifier of its source chunk, we directly gather the records linked to a query's annotated supporting evidence (used only during training) and score them with a frozen answer model. This evidence-indexed score reflects what was stored rather than how it was retrieved. For retrieval, all rollouts in a group share an identical memory state resampled from the current policy, so reward differences reflect retrieval alone. Alternating the two phases yields stage-specific signals, enabling both capabilities to co-evolve.

To address long-horizon credit attribution, we introduce Event-Wise Credit Assignment (ECA), which organizes multiple memory operations into events 2^{2}, triggered by an incoming dialogue chunk (construction event) or a query (retrieval event). ECA uses a query's supporting evidence to localize the responsible construction events, and reuses evidence-indexed scoring to penalize an unsuccessful retrieval event only when sufficient evidence has been stored. For update-robust evidence attribution, ECA tracks events along the same memory update chain and assigns them the corresponding credit. Since the event stream is fixed by the input data, rollouts share aligned event positions. ECA thus normalizes each event's feedback against same-position events across the rollout group, rather than at the trajectory level, and broadcasts the resulting advantage to all memory tool calls within that event. Our contributions are summarized as follows:

• We propose UNI-MEM, a unified memory manager that jointly optimizes agentic construction and retrieval via end-to-end online RL, with Stage-Decoupled GRPO separating the two stages’ contributions to group-relative signals.

• We introduce Event-Wise Credit Assignment, which localizes outcome feedback to responsible events and computes advantages over position-aligned events across rollouts.

• Extensive experiments on LoCoMo and Long-MemEval demonstrate that UNI-MEM outperforms the strongest RL-based memory manager, supporting the effectiveness of jointly learning memory construction and retrieval.