MemPro: Agentic Memory Systems as Evolvable Programs¶
Conference: EMNLP 2026
Paper: ACL Anthology
Code: https://github.com/wanghai673/MemPro
Area: LLM Reasoning
Keywords: Agentic Memory Systems, Evolvable Programs, MCR Pipeline, Failure-Mode-Guided Refinement, Tree-Structured Evolution
TL;DR¶
MemPro treats the entire Memory Construction–Retrieval (MCR) pipeline as an evolvable program combining prompts and executable code, maintaining a runnable version tree where an Evolving Agent performs failure-mode-guided edit-debug refinement to surpass static architectures and prompt-only evolution methods within a few iterations.
Background & Motivation¶
Sustaining long-horizon autonomous interactions and complex reasoning requires large language model (LLM) agents to overcome finite context window constraints, retaining historical interactions, tracking dynamic state shifts, and retrieving salient context on demand. Mainstream agentic memory frameworks typically follow a Memory Construction–Retrieval (MCR) paradigm: raw interaction segments are processed to construct and maintain a structured memory bank, while a downstream retrieval module selects relevant memories to inform answers to incoming queries. However, existing systems treat the stored memory bank as the sole adaptive component, keeping the surrounding MCR pipeline completely static and rigid after initial deployment.
This fixed-pipeline paradigm suffers from two fundamental limitations. First, task heterogeneity creates varied failure patterns across distinct reasoning benchmarks: temporal reasoning demands precise chronological ordering and tracking of recent updates, whereas multi-session reasoning hinges on aggregating disjoint pieces of evidence across extended interaction sessions. Applying a static retrieval and integration strategy across diverse tasks inevitably degrades performance. Second, memory–pipeline misalignment emerges as memory banks expand in scale and structural complexity over time, causing a fixed pipeline logic to diverge from the underlying organization of stored knowledge, ultimately resulting in incomplete retrieval, severe context pollution, and ineffective evidence utilization.
While recent prompt-level optimization frameworks attempt to adjust text instructions, they are fundamentally incapable of modifying executable control flow, data transformation routines, or algorithmic decision rules. To overcome these constraints, this paper advocates broadening memory self-evolution to the system level. Core idea: Treat the entire memory construction and retrieval pipeline as an evolvable program consisting of both prompts and executable code, exploring a version tree of runnable implementations via failure-mode-guided edit–debug refinement driven by an autonomous Evolving Agent.
Method¶
Overall Architecture¶
MemPro establishes and maintains an MCR version tree \(\mathcal{T} = (\mathcal{V}, \mathcal{E})\), where each node represents a fully runnable pipeline implementation \(F_v\) paired with its comprehensive evaluation log \(L_v\). Evolution initiates from a baseline, human-designed root version \(v_0\). Across outer evolution iterations, an autonomous Evolving Agent executes a three-stage closed loop: first, it inspects historical evaluation logs across the version tree to select the most promising parent node; second, it conducts an inner iterative expansion consisting of failure-mode-guided code editing and single-trace targeted debugging to generate a verified child version; third, it executes the new pipeline across the training split to produce execution logs and registers the candidate into the version tree. Maintaining a tree topology enables branching and exploration from robust ancestor checkpoints, preventing the system from becoming trapped in regressions typical of linear optimization trajectories.
%%{init: {'flowchart': {'rankSpacing': 24, 'nodeSpacing': 28, 'padding': 6, 'wrappingWidth': 400}}}%%
flowchart TD
A["Initial MCR Pipeline v0<br/>(Construction/Retrieval/Integration Code & Prompts)"] --> B["Parent Selection & Multi-Metric Diagnosis<br/>LogReader + BaseSelector"]
B --> C["Failure-Mode-Guided Edit & Targeted Debugging<br/>CodeEditor + DebugRunner"]
C -->|Inner expansion not terminated| C
C -->|Inner loop terminated| D["Pipeline Evaluation & Version Tree Registration<br/>BenchmarkRunner + RegistryWriter"]
D -->|Update version tree & evaluation logs| B
D --> E["Optimal Pipeline Task-Time Deployment<br/>(Tri-channel BM25/Vector/PageID Retrieval & Dynamic Integration)"]
Key Designs¶
1. Parent Selection and Multi-Metric Diagnosis: Balancing Overall Fitness and Failure Pattern Resolution
Linear, chain-based greedy evolution easily stalls in local optima or suffers from catastrophic regression when an aggressive edit fails. MemPro mitigates this by maintaining a version tree where the Evolving Agent uses LogReader to aggregate logs across all tree nodes \(v \in \mathcal{V}\). Each log \(L_v = (S_v, C_v, \text{pa}(v), A_v)\) encapsulates the overall average training score \(S_v\), category-level performance metrics \(C_v\) that pinpoint specific architectural weaknesses, the parent node reference \(\text{pa}(v)\), and an overall diagnostic summary \(A_v\) analyzing recurring failure modes. Guided by BaseSelector, the agent chooses parent node \(v^\star_\ell\) based on three core criteria: prioritizing versions with high overall benchmark accuracy, favoring branches that present generalizable improvement vectors without severe regressions, and targeting persistent, well-diagnosed categorical vulnerabilities. This allows the search to branch flexibly into distinct functional specializations while retaining the ability to backtrack to robust ancestors if a child branch regresses.
2. Failure-Mode-Guided Edit and Targeted Debugging: Code-Level Programmatic Refinement Beyond Prompt Text
Restricting evolution to textual prompts leaves the underlying data flow and control logic untouched, whereas full training re-evaluation during every code tweak is computationally prohibitive. MemPro resolves this via an inner expansion process where the Evolving Agent iteratively chooses between EDIT, DEBUG, and TERMINATE actions. During code editing via CodeEditor, the agent revises not only natural language prompts but also Python algorithmic logic—such as introducing question-type-aware dynamic integration dispatchers, explicit counting and temporal interval calculation routines, adaptive retrieval depth controllers, and salient snippet extraction mechanisms. During debugging, the agent invokes DebugRunner on a targeted diagnostic failure case \(x^\text{diag}_j\) rather than re-evaluating the entire training split, inspecting full execution trace \(\tau_j\) via TraceInspector. This targeted verification detects syntax errors and logical flaws early, refining the implementation until a stable, coherent child version triggers TERMINATE.
3. Pipeline Evaluation and Version Tree Registration: Closed-Loop Verification and Memory Artifact Reuse
Modifying pipeline components can inadvertently invalidate existing memory banks or disrupt data representation consistency. To enforce strict quality control, the verified candidate version \(F_{u_\ell}\) undergoes full execution across training split \(\mathcal{D}_\text{train}\) using BenchmarkRunner to assemble execution traces \(\Gamma_{u_\ell}\). The Evolving Agent applies Ieval to generate evaluation log \(L_{u_\ell}\) detailing new category scores and failure patterns. Crucially, MemPro incorporates an explicit memory artifact reuse protocol: if modifications are confined to the Research Agent (retrieval query planning, evidence aggregation, or answer formatting), pre-computed memory bank representations are reused without re-indexing; conversely, if changes alter the Memory Agent (chunking boundaries, abstraction prompts, or storage schemas), the memory bank is systematically re-indexed. The resulting node \(u_\ell\) is formally linked to \(\text{pa}(u_\ell) = v^\star_\ell\) and registered via RegistryWriter to guide subsequent evolutionary cycles.
Loss & Training¶
MemPro performs no parametric gradient updates on the underlying language model weights; rather, it conducts offline discrete structural optimization over executable Python source code and prompt specifications. Throughout the evolution process, the task-level Memory Agent and Research Agent employ gpt-4o-mini (temperature 0.0, top-p 1.0), while the meta-level Evolving Agent is implemented on an OpenAI Codex coding harness driven by gpt-5.4-medium. Hyper-parameters cap the maximum outer evolution iterations at \(T=15\) and inner expansion steps at \(J=20\). Training splits used during evolution are compact to prevent data memorization (sampling 10% or 50 instances on LongMemEval, 154 instances on LoCoMo, and 30 instances across context lengths on HotpotQA). Once evolved, the best-performing pipeline is deployed zero-shot at inference time and transfers robustly across distinct backbones including Qwen3-30B-A3B-Instruct-2507 and Qwen2.5-14B.
Key Experimental Results¶
Main Results¶
MemPro is evaluated across two representative agentic long-term memory benchmarks—LongMemEval (spanning temporal reasoning, multi-session, knowledge update, single user, single assistant, and user preference) and LoCoMo (covering multi-hop, open-domain, single-hop, and temporal questions)—and two complex long-context QA benchmarks, HotpotQA and NarrativeQA. Baselines encompass full-context ingestion, Naive RAG, static memory systems (Mem0, A-MEM, MemoryOS, LightMem, SimpleMem, GAM), and prompt-evolution frameworks (GEPA, MetaMem).
| Benchmark | Backbone Model | Metric | MemPro-15 (Ours) | GAM (Strong Static) | GEPA (Prompt Evolution) | Relative Improvement / Finding |
|---|---|---|---|---|---|---|
| LongMemEval | gpt-4o-mini | Avg. Acc | 79.00 | 72.40 | 75.60 | +6.60 vs GAM; +3.40 vs GEPA |
| LongMemEval | Qwen3-30B-A3B | Avg. Acc | 80.80 | 72.80 | 76.20 | +8.00 vs GAM; +4.60 vs GEPA |
| LoCoMo | gpt-4o-mini | Avg. Acc | 84.93 | 80.45 | 79.50 | +4.48 vs GAM; +5.43 vs GEPA |
| LoCoMo | Qwen3-30B-A3B | Avg. Acc | 77.85 | 74.46 | 75.77 | +3.39 vs GAM; +2.08 vs GEPA |
| HotpotQA (56K) | gpt-4o-mini | F1 | 70.32 | 63.22 | - | +7.10 F1 over GAM at 56K context |
| HotpotQA (224K) | gpt-4o-mini | F1 | 65.81 | 61.46 | - | +4.35 F1 over GAM at 224K context |
| HotpotQA (448K) | gpt-4o-mini | F1 | 64.02 | 59.81 | - | +4.21 F1 over GAM at 448K context |
| NarrativeQA | gpt-4o-mini | F1 | 38.12 | 36.86 | - | Outperforms all static agentic systems |
| NarrativeQA | Qwen2.5-14B | F1 | 31.23 | 30.17 | - | Consistent SOTA under open-weight LLMs |
Note: MemPro-5 already achieves state-of-the-art results across all evaluated benchmarks and backbones within only 5 evolution iterations (e.g., reaching 75.77/76.96 on LongMemEval and 81.94/76.33 on LoCoMo), surpassing all non-MemPro baselines.
Ablation Study¶
Ablations on LoCoMo evaluate the contribution of individual framework components and retrieval tools against the full 15-iteration MemPro pipeline (reported in LLM-as-a-Judge Accuracy %):
| Configuration | gpt-4o-mini | Qwen3-30B-A3B-Instruct | Key Takeaways & Component Analysis |
|---|---|---|---|
| MemPro (Full, 15 Iterations) | 84.93 | 77.85 | Complete system combining code evolution, version tree, and inner debugging |
| w/o Code (Prompt Evolution Only) | 81.69 | 74.83 | Drops -3.24 / -3.02; confirms programmatic logic edits exceed prompt tuning ceiling |
| w/o Version Tree (Chain Evolution) | 80.84 | 73.54 | Drops -4.09 / -4.31; linear progression cannot escape regression nodes or branch |
| w/o Evolution (Initial Un-evolved v0) | 77.33 | 72.35 | Drops -7.60 / -5.50; underscores massive gap between human design and evolved SOTA |
| w/o Iterative Expansion (Single Edit) | 81.23 | 74.27 | Drops -3.70 / -3.58; single-shot editing without inner targeted debugging is brittle |
| Retrieval Ablation: w/o BM25 | 72.25 | 65.44 | Largest retrieval drop (-12.68 / -12.41); exact keyword matching is foundational |
| Retrieval Ablation: w/o Embedding | 82.57 | 75.67 | Drops -2.36 / -2.18; dense embeddings are crucial for resolving lexical mismatches |
| Retrieval Ablation: w/o PAGE-ID | 84.37 | 77.12 | Drops -0.56 / -0.73; structural page localization provides useful grounding |
Key Findings¶
- Executable Code Evolution Solves Structural Bottlenecks: In the LoCoMo evolution trajectory, accuracy rises from 77.33% to 84.93%, with primary step gains driven by executable code modifications: question-type-aware dynamic integration boosts accuracy from 79.10 to 80.88, explicit count and duration calculation logic yields 82.12, adaptive retrieval depth yields 83.46, and focused evidence snippet extraction achieves 84.93. In contrast, prompt refinement targeting temporal format yields only an initial modest gain (79.10).
- Version Tree Overcomes Non-Monotonic Regressions: The evolution dynamics exhibit intermediate dips where exploratory programmatic edits cause regressions on edge cases. The version tree structure preserves historically strong ancestor checkpoints, allowing the optimizer to branch into alternate directions rather than propagating faulty code down a single chain.
- Favorable Performance-to-Cost Profile: MemPro achieves superior accuracy while using substantially fewer inference tokens than Full Text and operating within a token budget comparable to GAM and GEPA, offering a compelling trade-off between task performance and runtime efficiency.
Highlights & Insights¶
- Shifting From Static Memory Architectures to Evolvable Programs: Replaces the conventional perspective of agentic memory as a "fixed database + static prompts" with a paradigm where data ingestion, indexing, and multi-turn retrieval control flows are self-compiling programs optimized directly by LLMs.
- Targeted Single-Trace Debugging via DebugRunner: Introducing targeted execution on representative failure cases during inner expansion avoids full-dataset evaluation at every code adjustment, enabling efficient verification of syntax and algorithmic logic.
- Cross-Model Zero-Shot Program Transferability: Pipelines evolved with gpt-4o-mini transfer seamlessly to completely disparate architectures like Qwen3-30B-A3B, preserving performance superiority and demonstrating that programmatic discoveries represent general reasoning heuristics rather than model-specific prompt tricks.
Limitations & Future Work¶
- Offline Evolution Computational Overhead: The framework requires an upfront offline evolutionary search driven by capable coding models (e.g., gpt-5.4-medium), incurring computational cost prior to deployment.
- Underperformance on Single-Assistant Queries under Lightweight Backbones: On LongMemEval's Single-Assistant category under gpt-4o-mini, MemPro scores 60.71%, trailing raw Full Text (89.29%) and RAG (98.21%). Abstractive memory construction often compresses away the assistant's exact historical phrasing, which is penalized under strict reference matching, exacerbated by sparse training representation (only ~6 instances in the evolution set).
- Absence of Multi-Parent Recombination: Current version trees support only single-parent derivation. Exploring graph-structured evolutionary topologies that allow cross-over and recombination of complementary features from independent branches remains an open direction.
Related Work & Insights¶
- vs Static Agentic Memory Systems (Mem0, LightMem, GAM): Static architectures rely on fixed heuristic rules and hardcoded research loops. MemPro can initialize from any of these architectures as root node \(v_0\) and automatically optimize their execution logic for specific task distributions.
- vs Prompt-Level Evolutionary Optimizers (GEPA, MetaMem): Prompt optimizers use textual reflection to tune instructions but cannot modify algorithmic execution paths, data filtering routines, or numerical aggregation logic; MemPro expands the search space to executable Python programs.
Rating¶
- Novelty: ⭐⭐⭐⭐⭐ [Pioneering framing of agentic memory pipelines as evolvable programs combining code and prompts]
- Experimental Thoroughness: ⭐⭐⭐⭐⭐ [Extensive evaluations across 4 benchmarks, diverse context lengths, open and closed backbones, detailed ablations, and evolutionary trajectory analyses]
- Writing Quality: ⭐⭐⭐⭐⭐ [Rigorous formal definitions, transparent descriptions of the MCR version tree, and clear ablation breakdowns]
- Value: ⭐⭐⭐⭐⭐ [Offers a robust, extensible methodology for autonomous self-improving agent architectures in long-horizon reasoning tasks]