# Agent Memory

Agent memory retains and retrieves selected state or information so an AI agent can maintain continuity within a task or across interactions.

- Type: framework
- Domain: Engineering & architecture
- Level: Advanced
- Last reviewed: 2026-10-05
- Original: [Soroush’s Product Wiki](<https://wiki.soroush.uk/topic/agent-memory/>)

## What it means

Agent memory is an application mechanism for carrying information forward into future decisions. Short-term memory commonly tracks a conversation or task; long-term memory persists information across sessions. Implementations include structured profiles, event records, summaries, and retrieved notes. Stored information affects a model only when made available through context or tools; storing a memory does not itself update model weights.

## Why it matters

Continuity can reduce repeated explanations and support longer tasks, but incorrect or stale memories can influence many later interactions. Product design must define what the system remembers, whose information it uses, and how users can inspect or correct it.

## When to use it

Use memory when retained context delivers a clear benefit, such as resuming a task or honoring a stated preference. Prefer explicit profile fields for simple durable settings. Avoid collecting conversational details merely because storage is available, particularly when retention would surprise users.

## How it works

1. Identify the continuity need and separate task state, explicit preferences, and inferred information.
2. Define storage scope, ownership, retention, and controls for viewing, correcting, and deleting retained information.
3. Write selected records with provenance and timestamps, distinguishing user statements from model-generated summaries.
4. Retrieve only relevant authorized information and resolve conflicts against newer evidence before using it.
5. Evaluate recall, stale information, mistaken attribution, and cross-user isolation, including behavior after correction or deletion.

## A practical example

A research assistant remembers that a user prefers brief summaries and retains a project's unresolved questions. It offers a view of saved information and keeps project notes separate from personal preferences. When the user changes the brief, the assistant updates the relevant record rather than repeatedly applying the older summary.

## Where it breaks

Summaries can omit constraints or convert uncertain statements into apparent facts. Retrieval can miss relevant records or surface obsolete ones. More retained information increases storage, retrieval, and governance work; a larger context window alone does not solve these problems.

## Common mistakes

- Describing stored notes as permanent learning in the model's weights.
- Saving every message without a defined purpose or retention policy.
- Treating model-inferred preferences as confirmed user statements.
- Deleting the visible conversation while leaving associated memories active.

## Visualization

[View the visualization on the website](<https://wiki.soroush.uk/topic/agent-memory/#visualization-agent-memory>)

## Sources

1. [Memory overview](<https://docs.langchain.com/oss/python/concepts/memory>) — LangChain · Official documentation
2. [Effective context engineering for AI agents](<https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents>) — Anthropic · Official documentation

## Related topics

- [AI Agent](<https://wiki.soroush.uk/topic/ai-agent/>)
- [Context Window](<https://wiki.soroush.uk/topic/context-window/>)
- [Human–AI Interaction](<https://wiki.soroush.uk/topic/human-ai-interaction/>)
