AI Systems · Architecture

Agent Memory Systems

AI agent memory architecture: working, session, episodic, and long-term memory for LLMs, with write rules, forgetting, privacy controls, and production evals.

Read time
16 min
Level
Advanced
Updated
2026-08-25
Components
Working context · Session store · Episodic log
The short answer

An agent memory system is a set of stores — working context, session state, episodic logs, and long-term semantic memory — with explicit write rules, retrieval at turn time, and a forgetting policy so an LLM agent remembers what it should and drops what it must.

Key takeaways

  • 01

    Memory is not "the context window." Split working, session, episodic, and semantic stores; each has a different lifetime and trust level.

  • 02

    Write rules matter more than embedding choice: what gets persisted, by whom, and with which ACL.

  • 03

    Unbounded long-term memory poisons future turns with stale preferences, secrets, and wrong facts — forgetting is a feature.

  • 04

    Retrieve memory with the same permission filter you use for RAG; a remembered document is still a document.

  • 05

    Evaluate recall and non-recall: the agent should remember the account tier and forget the one-time password.

01

AI agent memory architecture: four stores

AI agent memory architecture is how state survives a turn. Working memory is the current context window: the prompt, recent turns, tool results. Session memory is durable state for this conversation or ticket (goal, entities, pending confirmation). Episodic memory is a log of past episodes — what happened, when, with which user. Long-term memory for an LLM is usually a semantic store of distilled facts and preferences, retrieved by similarity plus filters.

Do not collapse those into one vector bucket. Working memory is ephemeral and high-trust (you just produced it). Semantic memory is durable, low-trust until verified, and shared across sessions. Mixing them is how a joke in Tuesday's chat becomes Friday's policy.

  • Working: context window, tool scratchpad, this turn
  • Session: ticket or thread state, TTL in hours to days
  • Episodic: append-only event log with timestamps
  • Semantic: distilled facts, preferences, with provenance
02

Write rules, provenance, and privacy

Every write needs a rule: who may persist (user, agent, human reviewer), what type (preference, fact, credential — credentials never), and what provenance (span ID, source quote). Prefer explicit memory tools ("save this preference") over silently embedding every turn. Silent writes maximize recall of garbage.

Privacy is architectural. Memory records inherit the user's ACL and retention class. Do not write another employee's conversation into a shared semantic index. Redact PII at write time if the store is used for retrieval across users. Client-owned stores in the client's VPC are the default for anything that is not public knowledge.

03

Read path: what to inject, what to fetch

On each turn, load session state always (it is small and precise). Retrieve semantic and episodic memory with a query, a k limit, and a recency prior — not the entire biography. Inject memories as labeled data, not as new system instructions, so a poisoned memory cannot rewrite the agent.

Cap tokens reserved for memory. If retrieved memories crowd out the user question and the tools, you have built a worse RAG system. Rank by relevance, recency, and confidence; drop low-confidence facts rather than hedging them into the prompt.

04

Forgetting, correction, and decay

Forgetting policy is mandatory. TTL on session state, decay on unused semantic facts, hard delete on user request, and supersede-on-correction ("the office moved") rather than accumulating contradictions. Episodic logs can stay append-only if semantic memory is the only thing retrieved for generation.

Expose a way for operators and users to see and delete what was stored. A memory system you cannot inspect will store the wrong thing, and you will find out in a complaint, not a dashboard.

05

Failure modes and when not to add long-term memory

Failures: stale facts treated as current, cross-user leakage, secrets persisted because the model "thought it would help," context stuffing from over-retrieval, and write loops that memorize the agent's own mistakes. Confabulated memories — the model saving a fact it invented — need a verifier or a human confirm on writes to the semantic store.

Do not add long-term memory to a single-turn FAQ bot, a system that must not retain user content, or a workflow whose source of truth is already a CRM. Read the CRM. Memory is for state the systems of record do not hold: preferences, in-progress plans, distilled episode summaries. If a database already has the field, query it.

  • Stale or contradictory semantic facts
  • Cross-user or over-broad ACL on the memory index
  • Silent writes that persist secrets or jokes
  • Invented facts saved without verification
