Skip to content

Storage

This guide covers configuring conversation persistence.

Work in progress

This guide is being written. Check back soon for complete content.

SQLite storage

The built-in SQLite adapter provides local conversation persistence:

pnpm add @cognidesk/storage @libsql/client
import { createSqliteStorage } from "@cognidesk/storage/sqlite";

const storage = createSqliteStorage({
  filename: "conversations.sqlite",
});

const runtime = createRuntime({ storage, agent, models });

Postgres storage

Use Postgres for production deployments that need a server database:

pnpm add @cognidesk/storage pg
import { createPostgresStorage } from "@cognidesk/storage/postgres";

const storage = createPostgresStorage({
  url: process.env.DATABASE_URL!,
});

const runtime = createRuntime({ storage, agent, models });

Storage contract

The storage interface is defined in @cognidesk/core. Any implementation that satisfies the contract can be used:

  • Conversation records
  • Runtime Event storage and replay
  • Runtime Snapshot persistence
  • Conversation lifecycle updates

Custom storage adapters

Implement the storage interface to use your own database:

import type { StorageAdapter } from "@cognidesk/core";

const customStorage: StorageAdapter = {
  // Implement the storage contract
};