ElasticMem: Latent Memory as a Learnable Resource for LLM Agents

Tao Feng, Chongrui Ye, Tianyang Luo, Jingjun Xu, Xueqiang Xu, Haozhen Zhang, Ge Liu, Jiaxuan YouarXiv 2026

TL;DR

ElasticMem is a novel memory-augmented LLM framework that treats long-term memory as an elastic, learnable latent resource. By dynamically adjusting both memory retrieval and representation budgets based on downstream task rewards, it significantly improves QA accuracy and agent success rates while dramatically reducing token overhead.

What Problem Does This Paper Address?

To reason coherently over long interactions, large language model (LLM) agents need long-term memory. However, existing memory systems treat memory as a fixed resource.

Current approaches fall into two main camps, both of which suffer from a structural mismatch:

  1. Text-space approaches: These retrieve natural-language records and concatenate them directly into the prompt context window. This incurs massive token overhead and exposes the model to distracting, noisy text.
  2. Latent-space approaches: These compress memories into continuous vectors to save context space. However, they rely on rigid retrieval (like basic cosine similarity) and allocate a fixed, uniform vector capacity to every retrieved chunk.

This creates a fundamental flaw: memory usefulness is query-dependent and task-dependent, but memory allocation is fixed. A highly relevant chunk containing a crucial procedural plan gets the exact same representation budget as a redundant or superficially similar chunk. ElasticMem addresses this by learning how much representational capacity each memory chunk actually deserves based on its utility to the final task.

Methods

ElasticMem conceptualizes memory management as an end-to-end learnable resource allocation problem. The framework operates in four distinct stages:

  1. Latent Memory Bank Construction: Memory chunks (dialogues, passages, skill cards) are processed offline once using a frozen base LLM encoder. Each chunk is split into a compact retrieval key (the final hidden state) and a content cache (the last $N_c$ hidden states). This bank remains read-only during training to avoid expensive re-encoding.
  2. Query-Conditioned Retrieval: Instead of using a standalone external retriever, ElasticMem derives the retrieval query directly from the LLM reasoner's internal hidden state after sampling a special retrieval-control token. This ensures retrieval is conditioned on how the model currently interprets the input.
  3. Elastic Latent Budget Allocation: Retrieved candidate chunks are passed to a lightweight Transformer-based budget policy network. This network performs cross-memory attention to compare chunks and outputs a discrete budget $b_j \in \{0, \dots, B_{max}\}$ for each chunk. A budget of 0 allows the model to completely suppress misleading or redundant memories.
  4. Latent Memory Injection & Joint Optimization: The selected cached hidden states are mapped into the reasoner's input embedding space via a learned projector, acting as "soft memory tokens."

Crucially, the entire system—the LoRA-adapted reasoner, the budget policy, and the latent projector—is jointly optimized using Group-Relative Policy Optimization (GRPO) based on downstream task rewards (e.g., exact-match accuracy or environment success).

Figure 1: Overview of ElasticMem. ElasticMem learns to use long-term memory as an elastic latent resource. (1) Latent memory bank construction. Memory chunks from dialogues, passages, and skill cards are encoded once by a frozen offline LLM encoder. Each chunk is stored as a retrieval key and a latent content cache, forming a read-only memory bank B that is not updated during training. (2) Query-conditioned elastic memory retrieval and allocation. For each query, the LoRA-adapted reasoner generates a retrieval-control token and derives a query state for retrieving top- ranked memory chunks. A budget policy then assigns each retrieved chunk a variable latent budget bj ∈{0, . . . , Bmax}, allowing useful chunks to receive more capacity while weak or redundant chunks are compressed or suppressed. (3) Latent memory injection. The selected cached states are projected into soft memory tokens and inserted into the final model input before generation. (4) Reward-based optimization. Task rewards optimize the LoRA-adapted reasoner, budget policy, and latent projector through GRPO, while the latent memory bank remains frozen.

Datasets

