> For the complete documentation index, see [llms.txt](https://docs.anyassistant.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anyassistant.ai/anyassistant-builder/memory.md).

# Memory

The Assistant's memory allows it to recall past conversations and respond to your current message while maintaining context. Different memory techniques enable the Assistant to remember and utilize information from previous interactions.

We currently have two types of memories.

## Simple Chat Memory

Simple Chat Memory stores conversations in a list. When you send a new message to the Assistant, it retrieves the most recent n conversations from memory and combines them with your message. The Assistant then generates a response based on this combined information, which is added to the memory for future reference.

### Example

#### Current Memory

{% code overflow="wrap" %}

```
User: Hey

Assistant: Hello! How can I assist you today?

User: What can you tell me about Anthony Hopkins?

Assistant : Sir Anthony Hopkins is a highly acclaimed Welsh actor who has had a remarkable career in film, television, and theater. He was born in Port Talbot, Wales on December 31, 1937. Hopkins is widely regarded as one of the greatest actors of his generation and has received numerous accolades for his work, including an Academy Award, three BAFTA Awards, two Emmys, and a Golden Globe.

Hopkins' breakthrough role came in 1991 when he portrayed Dr. Hannibal Lecter in "The Silence of the Lambs." His chilling and mesmerizing performance earned him the Academy Award for Best Actor and solidified his status as a leading actor in Hollywood. The character of Hannibal Lecter became one of his most iconic roles.

```

{% endcode %}

#### New Message

`what did he do before he was hannibal?`

After the assistant generates the response, the new memory becomes.

{% code overflow="wrap" %}

```
User: Hey

Assistant: Hello! How can I assist you today?

User: What can you tell me about Anthony Hopkins?

Assistant : Sir Anthony Hopkins is a highly acclaimed Welsh actor who has had a remarkable career in film, television, and theater. He was born in Port Talbot, Wales on December 31, 1937. Hopkins is widely regarded as one of the greatest actors of his generation and has received numerous accolades for his work, including an Academy Award, three BAFTA Awards, two Emmys, and a Golden Globe.

Hopkins' breakthrough role came in 1991 when he portrayed Dr. Hannibal Lecter in "The Silence of the Lambs." His chilling and mesmerizing performance earned him the Academy Award for Best Actor and solidified his status as a leading actor in Hollywood. The character of Hannibal Lecter became one of his most iconic roles.

User: what did he do before he was hannibal?

Assistant: Before his role as Hannibal Lecter, Anthony Hopkins had a successful career in theater, television, and film. He began in the theater, performing in various stage productions, including Shakespearean plays. Hopkins then transitioned to television and film, gaining recognition for his roles in movies such as "The Lion in Winter" (1968) and "Young Winston" (1972). He continued to work on both sides of the Atlantic, appearing in notable films like "Magic" (1978), "The Elephant Man" (1980), and "The Bounty" (1984). However, his portrayal of Hannibal Lecter in "The Silence of the Lambs" (1991) brought him worldwide fame and critical acclaim, earning him an Academy Award and solidifying his status as a renowned actor.
```

{% endcode %}

## Contextual Chat Memory

In Contextual Chat Memory, conversations are stored in a vector store instead of a simple list. When a new message is received from the user, a vector search is performed to find only the relevant conversation items from the memory. This retrieval process helps identify the most relevant information for generating a response. The relevant conversation items are then combined with the new message to generate a response from the Assistant.&#x20;

This approach allows the Assistant to consider and incorporate contextually relevant information from past conversations, leading to more accurate and context-aware responses.

{% hint style="info" %}
Learn more about vector stores, embeddings and relevant data retrieval [here](broken://pages/PGqqv41YJLeEGDGMS9G1).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.anyassistant.ai/anyassistant-builder/memory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
