kernl
Core

Kernl

Configure storage, memory, and manage agents with the Kernl runtime.

Reference: Kernl

The Kernl class is the central runtime that manages agents, threads, and the memory system. It handles storage configuration, agent registration, and orchestrates execution.

Basic Usage

import { Kernl, Agent } from "kernl";
import { anthropic } from "@kernl-sdk/ai/anthropic";

const kernl = new Kernl();

const agent = new Agent({
  id: "assistant",
  name: "Assistant",
  model: anthropic("claude-sonnet-4-5"),
  instructions: "You are a helpful assistant.",
});

kernl.register(agent);

Constructor

import { Kernl } from "kernl";

const kernl = new Kernl(options?);

Options

Prop

Type

Storage Options

Configure where threads, tasks, and traces are persisted.

Prop

Type

Available Adapters

PackageTypeDescription
@kernl-sdk/pgdb, vectorPostgreSQL with pgvector support
@kernl-sdk/libsqldbLibSQL/SQLite adapter (local or Turso)
@kernl-sdk/turbopuffervectorTurbopuffer vector search

Example with Postgres + Turbopuffer

import { Kernl } from "kernl";
import { postgres } from "@kernl-sdk/pg";
import { turbopuffer } from "@kernl-sdk/turbopuffer";
import { openai } from "@kernl-sdk/ai/openai";

const kernl = new Kernl({
  storage: {
    db: postgres({ url: process.env.DATABASE_URL }),
    vector: turbopuffer({
      apiKey: process.env.TURBOPUFFER_API_KEY,
      region: "us-east-1",
    }),
  },
  memory: {
    embedding: openai.embedding("text-embedding-3-small"),
  },
});

Example with Postgres + pgvector

You can also pass the pool directly to share connections:

import { Kernl } from "kernl";
import { postgres, pgvector } from "@kernl-sdk/pg";
import { openai } from "@kernl-sdk/ai/openai";
import { Pool } from "pg";

const pool = new Pool({ connectionString: process.env.DATABASE_URL });

const kernl = new Kernl({
  storage: {
    db: postgres({ pool }),
    vector: pgvector({ pool }),
  },
  memory: {
    embedding: openai.embedding("text-embedding-3-small"),
  },
});

Memory Options

Configure how agent memories are stored and searched.

Prop

Type

Full Example

import { Kernl, Agent } from "kernl";
import { postgres, pgvector } from "@kernl-sdk/pg";
import { anthropic } from "@kernl-sdk/ai/anthropic";
import { openai } from "@kernl-sdk/ai/openai";

const kernl = new Kernl({
  storage: {
    db: postgres({ url: process.env.DATABASE_URL }),
    vector: pgvector({ url: process.env.DATABASE_URL }),
  },
  memory: {
    embedding: openai.embedding("text-embedding-3-small"),
  },
});

const assistant = new Agent({
  id: "assistant",
  name: "Assistant",
  model: anthropic("claude-sonnet-4-5"),
  instructions: "You are a helpful assistant with memory.",
  memory: { enabled: true },
});

kernl.register(assistant);

const result = await assistant.run("Remember that my favorite color is blue.");

On this page