Schemas
Schemas define the structure of the memories your agents can create. The SDK allows you to define these schemas using standard Zod definitions, providing full type safety.
Registering a Schema
Use registerSchema to define a new memory structure.
import { z } from "zod";
await client.registerSchema(
"UserProfile",
z.object({
dietaryRestrictions: z.array(z.string()),
preferences: z.record(z.string())
}),
{
description: "User's dietary needs and general preferences",
uniqueOn: ["kind"] // Auto-supersede: only one profile per user
}
);Options
- Name: The unique name of the schema.
- Schema: A Zod object definition.
- Description: A natural language description of what this schema represents. This is crucial as it guides the LLM on when and how to use this schema.
- uniqueOn: Fields that identify the same logical entity for auto-supersede.
["kind"]: Only one instance of this schema type exists per user (e.g., User Profile). New memories supersede the previous one.["email"]: One instance per unique email address.- Omit for collections: Multiple instances can exist (e.g., Task, Note). New extractions create new records.
Last updated on