The authors evaluated ElasticMem using MemorySuite, a benchmark divided into two distinct interaction types:

  • MemorySuite-QA: Evaluates long-term memory recall and reasoning. It includes PersonaMem-32K and PersonaMem-128K (personalized memory recall over varying context lengths), LoCoMo (long-dialogue understanding and temporal reasoning), and LongMemEval (comprehensive chat assistant memory evaluation).
  • MemorySuite-Agentic: Evaluates embodied decision-making using ALFWorld (both Seen and Unseen environments), where text-based agents must accomplish household tasks.

Key Insights and Ideas

  • Utility $\neq$ Semantic Similarity: Standard retrievers rely on surface semantic overlap. ElasticMem's reinforcement learning approach demonstrates that a memory chunk can be topically different but structurally vital (e.g., a skill card from a different task that shares an identical spatial layout), and the budget policy successfully learns to prioritize these transferable plans.
  • Suppression is as Important as Allocation: By allowing a budget of $b_j = 0$, the budget policy acts as a dynamic filter, actively suppressing chunks that have high cosine similarity to the query but offer zero downstream utility.
  • Cross-Memory Interaction Matters: Ablations show that a Transformer-based budget policy outperforms a simple MLP policy. Comparing retrieved memories against each other helps the model better identify redundancy and allocate tokens efficiently.

Key Results

The authors evaluated ElasticMem against strong text-space (e.g., MemoryBank, Mem0, LangMem) and latent-space (e.g., MemGen, AutoCompressor) baselines using Qwen2.5-3B-Instruct and Qwen2.5-7B-Instruct backbones.

Table 2: Main comparison results on PersonaMem-32K, PersonaMem-128K, LoCoMo, Long- MemEval, and ALFWorld. For Acc. and SR, higher is better; for #Tok., lower is better. Bold and underline denote the best and second-best results. The Avg. columns are computed as weighted averages using the number of test examples or games in each benchmark.
  • Substantial Accuracy Gains: On the QA tasks, ElasticMem improved weighted average accuracy by 26.2% on the 3B model and 24.6% on the 7B model over the strongest baselines.
  • Superior Agent Performance: On ALFWorld, ElasticMem boosted the task success rate by 66.3% (3B) and 27.2% (7B).
  • High Token Efficiency: Despite the performance surge, ElasticMem achieved the lowest token cost per game on ALFWorld, proving that its gains stem from smarter memory utilization rather than bloated context windows or prolonged exploration.
  • Optimal Budget Cap: Ablation studies revealed that a moderate maximum per-chunk budget ($B_{max} = 20$) yields the best performance, preventing the model from wasting capacity on less useful chunks.
Figure 2: Ablation studies on Qwen2.5-7B-Instruct. (a) Effect of budget policy: ElasticMem outperforms Random Budget, Uniform Budget, and MLP Budget Policy, showing that the Transformer budget policy better learns how to allocate latent capacity across retrieved memories. (b) Effect of retrieval design: ElasticMem outperforms Semantic Retrieval, Frozen-State Retrieval, and Query- State Retrieval, demonstrating the benefit of using a trainable reasoner-state retrieval mechanism with a sampled retrieval-control token. (c) Effect of per-chunk maximum budget: ElasticMem achieves the best overall performance at Bmax = 20, suggesting that a moderate per-memory capacity limit is more effective than overly small or overly large per-chunk budgets.

Limitations and Future Work

While highly effective, the authors note a few limitations and areas for future exploration:

  • Static Memory Banks: The latent memory bank is currently constructed offline and remains fixed. A natural next step is allowing the memory bank to update dynamically as the agent accumulates new experiences.
  • Model and Environment Scope: The evaluation was restricted to the Qwen2.5 family and the MemorySuite benchmark; validating generalizability across other model architectures and open-ended interactive environments remains future work.
  • Interpretability: While soft latent tokens are highly efficient, they lack the direct interpretability of text. Developing richer visualization tools for the learned budget allocations would make the memory-use process more transparent.

Summary updated

BibTeX
@misc{feng2026elasticmem,
  author = {Tao Feng and Chongrui Ye and Tianyang Luo and Jingjun Xu and Xueqiang Xu and Haozhen Zhang and Ge Liu and Jiaxuan You},
  title = {{ElasticMem: Latent Memory as a Learnable Resource for LLM Agents}},
  year = {2026},
  eprint = {2605.30690},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.30690},
}
Figure