Conversation Memory: Carry Forward Useful Information Safely
Conversation memory selects information from prior interactions and supplies it when it can help a later response. It is not the same as storing every conversation. Short-term thread state continues one conversation; long-term memory retains selected facts or preferences across sessions. A sound design decides what to remember, which user or thread it belongs to, when to update it, and how people can review or delete it.
Conversation memory selects information from prior interactions and supplies it when it can help a later response. It is not the same as storing every conversation. Short-term thread state continues one conversation; long-term memory retains selected facts or preferences across sessions. A sound design decides what to remember, which user or thread it belongs to, when to update it, and how people can review or delete it.
This guide covers memory for AI products and agents, not model training or the token budget of one request. Framework and product behavior varies by version and configuration; consult its current documentation.
Separate the scopes
Conversation state (short-term memory) carries messages, tool calls, and results within a thread. With a stateless API, the caller may need to provide prior messages again; a stateful API can retain them behind a conversation identifier. Thread continuity should not automatically become a user profile shared with unrelated conversations.
Long-term memory stores selected information for reuse across conversations, such as a repeated response preference or an explicitly stated project constraint. It may be user-specific or shared application knowledge. Separate these scopes and their access controls.
Treating the entire transcript as permanent memory can bring stale or context-specific statements into later tasks. Keeping only thread state can lose preferences needed in a new session. Choose retention to match the continuity the product needs.
Decide what to retain
Keep a memory only when it is likely to improve future responses, remain useful over time, and has an appropriate source and permission. Ask what future task it helps; whether the user requested it or the product policy permits it; whether it is a fact, inference, or time-bound preference; and how it will be removed if corrected or deleted. Track provenance, time recorded, and confidence where useful. Enforce authenticated user and organization boundaries at retrieval.
Sensitive details such as health, finances, location, or account security are not justified by personalization value alone. Avoid storing them unless necessary; if necessary, restrict purpose and access and provide understandable controls.
Store, update, and retrieve carefully
Use small structured records when they fit the application. A record might include content, type, source, recorded time, last confirmation, and an expiry or review condition. This is a design pattern, not a required API schema.
Do not blindly overwrite conflicts. An explicit “I now prefer tables over email” can justify updating a preference; a one-time request does not prove a lasting preference. Compare source and freshness, ask when ambiguity matters, and keep uncertain facts scoped to the current turn. When updating or deleting an item, track derived summaries and indexes too.
Retrieve only memories relevant to the current query and within the authenticated user’s scope. Check relevance, age, source, and conflicts instead of treating a retrieved memory as unquestionably true. Make it possible for people to see, correct, or remove memories that affect responses.
OpenAI’s Conversations API documents durable conversation state across sessions, while LangGraph distinguishes thread-scoped short-term memory from long-term data across conversations. These differ in scope and application responsibility. ChatGPT’s consumer memory controls are a product example; they should not be assumed to apply to other APIs.
Example: a writing assistant
Hypothetical scenario: A user often asks for tables first and concise answers. This repeated preference may help future tasks and could be a long-term memory candidate. If the user says “explain this one in detail today,” treat it as turn-specific state, not evidence that the lasting preference changed.
If the user updates the preference, check its source and date. Let the user inspect or correct memory used in an answer. A deletion request should cover the source record and derived summaries or search indexes in that user’s scope. This is a design example, not a test of a real product.
Evaluate and operate
Test separately: no memory, continuing the same thread, and retrieving a memory in a later session. Include stale preferences, conflicting facts, ambiguous statements, and attempts to retrieve another user’s information. Audit create, update, retrieve, and delete events without copying unnecessary sensitive content into logs. Verify that deletion rules cover actual copies such as summaries, caches, and vector indexes. Provide a recovery path for incorrect memory.
Product controls can be more complex than a single summary: OpenAI’s help documentation notes that available sources and controls vary and that complete removal may require deleting information from each place where it appears.
Common mistakes
Saving every conversation indefinitely: define purpose and retention; select useful details instead.
Mixing users’ memories: enforce identity and tenant boundaries at retrieval and test them.
Letting old facts dominate: record dates and review conditions; update derived copies.
Saving guesses as facts: preserve source and confidence or do not retain uncertain details.
Deleting only one copy: map summaries, indexes, caches, and other stores to the deletion policy.
Summary
Conversation memory preserves selected information at the right thread or user scope so it can be retrieved, updated, or deleted later. Separate short-term thread state from cross-session memory, track source and freshness, protect identity boundaries, and treat sensitive data conservatively. Evaluate whether memory helps while also checking that stale, incorrect, or deleted information does not reappear.
References
[OpenAI API: Conversation state](https://developers.openai.com/api/docs/guides/conversation-state) — manually carrying prior messages and using durable conversation identifiers.
[OpenAI API: Compaction](https://developers.openai.com/api/docs/guides/compaction) — reducing long-running conversation context while carrying forward state.
[LangGraph: Memory](https://docs.langchain.com/oss/python/langgraph/add-memory) — distinction between thread-level short-term and cross-session long-term memory.
[OpenAI Help Center: Memory in ChatGPT](https://help.openai.com/en/articles/8590148-memory-in-chatgpt) — product-specific review, correction, deletion controls and memory sources.