Skip to content

Postgres Memory

Postgres Memory stores an agent’s memory in a PostgreSQL database owned by your company. With it, the agent remembers what was said in the earlier messages of each conversation and, if you turn it on, also important facts about each user that it keeps from one conversation to the next.

If you only want an agent to remember the conversation, you don’t need this component: when you turn on Use memory in the agent, NappAI keeps the history for you. Use Postgres Memory when you want that memory to live in your own database.

When to use it

  • Your data policy requires customer conversations to be stored in a company database.
  • You want a customer service assistant to remember each customer’s preferences (language, usual store, payment method) from one conversation to the next.
  • Several flows or teams already work with a PostgreSQL database and you want your agents’ memory kept there too.

Configuration

Before you start you need a PostgreSQL database that NappAI can reach and a credential of the Postgres SQL service with its connection address. See Credentials.

FieldWhat it does
Credential (required)The credential of the Postgres SQL service. Pick one with Choose an option or create one with Add new credential.

Advanced options

FieldWhat it does
Enable CheckpointingStores the thread of each conversation in your database so the agent remembers the earlier messages. Default: on.
Enable StoreTurns on long-term memory: the agent can save important facts about each user and look them up in later conversations. Turning it on shows Session ID and Enable Semantic Search. Default: off.
Session IDAppears with Enable Store. You can leave it as it is: the agent organises memories by each user’s session, which you can set with Set Session ID.
Enable Semantic SearchAppears with Enable Store. Lets the agent search memories by meaning, not only by exact words. Turning it on shows the Embedding connection and the Embedding Dimension field. Your database must have the vector extension (pgvector) installed; if it doesn’t, the component tells you.
Embedding DimensionAppears with Enable Semantic Search. The size of the numeric representations produced by the connected embeddings model. It must match that model; check the value in the provider’s documentation. Default: 1536.
Conversation IDIdentifier of the conversation. You can leave it empty: the agent saves and restores the thread by the conversation of each run.
ConnectionWhat to connect
EmbeddingAn embeddings component, for example OpenAI Embeddings. Required to use Enable Store.

Output

Memory is the configured memory. Connect it to the Memory input of an agent such as Agent, Simple Agent or Deep Agent. That input appears when you turn on Use memory in the agent’s Advanced tab.

With Enable Store on, the agent also gains the ability to save an important fact, search what it has saved and retrieve a specific fact. It decides when to do so based on the conversation.

Example

Viajes Albaida runs a booking assistant and keeps all its data in PostgreSQL:

  1. Create a Postgres SQL credential with the address of the agency’s database.
  2. Add Postgres Memory and choose that credential in Credential.
  3. In the agent, turn on Use memory in the Advanced tab and connect Memory to the new Memory input.

When a customer writes “I want the same hotel as last time, but in July”, the agent finds in the conversation thread which hotel it was, and everything stays in Viajes Albaida’s database.

Good practices

  • Turn on long-term memory only if the agent must remember facts across different conversations; to follow one conversation, Enable Checkpointing is enough.
  • Tell the agent in its instructions what it should and should not remember, for example “remember the preferred language, never store payment details”.
  • Use Set Session ID with a stable customer identifier so each customer’s memories don’t mix with others.