跪拜 Guibai
← All articles
Frontend · Backend · Artificial Intelligence

Agent Long-Term Memory Is a Governance Problem, Not a Retrieval Problem

By zhangxingchao ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Most agent memory efforts stop at vector search over chat history, which turns into a junk drawer of raw events that agents cannot reliably act on. A governance-first design — write, revise, forget, promote, scope — is what separates a memory system that actually changes agent behavior from one that just fills the prompt with noise.

Summary

A travel-planning agent that repeats the same scheduling mistake across sessions exposes the real gap: raw conversation logs and RAG-based retrieval are not long-term memory. Without a system to extract, revise, and promote experiences into stable rules, each new task starts from scratch.

The architecture that fixes this splits memory into four layers: raw episodic events, consolidated session summaries, semantic policy rules, and a dynamically built working memory. Candidate experiences are promoted to stable rules only when backed by evidence — cross-session recurrence, tool failures, or explicit user directives — and a background heartbeat handles tidying outside the request path.

Scope isolation, evidence traceability, and rollback capability prevent automatic memory from becoming automatic pollution. The final acceptance test is not whether a rule was recalled, but whether the agent’s output behavior changes in an explainable way when memory is present.

Takeaways
— RAG covers only retrieval; long-term memory also requires ingestion, revision, and forgetting to decide what should influence future behavior.
— A four-layer model — Raw Episodic, Consolidated Episodic, Semantic/Policy, and Working Memory — separates evidence storage from rule application.
— Raw events are evidence sources, not memory; reusable rules like “distant attractions need a full day” must be extracted from failures and corrections.
— Candidate memories should carry evidence (original event IDs) so they can be verified and rolled back.
— Promotion to stable rules requires cross-session recurrence, tool-failure evidence, or explicit user long-term instructions.
— The Semantic/Policy layer must stay small, high-confidence, and traceable to avoid over-generalizing one-off preferences.
— A background heartbeat handles memory tidying asynchronously so it doesn’t add latency to user-facing turns.
— Un-governed background writes risk turning automatic tidying into automatic pollution from untrusted sources.
— New tasks should receive a curated Working Memory brief, not a dump of all historical sessions.
— Every memory needs scope tags (project, user, domain) to prevent cross-contamination between agents.
— Vector databases serve as semantic recall accelerators; the source of truth must remain in structured, auditable storage.
— The real test of long-term memory is whether the agent’s output behavior changes in an explainable way, not whether a rule appeared in the recall list.
Conclusions

Framing long-term memory as a governance pipeline rather than a storage problem shifts the engineering focus from “how do we store more” to “what deserves to influence future decisions.”

The promotion step — moving a candidate memory to a stable rule only when backed by evidence — is the linchpin. Without it, every transient preference risks becoming permanent policy.

Background heartbeat processing is a double-edged sword: it keeps the interaction loop fast but creates a new attack surface where untrusted content can silently poison long-term memory.

Scope isolation is under-discussed in agent memory. A rule learned in a reimbursement context leaking into a travel planner is a failure mode that pure vector similarity cannot prevent.

The behavioral-difference acceptance test is a practical alternative to precision/recall metrics that don’t capture whether memory actually changes what the agent does.

Concepts & terms
Four-Layer Memory Model
A long-term memory architecture splitting storage into Raw Episodic (original events), Consolidated Episodic (session summaries and candidate experiences), Semantic/Policy (stable, high-confidence rules), and Working Memory (a task-specific brief built at runtime).
Memory Promotion
The process of elevating a candidate memory to a stable Semantic/Policy rule, gated by evidence such as cross-session recurrence, tool-failure signals, or explicit user long-term instructions.
Heartbeat Tidying
A background processing loop that periodically scans new raw events, triggers summarization and rule promotion, and writes checkpoints, keeping memory maintenance out of the user-facing request path.
Scope Isolation
Tagging each memory with identifiers like project_id, user_id, and domain so that rules learned in one context (e.g., expense reimbursement) do not leak into unrelated agents (e.g., travel planning).
Working Memory
A dynamically constructed, task-specific context brief — containing relevant stable rules, session summaries, and evidence sources — that replaces the naive approach of dumping all history into the prompt.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