Memory Spaces Guide
Multi-tenancy and isolation with Cortex Memory Spaces.
Overview
Memory Spaces provide isolated memory contexts for different users, teams, or projects. They are automatically created when you first use a memorySpaceId - no explicit registration is required for basic usage. Memory spaces provide complete data isolation, ensuring that all memories, conversations, facts, and contexts are scoped to a specific memory space.
Use Cases
1. Per-User Isolation
import { createCortexMemory } from "@cortexmemory/vercel-ai-provider";
const cortexMemory = createCortexMemory({
convexUrl: process.env.CONVEX_URL!,
memorySpaceId: `user-${currentUser.id}`,
userId: currentUser.id,
agentId: 'my-assistant',
});
2. Team Workspaces
import { createCortexMemory } from "@cortexmemory/vercel-ai-provider";
const cortexMemory = createCortexMemory({
convexUrl: process.env.CONVEX_URL!,
memorySpaceId: `team-${currentTeam.id}`,
userId: currentUser.id,
agentId: 'my-assistant',
});
3. Project-Based
import { createCortexMemory } from "@cortexmemory/vercel-ai-provider";
const cortexMemory = createCortexMemory({
convexUrl: process.env.CONVEX_URL!,
memorySpaceId: `project-${projectId}`,
userId: currentUser.id,
agentId: 'my-assistant',
});
Benefits
Data Isolation
Complete separation of data between memory spaces
Multi-Tenant SaaS
Built-in support for SaaS multi-tenancy
Team Collaboration
Share memory within teams or organizations
Per-Space Analytics
Track usage and performance per memory space
Managing Memory Spaces
For advanced usage, you can explicitly manage memory spaces using the Cortex SDK. Memory spaces can be registered, queried, updated, and deleted through the Memory Space Operations API. This includes capabilities like:
- Explicitly registering memory spaces with metadata
- Querying memory space details and statistics
- Updating memory space configurations
- Deleting memory spaces (with cascade options)