Skip to content
Agent Builder
Module 3Full course9 min read

Giving Agents Memory

Short-term vs. long-term memory, file-based memory, retrieval, and how to design memory that helps instead of polluting context.

Every new session with an agent starts from zero. It doesn't remember that you prefer TypeScript, that your team never deploys on Fridays, or that it spent an hour yesterday learning why the payment tests are flaky. You explain the same things again and again, and the agent rediscovers the same lessons again and again.

Memory fixes that, but only if it's designed well. Badly designed memory is worse than none: it fills context with stale facts, outdated preferences, and contradictory notes, and the agent confidently acts on all of them. This lesson explains the kinds of memory agents can have, how file-based and retrieval-based memory work, and the design rules that keep memory helpful instead of polluting. You'll set up practical memory for your own agent work and learn what to build into agents you create.

Short-term vs. long-term memory

Memory in agents comes in two broad kinds, and it helps to name them precisely.

Short-term memory (also called working memory) is the context window itself: the conversation so far, tool results, and anything loaded for this session. It's fast and the model uses it directly, but it's limited in size and disappears when the session ends. Managing it is what Managing Long Context was about.

Long-term memory is anything stored outside the context window that persists across sessions and gets loaded back in when relevant. The model never "remembers" anything on its own. Long-term memory is always a two-step process: something gets written to storage, and later something gets read back into context.

It also helps to distinguish what kind of thing is being remembered:

TypeWhat it holdsExample
SemanticFacts and preferences"The user's company bills in EUR." "Prefers short answers."
EpisodicWhat happened before"On Oct 3 we tried caching the API client; it caused stale data in tests."
ProceduralHow to do things"To release: bump version, run npm run release, post in #deploys."

Procedural memory often lives best as a skill or instruction file, which is the subject of Skills and Reusable Instructions. This lesson focuses mainly on semantic and episodic memory.