NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

SelfMem: Self-Optimizing Memory for AI Agents

Shu Yang, Junchao Wu, Derek F. Wong, Di WangarXiv 2026

TL;DR

SelfMem introduces a paradigm shift in agent memory by replacing rigid, human-engineered storage and retrieval pipelines with an agent-controlled optimization process. By equipping agents with memory tools and multi-dimensional feedback (such as cost, token count, and accuracy), SelfMem allows agents to dynamically learn how to manage their own memory, outperforming traditional baselines by over 40% on long-context tasks while drastically reducing API costs.

What Problem Does This Paper Address?

While modern LLMs boast increasingly massive context windows, long-horizon tasks still require effective memory systems to prevent agents from becoming slow, expensive, or overwhelmed by irrelevant information.

Existing agent-memory frameworks (like RAG, MemGPT, or MemoryBank) rely on fixed, hand-crafted strategies to decide what to store, compress, or retrieve. These static pipelines are inherently rigid: a strategy that works perfectly for tracking user preferences in a chat might fail miserably when tracking project states or chronological event orderings. To address this, the authors propose moving away from manually tuned memory architectures and instead letting the agent dynamically optimize its own memory strategy based on environmental feedback.

Methods

SelfMem operates on the principle of "teaching an agent to fish rather than giving it a fish." Instead of forcing a predefined schema, the framework provides an environment containing:

  1. An Immutable Transcript Store: The raw conversation history is stored as a read-only SQLite database, allowing the agent to perform precise SQL queries rather than relying on arbitrary text chunking.
  2. A Memory Workspace: A flexible, model-managed scratchpad where the agent can organize information in whatever format it finds most useful.
  3. A Memory Action Space: A set of tools enabling the agent to inspect the transcript, write/revise memory (e.g., merge duplicates, archive stale data), and review memory quality.
  4. Multi-Dimensional Feedback Signals: Rather than a single scalar reward, the agent receives detailed feedback on token usage, API cost, latency, cache reuse, and memory diagnostics.
Concept of teaching an agent to fish vs. giving it a fish

Using these components, SelfMem establishes an inspect–write–review–revise loop. Furthermore, SelfMem employs a global strategy optimization process: over multiple iterations across training conversations, the agent reflects on aggregate performance and refines a "procedural strategy note" that guides its memory behavior in future, unseen tasks.

Figure 2: Overview of SelfMem. The raw transcript is kept as an immutable source of truth, while the agent is given a memory action space for inspecting the transcript, writing and revising memory, and reviewing memory quality.

Datasets

The authors evaluated SelfMem using the BEAM benchmark, a dataset designed to test long-term memory over extended interactions across 100K, 500K, and 1M token scales. The benchmark covers diverse memory demands, including information extraction, temporal reasoning, multi-session reasoning, and event ordering. Conversations 0–8 were used as the training split for strategy refinement, while conversations 9–19 served as the held-out test split.

Key Insights and Ideas

  • Heavier Infrastructure $\neq$ Better Memory: A common trend in agent design is building increasingly complex memory layers (e.g., continuous graph extraction, heavy embedding ingestion). SelfMem proves that giving the model agency over simple tools is more effective and significantly cheaper than running exhaustive, fixed background ingestion pipelines.
  • The Emergence of Low-Churn Strategies: When optimized, the agent naturally converged toward a compact-memory policy. It learned to reject transient, scenario-local details and instead prioritize stable, high-signal user constraints. It favored replacing and merging older items over continuously appending new ones, preventing memory bloat from diluting retrieval quality.
  • Language as an Optimization Surface: SelfMem demonstrates that memory management can be optimized purely in the space of natural language. By reading aggregate diagnostics, the model successfully rewrote its own procedural rules to achieve better downstream accuracy.

Key Results

SelfMem consistently achieved the highest official scores and pass rates ($Pass_{0.5}$) across all token scales (100K, 500K, and 1M), outperforming specialized baselines like MemGPT, Mem0, and LoCoMo.

  • Performance Boost: Compared to the strongest non-SelfMem baseline (RAG), SelfMem improved the official BEAM score by 48.7% at 100K, 40.8% at 500K, and 41.9% at 1M tokens.
  • Cost Efficiency: At the 1M token scale, Mem0 cost $18.830 and MemGPT cost $12.264 due to heavy LLM and embedding calls. In contrast, SelfMem achieved vastly superior accuracy for just $2.004 and required zero embedding requests.
  • Robustness: Heatmap analysis across question types showed that SelfMem wasn't just gaming a specific category; it achieved the best score on 9/10 question types at 100K and 7/10 at 1M tokens.
Downstream score improvement across optimization iterations

Limitations and Future Work

While promising, the authors note several limitations:

  • Benchmark Breadth: The framework was validated exclusively on the BEAM benchmark using the GPT-5.4-nano/mini model family. Future work is required to verify how well these self-optimizing strategies generalize to other benchmarks and model families.
  • Scalability of Refinement: Due to cost constraints, the iterative strategy-refinement study was only executed at the 100K token scale. Scaling the meta-optimization process itself to 500K and 1M histories remains an open engineering challenge.
  • Production vs. Harness Profiles: The baselines were evaluated inside a shared evaluation harness for fairness, meaning highly optimized production implementations of frameworks like Mem0 might exhibit different efficiency profiles in the wild.

Summary updated

BibTeX
@misc{yang2026selfmem,
  author = {Shu Yang and Junchao Wu and Derek F. Wong and Di Wang},
  title = {{SelfMem: Self-Optimizing Memory for AI Agents}},
  year = {2026},
  eprint = {2607.03726},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.03726},
}
Figure