Loading learning content…
Loading learning content…
Give agents persistent memory — short-term, long-term, semantic, and episodic.
Read through the lesson, mark it complete when the concept is clear, then move to the next lesson in the sequence or jump back to the module map.
In-context memory — the message history in the current conversation. Fast, zero latency, limited by context window size. Lost when the session ends.
External memory (episodic) — a database of past interactions, stored and retrieved as needed. Survives restarts. Requires retrieval logic.
Semantic memory — a vector database of concepts and knowledge, searched by similarity. Enables agents to "remember" information not in the current context.
Procedural memory — skills and workflows encoded in the system prompt or retrieved as needed. The agent's "how to do things" knowledge.
| Memory Type | Best For |
|---|---|
| In-context | Current conversation state |
| Episodic | User preferences, past tasks |
| Semantic | Domain knowledge, documentation |
| Procedural | Task workflows, best practices |
async function loadRelevantMemory(userId: string, query: string) {
const memories = await db.query.agentMemory.findMany({
where: eq(agentMemory.userId, userId),
orderBy: desc(agentMemory.createdAt),
limit: 10,
});
return memories.map(m => m.content).join('\n');
}
Inject retrieved memories into the system prompt before each interaction.
More memory = more context = higher cost and latency. Memory management is the art of selecting what to remember and what to forget.
Strategies: