AI Agent Memory Architecture
Memory is where useful agents become dangerous if the design is lazy.
Remembering the right thing makes the agent feel alive.
Remembering the wrong thing creates privacy problems, stale behavior, and weird decisions nobody can explain.
Three kinds of memory#
Separate memory into three buckets.
Run state
Temporary state for the current workflow: current task, tool results, approval status, intermediate decisions.
User preference
Stable preferences: preferred format, default repo, team naming conventions, recurring constraints.
Domain memory
Project or workspace facts: service owners, approved architecture decisions, recurring runbooks, known systems.
Do not throw all of these into one vector store.
What not to remember#
Avoid storing:
- Secrets.
- Raw customer data.
- Temporary incident noise.
- Unapproved model output.
- Sensitive support messages.
- Personal data without purpose.
- Anything that should expire.
Memory needs a delete story before launch, not after a privacy panic.
Memory should have TTLs#
Not all memory deserves to live forever.
Use TTLs:
- Run state: minutes or hours.
- Incident context: days or weeks.
- User preference: until changed.
- Architecture decision: until superseded.
- Customer-sensitive context: shortest possible window.
Expiration is a product feature.
Retrieval needs permissions#
Memory is still data access.
The agent should only retrieve memory allowed for:
- This user.
- This workspace.
- This workflow.
- This data class.
- This action.
If an employee changes teams, the agent's memory access should change too.
Evals for memory#
Test:
- Stale memory conflicts with current facts.
- User asks to forget.
- Private data appears in memory.
- Similar customer names collide.
- Memory improves answer quality.
- Memory causes wrong assumption.
- Approval state is remembered incorrectly.
Memory can improve the average case and break the edge case. You need both in tests.
Build it in Codelit#
Try this:
Design AI agent memory architecture for a SaaS operations agent. Include run state, user preferences, workspace memory, TTLs, privacy controls, scoped retrieval, deletion, evals, and audit logs.
Design the agent memory architecture
Memory should make the agent more useful, not less accountable.
Try these templates
Netflix Video Streaming Architecture
Global video streaming platform with adaptive bitrate, CDN distribution, and recommendation engine.
10 componentsSearch Engine Architecture
Web-scale search with crawling, indexing, ranking, and sub-second query serving.
8 componentsGoogle Search Engine Architecture
Web-scale search with crawling, indexing, PageRank, query processing, ads, and knowledge graph.
10 componentsContinue learning
Go deeper on AI agents and LLM systems
As an Amazon Associate I earn from qualifying purchases. Codelit may receive a commission at no extra cost to you.
AI Engineering
Chip Huyen · 2025
Book-length treatment of evals, prompts and deployment tradeoffs for foundation-model apps.
Designing Multi-Agent Systems
Victor Dibia · 2025
Six orchestration patterns plus ten documented failure modes, from an AutoGen core contributor.
4.8 (39)#6 in Machine TheoryBuilding Applications with AI Agents
Michael Albada · 2025
Architecture choices for single- vs multi-agent systems, with the research behind each pattern.
Learning Domain-Driven Design
Vlad Khononov · 2021
Turns bounded contexts and aggregates into decision rules for where service boundaries actually go.
4.6 (400)