using-memory

 

 Using Memory in ChatGPT and AI Agents

In the previous post, we learned how to use ChatGPT Projects to organize conversations, files, instructions, and long-running work.

In this post, we will explore Memory and understand why memory is important for AI Assistants and AI Agents.

Memory allows an AI system to use information from previous interactions instead of treating every conversation as completely new.

What is AI Memory?

In simple terms, AI memory is the ability of an AI system to retain and use information from previous interactions.

Without memory, an AI system may treat every interaction independently.

For example:

User:

My name is David and I am a software developer.

Later:

User:

What programming language should I learn?

Without memory, the AI may not know that the user is a software developer.

With memory, the AI may be able to use the previous information:

Since you are a software developer, you may want to consider…

This can make interactions more personalized and useful.

Why is Memory Important for AI Agents?

Memory becomes particularly important when we build AI Agents.

Imagine a customer-support Agent.

A customer says:

My name is John and I have an order number 12345.

Later, the customer asks:

What is the status of my order?

An Agent with appropriate memory and context can understand which customer and order the user is referring to.

Without memory or another mechanism for maintaining context, the Agent may need the customer to provide the information again.

Memory therefore helps an Agent maintain continuity.

ChatGPT Memory

ChatGPT includes memory features that can allow it to remember useful information about you between conversations.

For example, you might tell ChatGPT:

I am a software developer and I usually work with C# and .NET.

If memory is enabled and ChatGPT determines that this information is useful to remember, it may use it in future conversations.

You can also explicitly tell ChatGPT:

Remember that I prefer C# examples.

The exact memory features and controls available can change over time and may depend on your account and settings.

How to Manage ChatGPT Memory

You can manage ChatGPT memory through the ChatGPT settings.

Depending on the current version of ChatGPT, you can review, change, or delete saved memories.

You can also tell ChatGPT to forget something you previously asked it to remember.

For example:

Forget that I prefer C# examples.

It is important to understand that memory settings and chat history are not exactly the same thing.

A conversation can exist in your chat history without every piece of information from that conversation becoming a saved memory.

Memory vs Chat History

These two concepts are often confused.

Chat History

Chat history is the record of your previous conversations.

For example:

Conversation 1
Conversation 2
Conversation 3

You can return to these conversations later.

Memory

Memory refers to information that an AI system can retain and use in future interactions.

For example:

User prefers C#.

The AI may use this information in a future conversation.

Therefore:

Chat History ≠ Memory

They are related concepts, but they serve different purposes.

Memory in Projects

Projects can also provide context for ongoing work.

For example, imagine a Project called:

AI Agent Development

Inside the Project you have:

  • Project instructions
  • Technical documents
  • Architecture discussions
  • Programming conversations
  • Research

This information can provide context for future work within the Project.

Depending on your Project settings, ChatGPT can use Project conversations and other available context to provide more relevant responses.

This is particularly useful for long-running projects.

Project Memory

ChatGPT Projects can support different memory behaviors.

One important option is project-only memory.

With project-only memory, the Project can use relevant information from conversations within that Project without using conversations outside the Project as context.

This can be useful when you want a Project to remain focused on one particular subject.

For example:

AI Customer Support Agent

could have its own context and information without mixing it with your personal conversations or another software project.

The exact memory options available can change as OpenAI updates ChatGPT.

Short-Term and Long-Term Memory

When discussing AI Agents, developers often divide memory into two broad categories.

Short-Term Memory

Short-term memory refers to information available during the current interaction or task.

For example:

User: My name is John.

User: What is my name?

The Agent can use the conversation context to answer:

Your name is John.

This information may exist only within the current conversation or task.

Long-Term Memory

Long-term memory allows an AI Agent to retain useful information for future interactions.

For example:

User prefers C#.

The Agent could store this information and use it in future conversations.

Long-term memory is particularly useful for personalized applications.

Example of AI Agent Memory

Imagine a personal software-development Agent.

The user tells the Agent:

I normally develop applications using C# and ASP.NET Core.

The Agent stores this preference.

Several days later, the user asks:

Create a REST API for my application.

The Agent can use the stored preference and suggest:

Since you normally work with C# and ASP.NET Core, here is an ASP.NET Core implementation…

The user does not need to repeat the same information every time.

Memory Is Not the Same as Knowledge

Another important distinction is:

Knowledge and Memory are not the same thing.

Knowledge can come from the model’s training or from external sources such as documentation or a database.

Memory is information associated with a particular user, conversation, or application that can be retained and reused.

For example:

Knowledge:

C# is a programming language developed by Microsoft.

Memory:

This user prefers C# examples.

The first is general knowledge.

The second is user-specific information.

Memory and RAG

Memory is also different from Retrieval-Augmented Generation (RAG).

