# Memory system

> A system that attempts to make an agent stateful across sessions by persisting to the environment and reloading at session start.

A system that attempts to make an [agent](https://ai9k.vercel.app/en/agent) [stateful](https://ai9k.vercel.app/en/stateful) across [sessions](https://ai9k.vercel.app/en/session). Persists information into the [environment](https://ai9k.vercel.app/en/environment) during a session and reloads it into the [context window](https://ai9k.vercel.app/en/context-window) at the start of future ones, so the agent carries continuity beyond the user [clearing](https://ai9k.vercel.app/en/clearing) the session.

A memory system has two halves. The write path: during a session, the agent records what it learned — a preference you stated, a fact about the project — as files in the environment. The read path: at session start, the [harness](https://ai9k.vercel.app/en/harness) loads those files, or an index of them, back into the context window. Many harnesses ship their own memory system — Claude Code's `/memory` is one — but you can also build one yourself: a directory of notes plus an instruction in [AGENTS.md](https://ai9k.vercel.app/en/agentsmd) to consult it.

The same trade-offs as any always-loaded content apply. Memories accumulate, so most systems load a one-line index and leave the bodies behind [context pointers](https://ai9k.vercel.app/en/context-pointer) rather than inlining everything. And memories are [secondary sources](https://ai9k.vercel.app/en/secondary-source), so they drift: a fact recorded in March is loaded with equal confidence in June, after the project has moved on. A memory system needs pruning, the same way AGENTS.md does.

**Usage**

"I keep having to re-tell it I'm on Postgres, not MySQL."

"Wire up a memory system — write what it learns to the [filesystem](https://ai9k.vercel.app/en/filesystem) on the first [turn](https://ai9k.vercel.app/en/turn), reload it at session start. The [model](https://ai9k.vercel.app/en/model) itself is [stateless](https://ai9k.vercel.app/en/stateless); the memory layer fakes continuity."

---

- Section 6 — Memory and Steering · Term 53 of 72
- Page: https://ai9k.vercel.app/en/memory-system
- Learn step by step: https://ai9k.vercel.app/en/learn#/memory-system
- On the map: https://ai9k.vercel.app/en?term=memory-system
- JSON: https://ai9k.vercel.app/data/terms/memory-system.json
- Mentioned in: [Inference](https://ai9k.vercel.app/en/inference.md), [Stateless](https://ai9k.vercel.app/en/stateless.md), [Context window](https://ai9k.vercel.app/en/context-window.md), [Stateful](https://ai9k.vercel.app/en/stateful.md), [Session](https://ai9k.vercel.app/en/session.md), [Environment](https://ai9k.vercel.app/en/environment.md), [Contextual knowledge](https://ai9k.vercel.app/en/contextual-knowledge.md), [Secondary source](https://ai9k.vercel.app/en/secondary-source.md)
- Previous: [Autocompact](https://ai9k.vercel.app/en/autocompact.md)
- Next: [AGENTS.md](https://ai9k.vercel.app/en/agentsmd.md)

Every term page has a markdown copy: add .md to its address.
