Memory Contexts
Memory contexts control how data is isolated and shared. Rekall supports Personal, Hive, and Agent contexts, each with distinct visibility and sharing rules.
Overview
Every memory in Rekall exists within a context that determines who can read and write it. Contexts provide data isolation between users, teams, and agents while enabling controlled sharing when needed.
Personal
Per-user memories. Private to the individual. Default context for all operations.
Hive
Shared team memories. Accessible to all members of an organization.
Agent
Per-agent memories including husk identity and agent-specific knowledge.
Personal Context
Personal context is the default. When you create a memory without specifying a context, it is stored in the current user's personal context. These memories are only accessible by the user who created them and agents acting on their behalf.
import Rekall from '@rekall/sdk';const rekall = new Rekall({ apiKey: 'rk_your_api_key' });// Personal context is the default - no need to specifyconst memory = await rekall.episodic.create({content: 'User prefers dark mode in all applications',importance: 0.7,});// Explicitly specify personal contextconst memory2 = await rekall.episodic.create({content: 'Private note about project concerns',importance: 0.6,context: 'personal',});// Search only personal memoriesconst results = await rekall.episodic.search({query: 'UI preferences',context: 'personal',});
Hive Context
Hive context provides shared memories accessible to all members of an organization. Use it for team knowledge, shared procedures, organizational facts, and any information that should be available to the whole team.
// Create a shared team memoryawait rekall.episodic.create({content: 'The team decided to migrate from REST to GraphQL for the public API',importance: 0.9,context: 'hive',participants: ['user:alice', 'user:bob', 'user:carol'],});// Create shared entitiesawait rekall.semantic.entities.create({name: 'API Migration Project',type: 'project',attributes: { status: 'in_progress', deadline: '2025-Q2' },context: 'hive',});// Search across team knowledgeconst teamResults = await rekall.episodic.search({query: 'API migration decisions',context: 'hive',});// Create shared proceduresawait rekall.procedural.create({name: 'Production Deployment Checklist',steps: [/* ... */],context: 'hive',});
Hive permissions
Hive context requires the memory:hive:write scope to create memories and memory:hive:read to search. See Scopes & Permissions.
Agent Context
Agent context stores memories specific to a particular agent instance. This includes the agent's "husk" identity (personality, system prompt, behavioral patterns) and knowledge the agent acquires through its own operation.
Agent context has two sub-layers:
- •Husk identity: The agent's personality, tone, role, and behavioral guidelines. Persists across all sessions.
- •Agent knowledge: Facts, procedures, and preferences specific to this agent's function and learned from operation.
// Set agent identity (husk)await rekall.agent.setIdentity({agentId: 'code-reviewer',husk: {name: 'CodeReview Bot',role: 'Senior code reviewer',personality: 'Thorough, constructive, focuses on maintainability',guidelines: ['Always explain the reasoning behind suggestions','Prioritize security and performance issues','Suggest alternatives, do not just point out problems',],},});// Store agent-specific knowledgeawait rekall.episodic.create({content: 'The codebase uses a custom ESLint config that disallows default exports',importance: 0.8,context: { type: 'agent', agentId: 'code-reviewer' },});// Query agent contextconst agentKnowledge = await rekall.episodic.search({query: 'ESLint configuration rules',context: { type: 'agent', agentId: 'code-reviewer' },});
Switching Contexts
You can set a default context for the SDK instance or specify context per-operation. Per-operation context overrides the instance default.
// Set default context for all operationsconst rekall = new Rekall({apiKey: 'rk_your_api_key',defaultContext: 'hive',});// Override per-operationconst personal = await rekall.episodic.search({query: 'my preferences',context: 'personal', // Overrides 'hive' default});// Use a scoped client for a specific contextconst agentClient = rekall.withContext({type: 'agent',agentId: 'code-reviewer',});// All operations on agentClient use agent contextawait agentClient.episodic.create({content: 'Learned about the team naming conventions',importance: 0.7,});
Cross-Context Queries
Sometimes you need to search across multiple contexts. Rekall supports multi-context queries that merge results from personal, hive, and agent contexts, respecting visibility rules.
// Search across personal and hive contextsconst results = await rekall.episodic.search({query: 'deployment best practices',context: ['personal', 'hive'], // Search bothlimit: 10,});// Results include a 'context' field indicating the sourcefor (const mem of results) {console.log(`[${mem.context}] ${mem.content}`);}// Search all contexts the user has access toconst allResults = await rekall.episodic.search({query: 'deployment best practices',context: 'all',limit: 10,});
Data Isolation
Contexts enforce strict data isolation at the storage level:
| From \ To | Personal | Hive | Agent |
|---|---|---|---|
| Personal | Own only | No access | No access |
| Hive | No access | All org members | No access |
| Agent | No access | No access | Same agent only |
| Cross-context query | Own only | If org member | If agent owner |
No lateral access
A user's personal context cannot access another user's personal context. An agent's context cannot access another agent's context. Cross-context queries only return data the requesting identity is authorized to see.
Best Practices
- 1.Default to personal context. Unless data should be shared, keep it personal. You can always promote data to hive later.
- 2.Use hive for team knowledge. Decisions, procedures, and shared facts belong in hive context so the whole team benefits.
- 3.Define agent husks early. Set up the agent's identity before it starts interacting. A well-defined husk leads to more consistent behavior.
- 4.Use cross-context search sparingly. Searching "all" contexts is convenient but slower. Specify the contexts you need when possible.
- 5.Audit hive writes. Since hive memories affect the whole team, consider a review process for important shared knowledge.
