PostgreSQL​Postgre​S​Q​L

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.

yaml
type: "io.kestra.plugin.ai.memory.PostgreSQL"

Use PostgreSQL-based chat memory for a conversation

yaml
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 name

The name of the PostgreSQL database

PostgreSQL host

The hostname of your PostgreSQL server

Database password

The password to connect to PostgreSQL

Database user

The username to connect to PostgreSQL

Default NEVER
Possible Values
NEVERBEFORE_TASKRUNAFTER_TASKRUN

Drop 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.

Default {{ 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.

Default 10

Maximum 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.

Default 5432

PostgreSQL port

The port of your PostgreSQL server

Default chat_memory

Table name

The name of the table used to store chat memory. Defaults to 'chat_memory'.

Default PT1H
Format duration

Memory duration - defaults to 1h