Give Eliza OS agents durable cross-session memory.
Eliza OS Integration
Eliza is a TypeScript multi-agent framework. Use the cortexdbai SDK to add memory provider for agent characters.
Install
npm install cortexdbai @ai16z/eliza
Pattern — memory provider
import type { IAgentRuntime, Memory } from "@ai16z/eliza";
import { V1Client } from "cortexdbai/v1";
const cortex = new V1Client({
apiUrl: "https://api-v1.cortexdb.ai",
actor: "agent:eliza",
bearer: process.env.CORTEX_TOKEN!,
});
export async function recall(runtime: IAgentRuntime, message: Memory): Promise<string> {
const scope = `org:acme/character:${runtime.character.name}`;
const pack = await cortex.recall(scope, {
view: "holistic",
query: message.content.text,
include: ["beliefs", "facts", "episodes"],
budgets: { max_tokens: 3000 },
});
return pack.context_block ?? "";
}
export async function capture(runtime: IAgentRuntime, message: Memory): Promise<void> {
const scope = `org:acme/character:${runtime.character.name}`;
await cortex.experience(scope, {
modality: "conversation",
content: { kind: "message", role: message.userId === runtime.agentId ? "assistant" : "user", text: message.content.text },
context: { observed_at: new Date().toISOString() },
idempotency_key: `eliza-${message.id}`,
});
}
Register these in your character's plugin so every turn flows through CortexDB.
See also
- TypeScript SDK
- Scopes — per-character scoping