- 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: 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:
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: 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.