Context engineering · memory

AI Agent Memory: What to Store, Retrieve, and Forget

Models do not remember by themselves. An application creates the experience of memory by deciding what to save, where to store it, when to retrieve it, and when to delete it.

Four things commonly called memory

Working context is what the model can see in the current request. Conversation history is an application-maintained transcript. Durable memory stores selected user facts or preferences. Organizational knowledge contains source-controlled documents and belongs in a retrieval system. Mixing these categories creates noise and privacy risk.

Write memory deliberately

Do not save every sentence. Define eligible categories, request consent where appropriate, attach provenance and timestamps, and reject sensitive or short-lived facts that have no clear future use. A useful memory record is small, scoped, correctable, and explainable.

Retrieve for a purpose

A stored fact should enter context only when it is relevant to the current task. Retrieve by user, tenant, purpose, freshness, and confidence. More remembered content can reduce quality by distracting the model or reviving outdated information.

Correction and forgetting

People change preferences and systems change facts. Give users a way to inspect, correct, and delete durable memory. Add expiry for temporary facts and never treat a model-generated inference as confirmed user data.

Test isolation

Create tests with two users and two sessions. Verify that one user’s preference never appears in another user’s context, deleted data stays deleted, expired facts are excluded, and the agent behaves sensibly when memory is unavailable.