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",
cardinality: "single" // 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.
- Cardinality:
single: Only one instance of this memory type exists per user/agent (e.g., User Profile). Updates will merge/overwrite.multiple: Multiple instances can exist (e.g., Task, Note). New extractions create new records.
Last updated on