
AI PostgreSQL
CertifiedPersist chat memory in PostgreSQL
AI PostgreSQL
Persist chat memory in PostgreSQL
Stores chat history in a PostgreSQL table keyed by memory_id; TTL sets an expires_at timestamp. Honors drop policies BEFORE/AFTER run; defaults to KEEP. Table is created if missing. Requires reachable Postgres with permissions to create tables.
type: io.kestra.plugin.ai.memory.PostgreSQLExamples
Use PostgreSQL-based chat memory for a conversation
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: "{{ secret('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
PT1HMemory duration - defaults to 1h