Memory Tool
Status: Planned
Persistent storage for context, preferences, and learned information.
Capabilities
- Store/retrieve key-value data
- Semantic search over memories
- Learn from interactions
- Manage conversation context
- Track user preferences
Interface
typescript
interface MemoryTool extends Tool { name: "memory"; actions: { // Basic storage store(key: string, value: unknown, metadata?: MemoryMetadata): Promise<void>; retrieve(key: string): Promise<unknown | null>; delete(key: string): Promise<void>; list(prefix?: string): Promise<string[]>; // Semantic search search(query: string, options?: SearchOptions): Promise<MemoryResult[]>; // Context management getContext(conversationId: string): Promise<ConversationContext>; updateContext(conversationId: string, context: Partial<ConversationContext>): Promise<void>; // Preferences getPreference(key: string): Promise<unknown>; setPreference(key: string, value: unknown): Promise<void>; // Learning recordInteraction(interaction: Interaction): Promise<void>; getInsights(topic?: string): Promise<Insight[]>; }; } interface MemoryMetadata { category?: string; tags?: string[]; expiresAt?: Date; importance?: number; } interface MemoryResult { key: string; value: unknown; score: number; // Relevance score metadata: MemoryMetadata; }
Memory Categories
Short-term (Conversation)
- Current conversation context
- Recent tool outputs
- Temporary working data
Long-term (Persistent)
- User preferences
- Learned patterns
- Important facts
- Previous conversations (summarized)
Semantic (Searchable)
- Indexed by content
- Supports natural language queries
- Uses embeddings for similarity
Storage Backend
Local storage in ~/.bot0/memory/:
~/.bot0/memory/
├── kv/ # Key-value store
│ ├── preferences.json
│ └── context/
├── conversations/ # Conversation history
│ └── {id}.json
├── embeddings/ # Vector store for semantic search
│ └── index.bin
└── insights/ # Learned patterns
└── insights.json
Example Usage
typescript
// Store a fact await memory.store("user.timezone", "America/New_York", { category: "preference", importance: 0.8 }); // Semantic search const results = await memory.search("what does the user prefer for meetings?"); // Get conversation context const context = await memory.getContext("conv_123");
Privacy Considerations
- All memory stored locally
- User can view/delete any memory
- Option to disable learning
- Export/import memory
Open Questions
- How to handle memory that becomes outdated?
- Should memory sync to cloud (Bytespace)?
- How much conversation history to retain?
- Vector embedding model to use?