# Agent Memory

> The Agent Memory is a way for an AI agent to store and reuse information beyond a single context window.

## How do AI agents remember things between sessions?

The mechanism that lets an agent keep information between steps and sessions, for example notes, files or a database of facts about the user and project. Short-term memory lives in the context, long-term memory is stored outside it.

- Topic: AI Agents
- Type: concept

## Example

Wrong:

```json
{
  "memory": "User: hi, my token is abc123 ... (full chat log)",
  "scope": "global"
}
```

Right:

```json
{
  "fact": "Prefers short answers with code first",
  "source": "conversation:8421",
  "scope": "user:42"
}
```

A short, scoped fact with a source is easy to review, update or delete, and keeps secrets out of memory.

## Common mistakes

- Stale memories keep pushing the agent toward outdated decisions.

## Key points

- Saved memories are short facts with a source, not full conversation logs.
- Secrets and personal data are not written to memory.
- Memory is scoped per user or project, so one user's memory never reaches another.
- Old or wrong memories can be updated or deleted.

## Interview questions

### Short-term vs long-term agent memory?

Short-term memory is the current context window. Long-term memory is stored outside it, in files or a database, and loaded in later sessions.

### How does an agent recall memories?

It loads them at the start of a session, or searches them with a tool when needed, often with keyword or semantic search.

### Is agent memory the same as fine-tuning?

No. Memory is data added to the context at runtime; the model weights do not change.

## Related cards

- [Context Window](https://wonderium.dev/ai/context-window.md)
- [RAG](https://wonderium.dev/ai/rag.md)
- [Context Compaction](https://wonderium.dev/ai/context-compaction.md)
- [Agent Instructions File](https://wonderium.dev/ai/agent-instructions-file.md)
- [Sensitive Data Leakage](https://wonderium.dev/ai/sensitive-data-leakage.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/agent-memory
- Last updated: 2026-11-25
