Persistent Memory for AI Agents: User Profiles, RAG Retrieval, and the Two-Layer Architecture That Enables Proactive Service
Agent products that cannot remember users across sessions stall at reactive Q&A; the two-layer architecture here is a concrete path to proactive service, and the PR-based update flow gives production teams a way to keep memory and knowledge trustworthy under multi-tenant constraints.
Persistent memory for AI agents splits into two scales that share the same machinery. User memory extracts stable facts about one person from conversation and stores them as atomic notes, narrative paragraphs, JSON cards, or executable Python state. Knowledge bases hold shared domain knowledge and run on the full RAG stack: chunking, dense and sparse embeddings, hybrid fusion, and neural reranking. Both scales hit the same failure modes: conflicting facts, stale knowledge, and retrieval misses.
A three-level evaluation framework (basic recall, multi-session retrieval, proactive service) shows why proactive service is hard: it needs both a global overview and precise details at the same time. The architecture that survives the experiments is two-layered. Advanced JSON Cards keep a few critical facts structured and resident in context; contextual retrieval, which prepends LLM-generated background prefixes to chunks, pulls exact dialogue details on demand. Anthropic's numbers appear in the same argument: prefixing chunks cuts retrieval failure by 49% with BM25 and 67% with a reranker.
Knowledge maintenance gets the same discipline as code review. Every update is a PR proposed by one agent and independently reviewed by a second agent from a different model family, with raw evidence as ground truth and derived indexes rebuilt only after merge. Retrieval-side security is explicit too: retrieved content is data, not instructions, and side-effectful actions need a separate authorization decision.
Moving conflict resolution from write time to query time, as Mem0 v3 does, trades a tidy memory store for auditability: old facts survive as timestamped entries and the retriever has to decide which one is current. For user memory, that is the safer default because a wrong DELETE is unrecoverable.
Treating knowledge updates as a two-agent code review is a process answer to a model problem: LLM-generated edits can silently destroy information, so the fix is evidence-backed diffs, cross-model reviewers, and CI before merge rather than a smarter prompt.
The black-cat/white-cat and Xfinity examples make the general point that raw chunks are not knowledge. Similarity retrieval cannot count, generalize, or exclude, so aggregation and rule extraction must happen at index time.
Storing multimodal embeddings in context at one token per face or voiceprint is a surprisingly cheap way to give agents perceptual memory; the tradeoff is that it only works within the context window, while Engram-style parameter insertion scales further but needs special pretrained models.
The two-layer memory architecture resolves the structured-versus-unstructured debate by refusing to choose: always-on JSON Cards supply the overview, contextual retrieval supplies the detail, and neither alone satisfies the proactive-service level defined earlier.
Single-session context and cross-session memory are indeed two different things. Making user memory into "what kind of person this is" rather than storing every sentence is a clearer analogy than piling up chat logs. On the knowledge-base side, it is shared domain material for everyone; conflicts, staleness, and biased retrieval will trip up both sides together. I would especially like to see how, after memory compression, old preferences and newly stated preferences clash — which one wins. If the article had eviction rules, it would feel more grounded.
Compression solves "what to store, what to delete"; conflict resolution solves "when two entries don't match, which one to trust" — the article deliberately did not write it as an unconditional "always trust the latest." Current consolidation tends to keep only the latest; Mem0 v2 does UPDATE on write, while v3 keeps both entries and decides the current one at query time by recency/retrieval evidence; the knowledge-base side emphasizes scenario constraints, so both can be valid. Eviction from compression mainly relies on access, decay, and uniqueness; an old summary should not override a preference the user just corrected. What you care about — concrete implementation (type × conflict × deletability) — is indeed the next cut to add, agreed.
Type, conflict, and whether it can be deleted — these three columns are more useful than piling up another set of storage terms. In my implementation, I would mark a preference the user just corrected as something that cannot be overwritten by an old summary, and pick the current one by time at query time, so compression does not swallow back the tone they just changed.