Papers
Topics
Authors
Recent
Search
2000 character limit reached

SelfMem: Self-Optimizing Memory for AI Agents

Published 4 Jul 2026 in cs.CL | (2607.03726v1)

Abstract: While current AI agents support increasingly long context windows, tool use, and skill execution for long-horizon tasks, they still require memory systems to effectively leverage historical experience. Existing memory frameworks typically rely on fixed storage, retrieval, and summarization mechanisms, which can be rigid across different tasks and often require manual tuning. To address this limitation, we propose SelfMem, a self-optimizing memory framework. Inspired by prior work on self-improving AI, we follow the principle of "teaching an agent to fish rather than giving it a fish." Instead of forcing the model to follow a predefined memory strategy or format, SelfMem provides an environment with memory tools and feedback signals that allow the agent to explore, evaluate, and refine its own memory strategy. Our results show that SelfMem consistently outperforms retrieval, compression, and agent-memory baselines on BEAM across conversation scales from 100K to 1M tokens. Compared with the strongest baseline, SelfMem improves the official score by 48.7%, 40.8%, and 41.9% at 100K, 500K, and 1M, respectively. Further question-type analysis shows broad robustness across diverse memory demands, and our optimization study shows that model-guided strategy refinement further improves performance.

Summary

  • The paper introduces a self-optimizing memory framework, enabling adaptive memory management via agent-driven diagnostic feedback.
  • It details a flexible system leveraging iterative review and strategy revision, outperforming baselines like RAG in performance and cost-efficiency.
  • Experimental results demonstrate significant gains on BEAM benchmarks across varied token scales while eliminating embedding costs.

SelfMem: A Self-Optimizing Memory Framework for AI Agents

Motivation and Problem Statement

The increasing capability of LLM-based agents to operate in long-horizon, multi-turn, and tool-augmented scenarios fundamentally elevates the requirements for scalable, adaptive memory systems. Most contemporary memory frameworks—such as RAG, MemGPT, and MemoryBank—utilize fixed strategies for memory storage, retrieval, and summarization, which lead to rigidity and lack of adaptability across heterogeneous tasks and histories. This rigidity impedes robust performance as context length and task diversity grow.

SelfMem directly addresses this limitation by making memory management itself an agent-driven, optimization-based process. Rather than prescribing a static memory schema, the SelfMem framework exposes a memory toolset and a suite of diagnostic and operational feedback signals, empowering the agent to iteratively learn and refine memory behaviors in response to empirical context demands. Figure 1

Figure 1: SelfMem's philosophy: guide agents to self-optimize memory by enabling principled, trade-off-aware strategy search instead of implementing rigid, predefined schemes.

SelfMem Framework: Architecture and Mechanisms

SelfMem formalizes memory management as a model-intrinsic control problem: beginning with an immutable transcript store (serving as the factual ground truth), the agent maintains a memory workspace via exposed actions such as read, write, review, compress, merge, and probe. The agent iterates through a tool-use loop, observing prior operations and diagnostics, selecting actions adaptively, and updating the workspace in an auditable, rationale-tracked manner.

Key architectural elements include:

  • Transcript Store: A read-only, auditable SQLite DB that provides efficient chronological access and prevents loss of detail inherent in premature summarization.
  • Memory Workspace and Tools: The workspace is flexible, supporting arbitrary agent-selected structures (profile, project-state, canonical facts, etc.). Tools span transcript/memory-read, memory-write, memory-review (diagnostics), and memory-probe (self-testing) operations.
  • Feedback and Diagnostics: Unlike scalar rewards, feedback comprises fine-grained diagnostics—memory operation efficacy, token/cost stats, source grounding checks, and staleness/contradiction audits.
  • Iterative Memory Construction Loop: Rather than one-shot summary induction, the agent performs repeated inspect–write–review–revise cycles, leveraging feedback to optimize memory policy dynamically.

