Long-Term Memory

In a Structured Visual Agent, the State provides conversation-scoped memory, often called Short-Term Memory.

A common need in Agentic use cases is for the Agent to remember user preferences and information over time, in order to provide better assistance. This is called Long-Term Memory.

Structured Visual Agents provide two blocks for managing Long-Term Memory:

  • Store in Long-Term Memory - Typically runs at the end of a turn and detects elements of the conversation that need to be remembered (either because it’s deemed important, or because the user explicitly asked for it)

  • Retrieve from Long-Term Memory - Typically runs at the beginning of a turn, and searches within the user’s Long-Term Memory, to add relevant facts and episodes, in order to help the Agent make better decisions and better respond to the user.

Setup

These blocks are provided by the “Agent Long-Term Memory” plugin, which you need to install.

These blocks require that the Agent runs in a specific Code Env, which you can configure in the “Settings” tab of the agent. The Code Env needs to contain the “pysqlite3” and “sqliteai-vector” packages.

Types of memory items

The blocks handle two types of memory items, “facts” and “episodes”:

  • Facts - typically include curated, “factual” information such as “The user prefers the color blue”. The “Retrieve from Long-Term Memory” block retrieves all facts for the user (up to a configurable limit) and then uses an LLM query to filter facts that seem relevant to the current state of the conversation.

  • Episodes - elements from the past that are worth remembering but are not as strong as facts. They are often used when the user says something like “Remember when we talked about that? I want to get back to this”. The “Retrieve from Long-Term Memory” block uses semantic search to retrieve past episodes that may be relevant to the current conversation.

Memory banks

Both blocks can implement one or several memories per project. Each block references a “memory bank”, which is an identifier.

If you don’t configure an identifier, a default project-level memory bank is used. This allows sharing memory between agents of the same project.

If you do configure an identifier, a specific memory bank is used, if you don’t want memory from other agents to interfere.

Within each memory bank, memories are stored and retrieved separately per-user.