MemQ: Integrating Q-Learning into Self-Evolving Memory Agents over Provenance DAGs

Junwei Liao, Haoting Shi, Ruiwen Zhou, Jiaqian Wang, Shengtao Zhang, Wei Zhang, Ying Wen, Zhiyu Li, Feiyu Xiong, Bo Tang, Muning WenarXiv 2026

TL;DR

MemQ introduces a reinforcement learning framework for LLM episodic memory that treats memories as interconnected rather than independent. By propagating credit backward through a structural "provenance Directed Acyclic Graph (DAG)" using $\text{TD}(\lambda)$ eligibility traces, MemQ ensures that early memories which indirectly enable future successes are properly valued, significantly boosting agent performance on complex, multi-step tasks.

Figure 1: High-level and conceptual illustration of MemQ.

What Problem Does This Paper Address?

Equipping Large Language Model (LLM) agents with external episodic memory allows them to learn from past experiences without undergoing expensive weight updates. However, traditional retrieval mechanisms rely on fixed heuristics like embedding similarity, which don't account for whether a memory actually led to a successful outcome.

While recent reinforcement learning (RL) methods attach Q-values to individual memories to learn their utility, they treat each memory in isolation using single-step updates. This creates a severe credit assignment problem. In multi-step tasks, memories are often interdependent: retrieving memory $A$ helps the agent generate memory $B$, which eventually leads to a successful task completion. Under existing single-step updates, memory $A$ receives no feedback and its value stagnates, even though it was vital to the causal chain of success.

Methods

The authors introduce MemQ, a novel framework that maps memory dependencies and propagates reinforcement learning signals structurally.

  1. Exogenous-Context MDP (EC-MDP): The authors formalize the environment by factoring the state space into an exogenous task stream (external tasks beyond the agent's control) and an endogenous memory store (evolved entirely by the agent's actions).
  2. Provenance DAG: When the agent retrieves a set of memories to tackle a task and subsequently creates a new memory from the experience, MemQ records the retrieved memories as the "parents" of the new memory. This forms a Directed Acyclic Graph (DAG) tracking memory lineage.
  3. Structural $\text{TD}(\lambda)$ Eligibility Traces: Instead of propagating credit across temporal time steps (as in classical RL), MemQ propagates Temporal Difference (TD) errors backward through the structural paths of the provenance DAG. The credit weight decays as $(\gamma\lambda)^d$, where $d$ is the depth or structural distance in the DAG, substituting temporal proximity with structural proximity.
  4. Two-Phase Retrieval: To select memories, MemQ first applies a locality filter (using a cosine similarity threshold to ensure the LLM can generalize from the memory) followed by a Q-guided selection step ($\epsilon$-greedy selection based on a blend of similarity and learned Q-value).
Figure 3: MemQ Framework Overview. The continuous learning loop features three stages: Retrieve: Following locality filtering, an ϵ-greedy policy selects memories via learned Q-values to contextualize the LLM. Build: Task trajectories are distilled into new memories (via proceduralization or reflection) and integrated into the provenance DAG, linked to their parents. Update: TD errors backpropagate through the DAG to assign multi-step credit and update the Q-values of all contributing ancestors.

Datasets

MemQ was evaluated across six diverse benchmarks requiring different cognitive capabilities:

  • LifeLongAgentBench (LLAB): Multi-step OS-level agent planning.
  • BFCL v3 (Berkeley Function Calling Leaderboard): Multi-turn function calling and error recovery.
  • LiveCodeBench v6: Contamination-free competitive code generation.
  • MMMU Pro: Multi-discipline multimodal reasoning.
  • ERQA: Multimodal, physically grounded question-answering.
  • GPQA Diamond: Graduate-level, Google-proof science QA.

Key Insights and Ideas

  • Structural Depth Replaces Time: The core conceptual leap of MemQ is replacing temporal step counts with DAG depth. This allows credit to flow across completely different tasks and sessions, so long as an old memory causally contributed to the formation of a successful new strategy.
  • The Exogenous Noise Factor: Because external tasks are drawn independently from a distribution, propagating credit across task boundaries introduces pure variance. The authors discovered that a lower $\lambda$ is optimal because it helps isolate the structural credit assignment from the empirical noise of unrelated tasks.
  • Task Complexity Dictates Hyperparameters: Multi-turn tasks with deep dependency chains (like function calling in BFCL) benefit significantly from a higher discount factor ($\gamma$), whereas single-turn tasks prefer moderate discounting to avoid amplifying noise from distant ancestor memories.

Key Results

MemQ achieved the highest success rate across all six benchmarks in runtime learning and five out of six in generalization/transfer evaluations:

  • Deep Chains, High Gains: The performance boost over single-step RL baselines (like MemRL) was most pronounced in complex, multi-step tasks: +5.7 percentage points (pp) on LiveCodeBench, +4.6 pp on ERQA, and +2.3 pp on BFCL.
  • Shallow Tasks, Minimal Gains: On single-step classification tasks like MMMU Pro, where single-step updates are already sufficient, MemQ still led the field but by a narrower margin (+0.77 pp), confirming that its advantages are fundamentally structural.

Limitations and Future Work

  • Computational Overhead: Maintaining the provenance DAG and running Breadth-First Search (BFS) for credit propagation incurs a cost of $O(|A_j| \cdot D)$ per task. For lifelong learning scenarios, approximate propagation mechanisms like ancestor sampling will be required.
  • Monotonic Memory Growth: The current formulation assumes memory only grows and does not address memory consolidation, pruning, or eviction, which are necessary for bounded-capacity systems.
  • Independent Task Assumption: The EC-MDP framework assumes the agent cannot influence the sequence of incoming tasks, meaning it cannot currently be applied directly to environments featuring active curriculum learning.

Summary updated

BibTeX
@misc{liao2026memq,
  author = {Junwei Liao and Haoting Shi and Ruiwen Zhou and Jiaqian Wang and Shengtao Zhang and Wei Zhang and Ying Wen and Zhiyu Li and Feiyu Xiong and Bo Tang and Weinan Zhang and Muning Wen},
  title = {{MemQ: Integrating Q-Learning into Self-Evolving Memory Agents over Provenance DAGs}},
  year = {2026},
  eprint = {2605.08374},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.08374},
}
Figure