By Sagar Shankaran, Founder of CallSphere
Deep dive into memory architectures for AI agents — short-term context, long-term vector stores, episodic memory, and procedural memory. Implementation patterns and real-world tradeoffs.
Key takeaways
AI agents without memory are like employees with amnesia — productive in the moment but incapable of learning from experience, maintaining context across sessions, or building relationships with users. As agent systems move from demos to production, memory architecture has become a critical design challenge.
The core tension: LLMs have fixed context windows (4K to 2M tokens), but agent interactions can span hours, days, or months. How do you give an agent access to relevant past experience without overwhelming its context or exploding costs?
Drawing from cognitive science, agent memory systems typically implement four types:
What it is: The current conversation context — the messages, tool results, and intermediate state that exist within a single agent session.
Implementation: Simply the message array passed to the LLM in each call.
# Working memory is just the conversation history
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "Analyze our Q4 revenue"},
{"role": "assistant", "content": "I'll look at the data..."},
{"role": "tool", "content": '{"revenue": 2400000, ...}'},
{"role": "assistant", "content": "Q4 revenue was $2.4M..."},
]
Challenge: Context windows are finite. Long conversations must be summarized or truncated. Naive truncation loses important early context; aggressive summarization loses nuance.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
Best practice: Implement a sliding window with a summary prefix. Keep the last N messages verbatim and maintain a rolling summary of earlier conversation.
What it is: Factual knowledge accumulated over time — user preferences, domain facts, organizational knowledge.
Implementation: Vector databases with embedding-based retrieval.
from langchain_community.vectorstores import Chroma
from langchain_openai import OpenAIEmbeddings
# Store memories as embedded documents
memory_store = Chroma(
collection_name="agent_memories",
embedding_function=OpenAIEmbeddings()
)
# Save a memory
memory_store.add_texts(
texts=["User prefers Python over JavaScript for backend work"],
metadatas=[{"type": "preference", "user_id": "u123", "date": "2026-02-01"}]
)
# Retrieve relevant memories for current context
relevant = memory_store.similarity_search(
"What language should I use for this API?",
k=5,
filter={"user_id": "u123"}
)
Challenge: Relevance decay. Old memories may be outdated. A user who preferred Python in 2025 may have switched to Rust in 2026.
flowchart TD
HUB(("The Memory Problem in<br/>Agentic AI"))
HUB --> L0["Memory Type Taxonomy"]
style L0 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L1["1. Working Memory<br/>(Short-Term)"]
style L1 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L2["2. Semantic Memory<br/>(Long-Term Knowledge)"]
style L2 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L3["3. Episodic Memory (Past<br/>Experiences)"]
style L3 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L4["4. Procedural Memory (How-To<br/>Knowledge)"]
style L4 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L5["Practical Architecture for<br/>Production Agents"]
style L5 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L6["Key Design Decisions"]
style L6 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
style HUB fill:#4f46e5,stroke:#4338ca,color:#fff
Best practice: Include timestamps in memory metadata and implement decay functions that reduce the weight of older memories. Periodically consolidate or prune memories that contradict newer information.
What it is: Records of specific past interactions — what happened, in what order, and what the outcome was. Unlike semantic memory (facts), episodic memory preserves temporal and contextual structure.
Implementation: Structured event logs with retrieval capability.
# Episodic memory entry
episode = {
"id": "ep_2026_02_15_001",
"timestamp": "2026-02-15T14:30:00Z",
"user_id": "u123",
"task": "Debug production API timeout",
"actions_taken": [
"Checked server logs",
"Identified N+1 query in /api/orders",
"Suggested adding eager loading"
],
"outcome": "success",
"resolution": "Added .prefetch_related('items') to OrderSerializer",
"duration_minutes": 12,
"user_satisfaction": "positive"
}
Why it matters: Episodic memory enables agents to learn from experience. When a similar problem appears, the agent can recall what worked before and apply proven solutions.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Challenge: Knowing when a past episode is relevant to the current situation requires good similarity matching across structured data, not just text embedding.
What it is: Learned procedures, workflows, and strategies — the "muscle memory" of how to accomplish specific tasks.
Implementation: Prompt templates, tool chains, and learned action sequences stored as executable patterns.
# Procedural memory: learned workflow for code review
procedure = {
"name": "code_review",
"trigger": "user requests code review",
"steps": [
{"action": "read_diff", "tool": "git_diff"},
{"action": "check_tests", "tool": "run_tests"},
{"action": "analyze_complexity", "tool": "code_analysis"},
{"action": "check_conventions", "context": "team_style_guide"},
{"action": "generate_review", "format": "inline_comments"}
],
"learned_from": ["ep_001", "ep_015", "ep_023"],
"success_rate": 0.92
}
A production-ready memory system typically combines all four types:
┌─────────────────────────────────────┐
│ Agent Runtime │
├─────────────────────────────────────┤
│ Working Memory (context window) │
│ ┌─────────────────────────────┐ │
│ │ System prompt + recent msgs │ │
│ │ + retrieved memories │ │
│ └─────────────────────────────┘ │
├─────────────────────────────────────┤
│ Memory Manager │
│ ├── Retrieval: What memories are │
│ │ relevant to current context? │
│ ├── Storage: What from current │
│ │ session is worth remembering? │
│ └── Consolidation: Merge, update, │
│ or prune existing memories │
├─────────────────────────────────────┤
│ Memory Stores │
│ ├── Vector DB (semantic memory) │
│ ├── Event Log (episodic memory) │
│ └── Procedure DB (procedural) │
└─────────────────────────────────────┘
What to remember: Not everything is worth storing. Implement a significance filter — store memories about user preferences, successful problem resolutions, and domain facts. Skip routine acknowledgments and chitchat.
When to retrieve: Retrieving memories on every turn adds latency and cost. Trigger retrieval when the conversation topic shifts, when the user references past interactions, or when the agent encounters uncertainty.
How much to inject: Retrieved memories compete with current context for the model's attention. Limit injected memories to 3-5 most relevant entries and summarize them concisely.
Sources: LangChain — Memory Documentation, LlamaIndex — Agent Memory, Letta (MemGPT) — Memory Management for LLMs
flowchart LR
IN(["Input prompt"])
subgraph PRE["Pre processing"]
TOK["Tokenize"]
EMB["Embed"]
end
subgraph CORE["Model Core"]
ATTN["Self attention layers"]
MLP["Feed forward layers"]
end
subgraph POST["Post processing"]
SAMP["Sampling"]
DETOK["Detokenize"]
end
OUT(["Generated text"])
IN --> TOK --> EMB --> ATTN --> MLP --> SAMP --> DETOK --> OUT
style IN fill:#f1f5f9,stroke:#64748b,color:#0f172a
style CORE fill:#ede9fe,stroke:#7c3aed,color:#1e1b4b
style OUT fill:#059669,stroke:#047857,color:#fff
flowchart TD
HUB(("The Memory Problem in<br/>Agentic AI"))
HUB --> L0["Memory Type Taxonomy"]
style L0 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L1["1. Working Memory<br/>(Short-Term)"]
style L1 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L2["2. Semantic Memory<br/>(Long-Term Knowledge)"]
style L2 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L3["3. Episodic Memory (Past<br/>Experiences)"]
style L3 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L4["4. Procedural Memory (How-To<br/>Knowledge)"]
style L4 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L5["Practical Architecture for<br/>Production Agents"]
style L5 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L6["Key Design Decisions"]
style L6 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
style HUB fill:#4f46e5,stroke:#4338ca,color:#fff

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
Graphiti is the open-source temporal knowledge graph for AI agents in 2026. Learn how bi-temporal memory beats vector RAG for voice agents and long-running LLMs.
The 2026 desktop AI agent landscape — ServiceNow Project Arc, Anthropic Claude offerings, OpenAI agents, and Google Mariner. A buyer's map.
May 2026's biggest agent-architecture shift: planning, tool selection, and self-correction move inside the model. Framework code shrinks. Here is what changes.
A close look at the pitchbook builder template Anthropic shipped on May 5, 2026: model, tool stack, document flow, and where the human-in-the-loop sits.
Head-to-head comparison of ReAct framework loops vs model-native agent architectures in 2026. Reliability, latency, cost, and what to ship.
A clean before/after of agent architecture in 2026. The control loop moved from your framework code into the model's reasoning chain. What that looks like.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco