Chat Memory backed by PostgreSQL
Persist chat memory in a PostgreSQL table using the memory ID as the primary key. The entry will expire after the provided TTL if configured. Ensure your PostgreSQL database is reachable and configured via plugin properties.
type: "io.kestra.plugin.ai.memory.PostgreSQL"Examples
Use PostgreSQL-based chat memory for a conversation
id: "postgresql"
type: "io.kestra.plugin.ai.memory.PostgreSQL"
id: chat_with_memory
namespace: company.ai
tasks:
  - id: first
    type: io.kestra.plugin.ai.rag.ChatCompletion
    chatProvider:
      type: io.kestra.plugin.ai.provider.GoogleGemini
      modelName: gemini-2.5-flash
      apiKey: "{{ kv('GEMINI_API_KEY') }}"
    memory:
      type: io.kestra.plugin.ai.memory.PostgreSQL
      host: localhost
      port: 5432
      database: ai_memory
      user: postgres
      password: secret
      tableName: my_custom_memory_table
    systemMessage: You are a helpful assistant, answer concisely
    prompt: "{{inputs.first}}"
Properties
database *Requiredstring
Database name
The name of the PostgreSQL database
host *Requiredstring
PostgreSQL host
The hostname of your PostgreSQL server
password *Requiredstring
Database password
The password to connect to PostgreSQL
user *Requiredstring
Database user
The username to connect to PostgreSQL
drop string
NEVERNEVERBEFORE_TASKRUNAFTER_TASKRUNDrop memory: never, before, or after the agent's task run
By default, the memory ID is the value of the system.correlationId label, meaning that the same memory will be used by all tasks of the flow and its subflows.
If you want to remove the memory eagerly (before expiration), you can set drop: AFTER_TASKRUN to erase the memory after the taskrun.
You can also set drop: BEFORE_TASKRUN to drop the memory before the taskrun.
memoryId string
{{ labels.system.correlationId }}Memory ID - defaults to the value of the system.correlationId label. This means that a memory is valid for the entire flow execution including its subflows.
messages integerstring
10Maximum number of messages to keep in memory. If memory is full, the oldest messages will be removed in a FIFO manner. The last system message is always kept.
port integerstring
5432PostgreSQL port
The port of your PostgreSQL server
tableName string
chat_memoryTable name
The name of the table used to store chat memory. Defaults to 'chat_memory'.
ttl string
PT1HdurationMemory duration - defaults to 1h
