promptgarten ๐ŸŒฑ
๐ŸŒ ES
Conceptโ—โ—โ—‹4 min ยท +40 XP

How AI Agents Remember Things

An agent starts every session with a blank mind โ€” memory systems like CLAUDE.md and memory files bridge that gap.

The core problem

Every new session of an AI agent begins with an empty context window. Without extra mechanisms, the agent has no idea what happened yesterday โ€” which rules apply, what went wrong last time, which library your team uses.

Two kinds of memory

You can roughly split memory into two kinds. Semantic memory is fixed, durable rules and facts โ€” "we use pnpm, not npm," code style, architecture decisions. That lives in files like CLAUDE.md or AGENTS.md, which you maintain. Episodic memory is notes about specific past events โ€” "in session X, approach Y failed because Z." Notes like that are often written by the agent itself, in separate memory files.

How this looks technically

CLAUDE.md/AGENTS.md loads in full at every session. Memory files often work differently: a short index file always loads, while more detailed topic files load only on demand โ€” much like a table of contents pointing to detail pages.

Compaction

When context inside a running session gets too full, the agent automatically summarizes older parts of the conversation to free up room (compaction). That's a different mechanism from persistent files: it works within a session, not across sessions.

EXAMPLE

An example split: CLAUDE.md says 'Tests run with npm test, never use npm run test:ci locally' (semantic, durable). A memory file says 'Session from July 12: migration with db:push failed on a foreign-key violation โ€” try db:migrate:dry-run first next time' (episodic, tied to a specific event).

QUICK QUIZ

What best distinguishes an episodic memory note from a rule in CLAUDE.md?

SOURCES

RELATED TOPICS

CLAUDE.md / AGENTS.md: Give Your Agent Memory & Rules โ—โ—โ—‹Context Window โ—โ—‹โ—‹Context strategies for agents โ—โ—โ—The Agent Loop: Think โ†’ Act โ†’ Check โ†’ Repeat โ—โ—โ—‹