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 short-term-memory:

  • A block that typically runs at the end of a conversation 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)

  • A block that typically runs at the beginning of a conversation 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 Memmory” 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 are typically long-term, curated, “factual” information such as “The user prefers the color blue”.

Episodes are elements from the past that are worth remembering but that do not raise to the rank of facts. Typically, they are mostly used for cases where the user says “remember when we talked about that ? I want to get back to this”.

The retrieve memory block retrieves all facts for the user (up to a configurable limit) and then uses a LLM query in order to filter facts that seem relevant to the current state of the conversation.

The retrieve 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 put an identifier, a default project-level memory bank is used. This allows sharing memory between agents of the same project. If you put an identifier, a specific memory bank is used, if you don’t want memory from other agents to interfere.