Agent Memory Systems: Working State, Episodic History, and Semantic Knowledge
Published
2 min read
Human teams do not re-read every company handbook and every past email from scratch before replying to a customer. They rely on distinct types of memory. Modeling agent memory cleanly prevents prompt bloat and stops contradictory facts from leaking across conversations.
Three Distinct Memory Layers
| Memory Type | Lifespan | Storage Pattern | Examples |
|---|---|---|---|
| Working Memory | Single run / active task | In-memory loop state + scratchpad | Tool outputs, pending draft, active filters |
| Episodic Memory | Per customer / thread | Rolling summaries + structured profile facts | Preferred language, past orders, unresolved ticket |
| Semantic Memory | Workspace-wide | Indexed KB + hybrid vector/lexical search | Product specs, refund policies, onboarding docs |
Memory Hygiene: Expiration and Conflict Resolution
Unbounded memory accumulation degrades accuracy over time. Every memory write should carry:
- Source provenance (did the customer state this directly, or did a verified billing webhook confirm it?).
- Timestamp / TTL (delivery city from last week is useful; "I need it today" from 6 months ago is stale).
- Explicit overwrite semantics so verified transactional events supersede older inferred chat facts.
ts
export interface MemoryFact {
key: string;
value: string;
source: "customer_message" | "verified_system_event" | "human_agent";
observedAtIso: string;
expiresAtIso?: string;
}
export function shouldReplaceFact(existing: MemoryFact, incoming: MemoryFact): boolean {
const trustRank = { customer_message: 1, human_agent: 2, verified_system_event: 3 };
if (trustRank[incoming.source] > trustRank[existing.source]) return true;
return incoming.observedAtIso >= existing.observedAtIso;
}
Strict Multi-Tenant Memory Boundaries
Never share episodic customer memory across workspaces, and never mix unverified customer utterances into workspace-wide semantic knowledge without explicit review.
Next: stop infinite loops and cost spikes before they hit production in Preventing Runaway Agents.
Was this helpful?