Semantic memory · AI agents

On this page 7

Semantic memory in AI agents is the long-term store of general facts and concepts that an agent has learned about its user, its domain and its environment, held independently of the specific episodes in which those facts were acquired. It allows an agent to remember that a customer prefers metric units or that a project uses PostgreSQL across separate sessions, without replaying the conversations where it learned this.

The term is borrowed from cognitive psychology, where semantic memory means knowledge of facts and meanings, as opposed to memories of personal events. In agent design, it is one of the long-term memory types alongside episodic and procedural memory, and it is usually implemented as an external, queryable store rather than as knowledge inside the model weights.

Where semantic memory fits in agent memory

Semantic memory answers the question what does the agent know to be true, while other memory types answer different questions. Cognitive architecture frameworks for language agents, such as CoALA, divide memory into a short-term working component and several long-term components, and the boundaries between them guide what gets stored where.

The following table distinguishes the four memory types most often used in agent memory designs.

Memory typeWhat it holdsTypical exampleTypical storage
Working memoryCurrent task state and contextThe open conversation and tool resultsContext window, scratchpad
Semantic memoryFacts, preferences, conceptsThe user works in Central European TimeVector store, knowledge graph, profile
Episodic memorySpecific past eventsLast Tuesday’s failed deployment attemptLogged trajectories, summaries
Procedural memorySkills and how to actSteps for running the test suiteSystem prompts, code, skills
Memory types in AI agents

The boundary between episodic and semantic memory is consolidation. An agent that notices across several episodes that a user always asks for summaries in bullet points can turn those events into a single durable fact, which is then stored semantically and the episodes can be discarded.

How agents write and read semantic memory

Semantic memory operates through a write path that extracts and stores facts and a read path that retrieves them when relevant. Both paths are usually run by the language model itself, either through dedicated memory tools or through a background process that runs after a conversation ends.

The write path is the harder part. The agent must decide what is worth remembering, express it as a self-contained statement, check it against existing memories and resolve conflicts. The main operations are summarized below.

OperationTriggerMain risk
ExtractNew fact appears in conversation or tool outputStoring trivia or misread statements
DeduplicateSimilar fact already existsNear-duplicates crowding retrieval
UpdateNew fact contradicts an older oneKeeping both and answering inconsistently
ForgetFact expires or user requests deletionStale facts persisting indefinitely
RetrieveAgent starts a task or receives a queryMissing a relevant fact or injecting noise
Core semantic memory operations

On the read path, the agent typically embeds the current request, runs semantic search over stored facts, and inserts the top results into the prompt. Some designs always load a small core profile of high-value facts, while larger knowledge is retrieved only on demand, a split popularized by MemGPT.

Storage designs for semantic memory

The choice of storage determines how facts can be queried and how well contradictions can be managed. Most production agents combine at least two of the designs below.

Storage designBest forLimitation
Vector store of fact statementsFuzzy recall by meaningWeak at exact updates and relations
Knowledge graphEntities, relations, multi-hop questionsExtraction and schema design effort
Structured profileStable preferences and settingsOnly covers predefined fields
Plain memory filesTransparent, user-editable notesRetrieval degrades as files grow
Storage options for agent semantic memory

Each stored fact benefits from metadata: a timestamp, the source episode, a confidence level and an owner. Timestamps allow the agent to prefer recent facts, and source links make it possible to audit why the agent believes something.

Semantic memory compared with RAG and model weights

Semantic memory is often confused with retrieval-augmented generation, because both retrieve text into the prompt. The difference lies in who writes the content: a RAG corpus is curated documents maintained by people, while semantic memory is written and revised by the agent itself during operation.

It also differs from the parametric knowledge stored in model weights. Weights hold broad world knowledge fixed at training time, whereas semantic memory holds specific, changeable facts about a user or deployment that can be inspected, corrected and deleted without retraining.

In multi-agent systems, semantic memory can be private to one agent or shared among several. A shared store lets a research subagent record a confirmed fact that a writing subagent later reuses, but it also requires clear write permissions and conflict rules, because two agents may record incompatible versions of the same fact during parallel work.

Risks and design safeguards

Because the agent writes its own memory, errors compound over time. A single misunderstood remark can become a permanent false belief that shapes every later session.

  • Memory poisoning: untrusted content, such as a web page or email, can plant false facts or instructions, so writes from tool output need stricter filtering than writes from the user.
  • Stale facts: preferences and project details change, so memories need expiry rules or periodic review.
  • Privacy obligations: stored personal data must be viewable and deletable, which is required under data protection laws such as the GDPR.
  • Over-personalization: injecting too many remembered facts can distract the model and reduce answer quality.
  • Cross-user leakage: memories must be scoped strictly to the correct user or tenant.

A sound design gives users visibility and control over what the agent remembers, separates memory scopes clearly and evaluates memory quality with tests that check both recall of relevant facts and resistance to injected false ones.

The idea in brief

An AI agent normally forgets everything when a conversation ends. Semantic memory is its notebook of lasting facts. It writes down things like your time zone, your favorite format or the tools your team uses.

Next time, the agent reads the relevant notes before it answers. It does not need to remember the whole past conversation. It only keeps the useful conclusions, much as a person remembers a friend’s birthday without recalling when they learned it.

A practical scenario

A software team uses a coding agent across many short sessions. In the first week, developers repeatedly correct it: the project uses pnpm rather than npm, tests run with Vitest, and dates must be stored in UTC. Without memory, the agent repeats the same mistakes in every new session.

The team enables semantic memory with a project-scoped store. After each session, a background step extracts durable facts, checks them against existing entries and saves about a dozen short statements with timestamps. At the start of each task, the agent retrieves the five most relevant facts and adds them to its context. Repeated corrections drop sharply, and when the team later migrates to a new test runner, a developer edits one memory entry instead of retraining or rewriting prompts. The result is an agent that behaves consistently across sessions while its knowledge remains open to inspection.