This paradigm decouples memory constraints (framework-level) from memory strategy (agent-level), creating a procedural optimization surface over task- and environment-driven trade-offs (precision vs. cost; stability vs. recency).

Experimental Evaluation and Results

Experiments leverage the BEAM benchmark across varying context scales (100K, 500K, 1M tokens) with over 100 conversations and 2,000 probing questions emphasizing information extraction, summarization, temporal/multi-session reasoning, and event ordering. All models operate under consistent answer and judging protocols, with GPT-5.4-nano for answer generation and GPT-5.4-mini as judge.

Performance Analysis:

  • SelfMem achieves the highest scores at all scales, improving over the strongest non-SelfMem baseline (RAG) by 0.165, 0.141, and 0.134 points at 100K, 500K, and 1M tokens, respectively. Pass0.5_{0.5} rates are increased by 17.0%, 14.9%, and 14.3% respectively, indicating robust answer quality even as conversation length increases.
  • Strong numerical results show that these gains are not cost-dependent; several heavy baselines (e.g., Mem0, MemGPT, A-Mem) incur significantly greater token and API costs without matching SelfMem's accuracy or robustness.
  • SelfMem requires zero embedding requests compared to embedding-heavy retrieval-centric approaches—demonstrating superior cost-efficiency.
  • The framework remains robust across question types and scales, outperforming alternatives in 9/10, 8/10, and 7/10 BEAM categories at 100K, 500K, and 1M, respectively. Figure 2

    Figure 2: SelfMem's question-type performance on BEAM; it achieves top or near-top scores consistently across diverse memory evaluation axes.

Procedural Strategy Optimization and Refinement

A defining feature is the ability to further optimize memory strategies via aggregate feedback. SelfMem exposes strategy notes as model-editable objects, yielding an iterative loop: propose-refine-evaluate-revise. Using held-out splits to restrict overfitting, experiments show that model-guided strategy revision yields further improvements in held-out performance—from an initial held-out score of 0.472 (default strategy) to 0.497 (final refined agent-synthesized policy), with the best discovered strategy reaching 0.510.

Optimization benefits do not scale simply with iteration count or training set size: gains arise specifically from discovering improved procedural heuristics on what to store, merge, or ignore—emphasizing agent-awareness of information stability, redundancy, and future retrievability. Figure 3

Figure 3: SelfMem refinement: BEAM held-out scores improve across iterations and training splits, indicating a tangible optimization surface for memory strategies.

Discussion and Implications

SelfMem challenges conventional, static memory pipelines by reframing memory as a self-optimizing, agent-editable policy underpinned by continuous diagnostic feedback. The empirical results contradict the prevailing notion that memory pipeline complexity/cost is necessary for robust long-context reasoning in LLM agents. Instead, a model-driven refinement loop with strategic action space and auditable feedback yields greater generalization, stability, and efficiency.

Practical implications include:

  • Deployment Flexibility: SelfMem's agent-driven adaptability is favorable for live agent deployment where task distribution, conversation scale, and user needs evolve over time.
  • Theoretical Insights: The work reinforces the paradigm of treating memory strategy as a latent, learnable policy variable in agentic architectures, blurring lines between architectural and reinforcement-level optimization.
  • Future Directions: Extending the refinement protocol to broader datasets, model classes, and real-world interactive settings will further test the limits of agent-driven procedural memory learning. The diagnostic feedback pathways provided by SelfMem could also serve as scaffolding for RL-based or meta-learning approaches in memory management.

Conclusion

SelfMem presents a rigorous framework for endowing agents with self-optimizing, diagnostic-driven memory control. By shifting memory construction, revision, and compression from fixed system pipelines to adaptive agent policies, SelfMem achieves superior accuracy, robustness, and cost-efficiency in large-context conversational reasoning. Furthermore, its procedural refinement methodology demonstrates the practical learnability of agentic memory strategies from aggregate, non-supervisory feedback—enabling continual advancement without recourse to retraining or over-engineered system design.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

Tweets

Sign up for free to view the 1 tweet with 0 likes about this paper.