Learning What to Remember: Observability-Safe Memory Retention via Constrained Optimization for Long-Horizon Language Agents

Qingcan Kang, Liu Mingyang, Shixiong Kai, Kaichao Liang, Tao Zhong, Mingxuan YuanarXiv 2026

TL;DR

This paper frames memory retention for long-horizon LLM agents as a multi-step constrained stochastic optimization problem rather than a simple heuristic choice. By introducing OSL-MR (Observability-Safe Learning for Memory Retention), the authors strictly separate online-observable features from offline supervision to train a horizon-aware memory policy. This approach significantly outperforms traditional myopic strategies like recency or static importance scoring, especially under tight token budgets.

What Problem Does This Paper Address?

As Large Language Model (LLM) agents engage in long-term interactions, they accumulate massive amounts of data—chat histories, reasoning traces, and retrieved facts. This data quickly overflows the model's context window and storage capacity, turning memory management into a high-stakes resource allocation problem.

Existing memory systems typically treat retention as a local, myopic decision. They rely on simple heuristics like keeping the most recent items (recency) or the most semantically similar ones. However, these methods fail to consider the long-term consequences of evicting a memory item, such as the future cost of re-acquiring it, the penalty of missing it entirely, or the risk of relying on stale information.

The core challenge is an information asymmetry: the ideal signals needed to evaluate a retention decision (like whether a memory will be "gold evidence" for a future query) are completely unobservable at runtime. To highlight how current methods fall short in addressing these multi-step dependencies and observability constraints, the authors compare representative approaches across five key dimensions:

Comparison of memory retention approaches across key dimensions

Methods

The authors formalize memory retention as a sequential decision-making problem under a hard budget and prove it is NP-hard. To solve it practically, they propose OSL-MR, a learning-based framework built on a strict separation between online-observable features and offline-available supervision (OAS).

Overview of the OSL-MR framework separating online features from offline supervision

The framework operates in two main components:

  1. Mixed-Score Heuristic: An online-safe baseline that combines multiple observable signals (recency, question overlap, entity overlap, speaker indicators, and size penalties) along with a type-based freshness multiplier to discount stale data. It manages the agent during a "cold-start" phase while interaction logs accumulate.
  2. Evidence Learner: A lightweight Multi-Layer Perceptron (MLP) trained offline using the accumulated logs. Instead of optimizing directly for sequence-level rewards (which are combinatorially intractable), the model learns to predict evidence membership—whether a specific memory item will be required to answer a future query.

At inference time, the trained MLP outputs a utility logit for each candidate memory. A budget-constrained knapsack decoder then sorts and greedily selects the optimal subset of memories to retain without ever violating online observability constraints.

Datasets

The authors evaluated OSL-MR on two prominent long-horizon conversational benchmarks:

  • LoCoMo: A benchmark designed for very long-term conversational memory evaluation.
  • LongMemEval: A dataset for benchmarking chat assistants over extended, multi-turn interactions.

Additionally, they built small, exactly-solvable Synthetic MDP Instances ($n=6$ memories, horizon $T=9$) to compute exact ground-truth optima via dynamic programming, allowing them to measure the absolute quality of their learned policy.

Key Insights and Ideas

  • Retention is an Operations Research Problem: Memory management in agents is fundamentally a sequential resource allocation problem under uncertainty, best modeled using classical optimization principles rather than ad-hoc heuristics.
  • The Failure of Myopic Optimization: On environments with shifting user demands, even a perfect single-step optimizer fails decisively (leaving up to a 31.5% optimality gap). It cannot anticipate the need to "pre-load" memories before their demand rises.
  • Evidence Membership as a Dense Proxy: Training a model on raw rewards is impractical because credit assignment is ambiguous across sets of memories. Predicting evidence membership provides a dense, decomposable supervision signal that aligns beautifully with the global optimization objective.
  • Static Importance Misalignment: Methods that score memories based on static importance (e.g., asking an LLM "how important is this memory?") perform poorly because they capture general salience rather than query-conditional utility.

Key Results

  • Superior Benchmark Performance: Across both LoCoMo and LongMemEval, OSL-MR consistently achieved the highest precision, recall, and F1 scores. For instance, on LoCoMo at a tight token budget of 128, OSL-MR achieved an F1 score of 0.263, vastly outperforming the Mixed-Score heuristic (0.087) and Generative Agents-style baselines (0.020).
  • Closing the Optimality Gap: On the exactly-solvable synthetic datasets, OSL-MR collapsed the myopic gap from 31.5% down to 10.1% under shifting demand, performing on par with or better than explicit lookahead planning algorithms without requiring expensive runtime rollouts.
  • Budget Efficiency: OSL-MR maintains high performance while keeping budget occupancy below saturation, proving it doesn't just blindly fill up the cache with low-utility items.

Limitations and Future Work

While OSL-MR marks a significant step forward, the authors note a few areas for improvement:

  • Heuristic Tuning: The feature groups and weights for the Mixed-Score prior are currently hand-tuned via grid search; automating this feature discovery is a clear next step.
  • Coarse Freshness Tracking: The freshness proxy relies on a simplified binary taxonomy ('stable' vs. 'temporary') and exponential decay, which could be replaced with more sophisticated semantic validity tracking.
  • Scaling Action Spaces: Future work will explore scaling these optimization-guided strategies to embodied or tool-augmented agents, where decision spaces are significantly more complex.

Summary updated

BibTeX
@misc{kang2026learning,
  author = {Qingcan Kang and Liu Mingyang and Shixiong Kai and Kaichao Liang and Tao Zhong and Mingxuan Yuan},
  title = {{Learning What to Remember: Observability-Safe Memory Retention via Constrained Optimization for Long-Horizon Language Agents}},
  year = {2026},
  eprint = {2606.10616},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.10616},
}
Figure