search_episodic_memory
Search through user event history and past experiences to retrieve relevant memories based on content queries, enabling personalized AI interactions through comprehensive memory recall.
Instructions
Search episodic memories by content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results | |
| query | Yes | Search query | |
| userId | Yes | User identifier |
Implementation Reference
- src/handlers/ToolHandlers.ts:302-317 (handler)The tool handler case that validates input parameters (userId, query, limit) and calls memoryStore.searchEpisodicMemory to execute the tool logic, returning the results as JSON text.case "search_episodic_memory": { const { userId, query, limit } = request.params.arguments as any; // Validate inputs ValidationUtils.validateUserId(userId); ValidationUtils.validateSearchQuery(query); ValidationUtils.validateLimit(limit); const memories = memoryStore.searchEpisodicMemory(userId, query, limit); return { content: [{ type: "text", text: JSON.stringify(memories, null, 2) }] }; }
- src/handlers/ToolHandlers.ts:167-183 (schema)Input schema defining the expected arguments for the search_episodic_memory tool: userId (required string), query (required string), limit (optional number).inputSchema: { type: "object", properties: { userId: { type: "string", description: "User identifier" }, query: { type: "string", description: "Search query" }, limit: { type: "number", description: "Maximum number of results" } }, required: ["userId", "query"]
- src/handlers/ToolHandlers.ts:164-185 (registration)Registration of the search_episodic_memory tool in the list of available tools, including name, description, and input schema.{ name: "search_episodic_memory", description: "Search episodic memories by content", inputSchema: { type: "object", properties: { userId: { type: "string", description: "User identifier" }, query: { type: "string", description: "Search query" }, limit: { type: "number", description: "Maximum number of results" } }, required: ["userId", "query"] } }
- src/store/MemoryStore.ts:169-182 (helper)Core implementation of episodic memory search: filters user memories where query matches event, context, outcome, or tags (case-insensitive), sorts by recency, and applies limit.searchEpisodicMemory(userId: string, query: string, limit?: number): EpisodicMemory[] { const searchTerm = query.toLowerCase(); const memories = Array.from(this.episodicMemory.values()) .filter(memory => memory.userId === userId && (memory.event.toLowerCase().includes(searchTerm) || memory.context.toLowerCase().includes(searchTerm) || memory.outcome?.toLowerCase().includes(searchTerm) || memory.tags?.some(tag => tag.toLowerCase().includes(searchTerm))) ) .sort((a, b) => b.timestamp - a.timestamp); return limit ? memories.slice(0, limit) : memories; }