Learn › AI Agents: Core Capabilities › Memory in Agents: Four Types

Memory in Agents: Four Types

Intermediate 🕐 12 min Lesson 2 of 7
What you'll learn
  • Name and describe the four types of agent memory
  • Explain the difference between in-context and external memory
  • Match a memory type to a given agent use case

Why Memory Matters

A language model has no inherent memory between requests. Each new call starts with a blank slate. For an agent that needs to run dozens of steps, remember what it learned two hours ago, or build on work from last week, that's a fundamental problem. Memory systems are the solution.

The standard framework, formalized in the CoALA paper (Princeton, 2023), distinguishes four types of memory that map to what agents actually need.

1. In-Context Memory (Working Memory)

In-context memory is everything currently in the model's context window: the conversation history, recent tool call results, files the agent is working with, and any instructions it was given. It's the agent's "working memory" — the information it's actively using right now.

  • Speed — instant; no retrieval needed
  • Limit — bounded by the context window (typically 100k–200k tokens for modern models)
  • Persistence — none; cleared when the session ends

In-context memory is where most agent state lives during active work. The design challenge is managing what's in it — keeping it focused on what's currently relevant rather than filling it with everything the agent has ever done.

2. Episodic Memory (What Happened)

Episodic memory stores specific past events: prior tool calls and their results, past conversations, specific decisions the agent made and why. Think of it as the agent's diary — a searchable record of what it did.

Episodic memory lives in an external database and is retrieved on demand. When the agent starts a new session on a task it's seen before, it can pull up the relevant episode ("last time I tried this, the API returned a rate limit error at step 4") and avoid repeating the same mistake.

3. Semantic Memory (What It Knows)

Semantic memory stores facts, general knowledge, and extracted preferences — information that isn't tied to a specific event. Product documentation, company policies, domain knowledge, and learned user preferences all live here.

This is the type of memory most people mean when they talk about "giving an agent access to your knowledge base." It's queried via retrieval-augmented generation (RAG) — the agent searches for relevant content and pulls it into context when needed.

4. Procedural Memory (How to Do Things)

Procedural memory stores skills, rules, and workflows — the agent's knowledge of how to perform tasks rather than what facts are true. This can be encoded in the system prompt ("always verify before deleting"), in explicit playbooks the agent can retrieve, or as learned behavior from fine-tuning.

Choosing the Right Memory Type

Most agents need at least two types working together:

  • Short-horizon work (single session, defined task) — in-context memory is sufficient
  • Knowledge retrieval (answering questions about a large corpus) — semantic memory + RAG
  • Persistent agents (run across multiple sessions on the same project) — episodic memory to avoid repeating work
  • Consistent behavior (agent should follow the same process every time) — procedural memory in the system prompt
Key takeaways
  • The four memory types are: in-context (active working memory), episodic (record of past events), semantic (facts and knowledge), procedural (skills and rules)
  • In-context memory is fast but ephemeral; external memory persists but requires retrieval via RAG or database query
  • The CoALA framework (Princeton 2023) is the canonical academic source for this four-type taxonomy
  • Most production agents use in-context + semantic memory at minimum; persistent agents also need episodic memory
Learn more every week Get 5 hand-picked prompts + new AI tools every Monday. Free.