RAG allows an AI system to retrieve relevant information from an external knowledge source.

For example:

Company documentation
Product manuals
Database
Knowledge base

The AI retrieves relevant information and uses it to generate an answer.

Memory, on the other hand, is generally used to retain information about interactions, users, preferences, or previous work.

A modern AI Agent may use both:

Memory

→ What does the Agent know about the user?

RAG

→ What information can the Agent retrieve from its knowledge sources?

Memory in an AI Agent Architecture

A simplified AI Agent architecture might look like this:

                    User
                      |
                      v
                AI Agent
                      |
        +-------------+-------------+
        |             |             |
        v             v             v
      LLM          Memory          Tools
        |             |             |
        +-------------+-------------+
                      |
                      v
                 Final Result

The LLM provides reasoning and language capabilities.

Memory provides relevant information from previous interactions.

Tools allow the Agent to interact with external systems.

Together, these components allow an Agent to perform more useful tasks.

Types of Memory Developers Can Build

When developing an AI Agent, memory can be implemented in different ways.

Conversation Memory

Stores previous messages from the conversation.

User Memory

Stores information about a particular user.

For example:

Name: John
Preferred language: English
Preferred programming language: C#

Application Memory

Stores information relevant to the application.

For example:

Customer preferences
Previous support requests
Previous transactions

Semantic Memory

Stores information based on meaning rather than simply storing conversation history.

Vector databases are often used to help retrieve semantically relevant information.

Episodic Memory

Stores information about previous events or experiences.

For example:

The Agent previously helped the customer resolve a payment problem.

These different memory approaches can be combined depending on the requirements of the AI Agent.

Where Can Agent Memory Be Stored?

When developers build an AI Agent, memory can be stored in different systems.

For example:

  • SQL databases
  • NoSQL databases
  • Redis
  • Vector databases
  • Cloud storage
  • Specialized memory systems

The correct choice depends on the application requirements.

For example, a simple Agent might store user preferences in a relational database.

A more advanced Agent might use a vector database to retrieve semantically related information from a large collection of previous interactions.

Memory and Privacy

Memory introduces an important issue:

Privacy.

If an AI system remembers information about users, developers need to carefully consider:

  • What information is stored?
  • Why is it stored?
  • How long is it stored?
  • Who can access it?
  • Can the user delete it?
  • Is sensitive information being stored?
  • How is the information protected?

Developers should avoid storing unnecessary sensitive information.

Memory should be designed as part of the application’s security and privacy architecture.

Memory and User Control

A good AI application should give users appropriate control over their stored information.

For example, users may need the ability to:

  • View stored information
  • Correct information
  • Delete information
  • Disable memory
  • Clear conversation history

The exact capabilities depend on the application.

A Practical ChatGPT Example

Let’s return to our AI Agent Development Project.

We could tell ChatGPT:

Remember that I prefer C# and .NET examples when learning about AI Agents.

Later, we could ask:

Show me an example of tool calling.

If that preference is available as memory or Project context, ChatGPT can provide the example using C# and .NET.

This demonstrates how memory can reduce repetitive instructions.

However, developers should not assume that every piece of information mentioned in a conversation will automatically become permanent memory.

Memory Does Not Mean the AI Remembers Everything

This is a very important point.

When we say that an AI system has memory, it does not necessarily mean that it remembers every conversation or every piece of information forever.

Memory is usually selective and controlled.

A well-designed AI Agent should decide:

What information is useful enough to store?

rather than:

Store everything.

Storing everything can create unnecessary cost, privacy problems, and irrelevant context.

What Have We Learned?

In this tutorial, we learned that:

  • AI memory allows systems to retain and reuse information.
  • Chat history and memory are different concepts.
  • ChatGPT can use memory to personalize future interactions.
  • Projects can provide useful context for long-running work.
  • AI Agents can use short-term and long-term memory.
  • Memory is different from general AI knowledge.
  • Memory is different from RAG.
  • Developers can store Agent memory in databases and other storage systems.
  • Memory introduces important security and privacy considerations.

Conclusion

Memory is one of the most important concepts in modern AI systems.

A chatbot can answer questions, and an AI Assistant can help users perform tasks. An AI Agent can go further by combining an LLM with memory, tools, planning, and the ability to perform actions.

Memory gives an Agent the ability to maintain useful context across interactions and provide more personalized and consistent behavior.

However, memory must be carefully designed. An Agent should not simply remember everything. Developers need to decide what information should be stored, where it should be stored, how long it should be retained, and how users can control it.

In the next post, we will take the next major step and start looking at how to build our first AI Agent, including its main components, architecture, tools, and workflow.

Building Your First AI Agent

← Back to AI Agents – Step-by-Step

← Back to Home Page