06

Evaluating memory

Build cases for recall ("user's timezone is Paris" still true next week), update ("timezone changed to Tokyo"), and non-recall (OTP, card number, another user's ticket). Score retrieval hit rate on the memory index separately from generation. Trace which memory IDs were injected. Operate with retention reports and a delete audit — memory that cannot be forgotten is a compliance bug.

Frequently asked questions

What is AI agent memory architecture?

AI agent memory architecture splits state into working context, session store, episodic log, and long-term semantic memory, each with write rules, ACLs, and a lifetime. The agent retrieves a small, permissioned slice per turn instead of stuffing the full history into the window. Forgetting and correction are part of the design.

What is long-term memory for an LLM agent?

Long-term memory for an LLM is a durable semantic store of distilled facts and preferences, retrieved on later sessions — not the raw chat log. Writes should carry provenance and an ACL. It is useful for preferences and summaries the CRM does not hold, and harmful when it stores secrets or unverified inventions.

How do working, session, episodic, and semantic memory differ?

Working memory is the current context window. Session memory is this ticket or thread. Episodic memory is an append-only log of past episodes. Semantic memory is distilled facts retrieved by similarity. They have different TTLs and trust levels; collapsing them into one vector index mixes a joke with a policy.

When should an agent forget?

On TTL expiry, on user or operator delete, when a newer fact supersedes an old one, and when a stored item is a secret or a one-time code that should never have been written. Decay unused semantic facts. Forgetting is how you stop stale memory from steering later turns.

When should you not add long-term memory?

Skip it for single-turn Q&A, for products that must not retain user content, and whenever a system of record already holds the field — query the CRM instead of embedding last week's chat. Add memory only for state those systems do not store, with write rules and an eval for both recall and non-recall.

Keep reading

ArchitectureMulti-Agent Orchestration SystemsQualityLLM Evaluation Systems (Evals)TrainingRL Environments for Agent TrainingArchitectureAgentic RAG SystemsArchitectureComputer-Use Agent SystemsArchitectureFunction-Calling and Tool-Use SystemsArchitectureGraphRAG SystemsArchitectureHuman-in-the-Loop AI SystemsArchitectureHybrid Retrieval and Re-ranking SystemsQualityLLM Guardrail SystemsInfrastructureLLM Inference and Serving SystemsInfrastructureLLM Observability and TracingInfrastructureMCP Tool Gateway SystemsArchitectureModel Routing and Fallback SystemsTrainingPEFT and Fine-Tuning PipelinesArchitecturePermissioned Retrieval SystemsQualityPrompt Injection Defense SystemsArchitectureRAG ArchitectureArchitectureRealtime Voice AI SystemsQualityAI Red-Teaming SystemsArchitectureStructured Generation SystemsTrainingSynthetic Data Generation Systems

Building one of these systems?

We help teams design, build, and validate production AI systems — orchestration, evals, and training environments included.

FAQ

Working with us

How soon can AI systems work start?

Typically within a week or two of a scope being agreed. The first delivery is deliberately a small batch so you can check the output against your expectations before volume ramps.

What do you need from our team?

One process owner who knows the workflow, one engineer with access to the systems involved, and a weekly 45-minute review. No standing committee, and no requirement for an ML specialist on your side.

Who owns the output and the data?

You do. Datasets, labels, weights, evaluation suites and runbooks are yours and are handed over at the end. Your data trains your models only, with zero-retention provider settings by default.

Can you scale volume up quickly if we need it?

Yes, and the quality bar holds because the rubric and gold set are already agreed by that point. Ramping is a staffing question, not a re-scoping one, so it usually takes days rather than a new engagement.

We already have a vendor for this. Why switch?

Often you should not. The cases where teams move to us are when they cannot get a quality number out of their current vendor, or when the work is delivered as an opaque batch with no trace of how disagreements were resolved.

What happens after the engagement ends?

We stay on-call for 30 days at no extra cost, then move to an optional support retainer. Most teams also keep a quarterly evaluation review with us to catch drift early.

Copyright © 2026
ReinforcedX, Inc.
All rights reserved