Dynamic Affective Memory Management for Personalized LLM Agents


TL;DR

This paper proposes a dynamic emotional memory management system called DAM-LLM. By introducing a Bayesian-inspired update mechanism and the concept of memory entropy, it enables an intelligent agent to autonomously maintain a dynamically updated memory database, addressing the problems of redundancy, obsolescence, and poor consistency in traditional static memory, thereby providing more personalized emotional interactions.

Key Definitions

This paper proposes or adopts the following core concepts:

At present, mainstream research in the field of emotional dialogue focuses on using methods such as reinforcement learning to enable agents to dynamically adjust emotional strategies during real-time interaction, thereby achieving better interaction outcomes. However, these works generally overlook how to persistently store, evolve, and effectively utilize users’ long-term emotional history, failing to form a coherent memory system with personalized cognition.

In the field of agent memory management, existing architectures are mostly based on Retrieval-Augmented Generation (RAG). Although some work has improved this by using hybrid retrieval, optimizing the retrieval process (such as Selfmem), or building external memory banks (such as MemoryBank), two major bottlenecks remain:

  1. Static and incoherent memory: Traditional methods store interactions as a collection of isolated facts and cannot synthesize multiple interactions into an evolving understanding of the user, leading to contradictions when the user’s attitude changes.
  2. Memory bloat and noise: Storing all interactions indiscriminately causes the memory bank to grow without bound, increasing retrieval latency and computational overhead while also introducinga large amount of noise, making it difficult to retrieve key information—the “needle in a haystack” problem.

This paper aims to address the above issues, especially how to dynamically model and manage long-term emotional memory, in order to overcome the limitations of traditional RAG architectures in handling emotional fluctuations and to maintain memory consistency and efficiency.

Method

This paper proposes an agent framework for emotional dialogue called DAM-LLM, whose core is dynamic emotional memory management. The framework optimizes the memory system by minimizing global belief entropy, transforming memory management from passive storage into an active cognitive process.

System Architecture

DAM-LLM consists of three core components: a central Master Agent, a two-stage hybrid retrieval module, and a distributed memory unit network. Together, these form a closed-loop cognitive architecture. The system drives dynamic memory optimization by minimizing the global belief entropy $\sum_{m\in M}H(m)$, maximizing certainty in modeling user preferences. The Master Agent uses belief entropy as a global perceptual signal to coordinate Bayesian memory updates, semantic retrieval, and entropy-driven compression.

Figure illustration

DAM-LLM Agent

The collaborative workflow of the system is completed by multiple agents, forming a complete closed loop from problem understanding to memory operations and response generation.

Figure illustration

  1. Input Routing: The routing agent analyzes user intent and decides whether the current input should trigger Store, Retrieve, or direct Generate response.

  2. Evidence Analysis and Processing: When user input $x_t$ needs to be recorded, the Extraction Agent parses it into structured emotional information in the form $\mathrm{\textit{E}\text{-}Agent}(x)\rightarrow E,Q,C,S$, which respectively represent the emotional description, retrieval query, sentiment confidence vector, and evidence strength.

  3. Memory Update and Compression: Based on the current state of the memory bank, the Master Agent processes new evidence:

    • Update: Integrate new evidence into existing memory units through a Bayesian-inspired mechanism, dynamically adjust sentiment confidence, and refresh the memory unit’s summary description.
    • Merge: Identify and merge multiple memory units about the same object but different aspects to form a more comprehensive, lower-entropy memory.
    • Delete: For memory units that consistently exhibit high entropy and low weight, the system treats them as “noise” or outdated information and deletes them, achieving active “forgetting.”

Memory Unit

The memory unit is the core of emotional memory, and its innovative design lies in transforming discrete emotional observations into a continuously updated confidence profile.

Data Structure Design

Each memory unit contains multiple fields for structured storage of emotional information.

Field Name Description
\(object_id\) Object ID
\(object_type\) Object type
\(aspect\) Aspect
\(sentiment_profile\) Sentiment profile (confidence scores)
$H$ Belief entropy
\(summary\) Summary
\(reason\) Reason

Bayesian-Inspired Update Mechanism

This is the key to enabling self-learning in the memory unit. The mechanism simulates Bayesian updating through a weighted averaging process, with the formula:

\[C_{\text{new}}=(C\times W+S\times P)/(W+S), \quad W_{\text{new}}=W+S\]

Among them, $C$ is the current sentiment confidence (prior), $W$ is its weight; $S$ is the strength of the new observed evidence, and $P$ is its confidence. This mechanism allows high-strength evidence to shape the sentiment profile more effectively while remaining robust to low-strength incidental remarks, thereby enabling smooth memory evolution.

Figure illustration

Cognitive Belief Entropy

Belief entropy $H(m) = -\sum_{k\in{\text{pos,neg,neu}}}p_{k}\log_{2}p_{k}$ is a unified metric for measuring the cognitive certainty of a memory unit.

The Master Agent’s goal is to minimize the total entropy of all memory units.

Two-Stage Hybrid Retrieval

To address the semantic drift problem in traditional vector retrieval, this paper designs a two-stage hybrid retrieval mechanism that is naturally aligned with the structure of memory units.

This “coarse filtering + fine ranking” process decouples the classification task from content retrieval. It uses lightweight metadata for efficient filtering and performs computation-intensive semantic matching only on a highly relevant subset, thereby ensuring retrieval accuracy and scalability.

Experimental Conclusions

Dataset and Implementation

To evaluate the system’s performance in emotional scenarios, this paper constructed a multi-turn dialogue dataset called DABench, focusing on user emotional expression and emotional changes. The dataset includes 2,500 observation sequences, 100 sessions (1,000 turns in total) of simulated user interactions, and 500 query-memory pairs. The experiments used Qwen-Max as the base LLM and Text-Embedding-V1 as the text embedding model.

Memory Unit Validation

Emotional accumulation and transition Emotional accumulation and transition

<img src="/images/2510.27418v1/x4.jpg" alt="Figure illustration" style="width:85%; max-width:600px; margin:auto; display:block;">

Figure illustration

Compression Algorithm Validation

Figure illustration

System Performance Evaluation

The system was evaluated from six dimensions using the LLM-as-a-judge (GPT-4) method.

Dimension Baseline Model DAM-LLM (This Paper)
Accuracy (AC) 4.31 4.35
Logical Coherence (LC) 4.02 4.28
Memory Reference Rationality (RMR) 3.86 4.25
Emotional Resonance (ER) 3.52 4.21
Personalization (Pers.) 3.56 4.33
Language Fluency (LF) 4.67 4.54

The experimental results show that, while using only about 40% of the memory, DAM-LLM significantly outperforms the baseline system in the dimensions of emotional resonance and personalization. This advantage is especially pronounced in scenarios involving large amounts of redundant memory or complex emotional evolution.

Summary

The DAM-LLM framework and its dynamic memory system proposed in this paper have been proven efficient and effective in experiments, providing a new direction for the development of memory architectures for emotional dialogue intelligent agents.