All posts
Technical
  • #agents
  • #memory
  • #security

Agent memory

12.05.2026·16 min

Agent memory

Agent Systems · 21-c04

26 June 2026 · Memory architecture

Agent memory is not endless chat history. When designed well, it is a read/write system for active tasks, past experiences, world knowledge, user preferences, and safety boundaries.

Misread
history != memory
Core
write / read / update
Value
continuity + personalization
Risk
stale + poisoned memory

Key terms in this post

  • working memory
  • episodic memory
  • semantic memory
  • procedural memory
  • preference memory
  • memory retrieval
  • forgetting
  • memory poisoning

A memory-enabled agent sounds simple: store conversations and bring them back later. In production, the questions multiply quickly: what should be stored, who may write, when should it be forgotten, and what happens when two memories conflict?

This post treats memory as engineering surface: storage, retrieval, update, forgetting, permission, and evaluation.

01/08

What is memory?

Agent memory is selected information carried from the past into future decisions.

Chat history is raw material; memory is the policy that decides what is stored, summarized, retrieved, and excluded.

Memory layer map

long-term stores

episodic memorywhat happened?
semantic memorywhat is true?
procedural memoryhow to act?
preference memoryhow do they want it?

working memory

Active goals, observations, temporary variables, and retrieved context.

The current desk. Only this reaches the model.

LLM decision + action

retrieve → relevant, permitted records move onto the desk.

← write new experience, inference, and preference flow back.

02/08

Working memory

Working memory is the agent's current desk: active goal, latest tool result, temporary plan, and parsed fields.

The prompt is only the slice shown to the model; working memory can persist across LLM calls.

Bad working memory can make good long-term memory dangerous.

Working memory example

working memory · full state

active_goal

Resolve the missing shipment request.

latest_observation

Shipping API: package stuck for three days.

retrieved_context

Customer prefers concise answers.

pending_decision

Offer refund instead of coupon?

guardrail

Refund requires human approval.

slice sent to model (prompt)

Resolve the customer's missing-shipment request. Per the shipping API the package has been stuck for three days. The customer prefers short answers. A refund needs human approval.

The controller moves only what this step needs into the prompt, not every field. Ids and raw logs stay in state.

03/08

Episodic memory

Episodic memory is the agent's experience log.

Generative Agents uses a memory stream retrieved by relevance, recency, and importance.

Reflection can make memory useful, but it can also fossilize wrong interpretations.

Episodic score

score = relevance × recency × importance

recencyimportancerelevanceevidence

Yesterday: same test broke on timezone

high relevance + recency

retrieve

Last month: a refund was denied

high importance

retrieve

6 months ago: a routine shipping delay

low recency

skip

Routine delivery notification

low importance

skip
04/08

Semantic memory

Semantic memory stores knowledge rather than events.

Read-only corpora and agent-learned facts should be separated because they do not have the same trust level.

Good semantic memory can cite where the fact came from.

Semantic memory split

read-only corpus

Catalogs, policies, runbooks.

high trust · cite source

learned facts

Inferences from episodes with evidence pointers.

hypothesis · verify with evidence

tenant scope · applies to both

Retrieval must respect authorization.

freshness · applies to both

Old facts may be stale even when well formatted.

05/08

Preference memory

Preference memory stores how a user wants to interact.

Preferences drift; recent shifts and long-term tendencies should both matter.

Preference is not authorization.

Preference drift example
t1t2t3t4

t1–t3: short, bulleted · t4: wants detail and examples

short-term · sliding window
long-term · EMA

response policy

Explain deeply, keep sections scannable.

06/08

Memory pipeline

Read memory as memory writing, memory reading, and memory management.

MemGPT separates main context from external context; stored information does not automatically enter the prompt.

The best memory systems are selective.

Storage -> retrieval -> update
external context · storemain context · prompt
1observestore

Message, tool result, error, approval, or event arrives.

2writestore

Choose memory type.

3indexstore

Add embedding and metadata.

4retrieveprompt

Select by relevance, recency, importance, and policy.

5injectprompt

Move only permitted fragments into working memory.

6updatestore

Summarize, decay, merge, resolve, or delete.

Stored does not mean in the prompt; only retrieve + inject cross the boundary.

07/08

Memory poisoning

Memory poisoning changes future behavior by inserting malicious records into long-term memory or a RAG knowledge base.

The base model need not be modified; retrieval can bring the malicious record back later.

Defense needs write-time validation, source trust, tenant isolation, retrieval monitoring, human review, and deletion paths.

Poisoning flow

t0 · attacker writes

inject

Attacker adds a targeted record.

the record waits silently

index

The record enters the normal index.

t1 · innocent query triggers

trigger

A later query retrieves it.

condition

The model trusts the context.

effect

Wrong answer or risky action follows.

The danger is not in today's prompt; it was written yesterday and detonates via retrieval tomorrow.

08/08

Design contract

The right question is not how much the agent should remember, but what kind of memory lives under which purpose, permission, duration, confidence, deletion right, and eval.

Memory makes the product more capable and more accountable.

My production rule: type memory first, retrieve second, inject third.

Memory readiness checklist
1

type

Is every record classified?

2

scope

Are tenant and user boundaries stored?

3

evidence

Do learned facts point to raw records?

4

freshness

Do old records decay or expire?

5

consent

Can users inspect and delete memory?

6

security

Are writes validated by source trust?

7

eval

Are recall, precision, stale harm, and poisoning tested?