consolidate_working_memory
Combine multiple working memory entries into a single semantic memory to organize and preserve information for AI systems.
Instructions
Consolidate multiple working memories into a single semantic memory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| working_memory_ids | Yes | Array of working memory UUIDs to consolidate | |
| consolidated_content | Yes | Content for the consolidated memory | |
| consolidated_embedding | Yes | Embedding for the consolidated memory |
Implementation Reference
- src/memory-manager.js:726-774 (handler)The core handler function that performs the consolidation: creates a new semantic memory, establishes consolidation relationships, marks originals as consolidated, and logs the event in a database transaction.async consolidateWorkingMemory(workingMemoryIds, consolidatedContent, consolidatedEmbedding) { try { const result = await this.db.transaction(async (tx) => { // Create consolidated memory const [consolidatedMemory] = await tx .insert(schema.memories) .values({ type: 'semantic', content: consolidatedContent, embedding: consolidatedEmbedding, importance: 0.8, status: 'active' }) .returning(); const consolidatedId = consolidatedMemory.id; // Create relationships from working memories to consolidated memory for (const workingId of workingMemoryIds) { await tx.insert(schema.memoryRelationships).values({ fromMemoryId: workingId, toMemoryId: consolidatedId, relationshipType: 'consolidation', strength: 1.0 }); // Mark working memory as consolidated await tx .update(schema.memories) .set({ status: 'consolidated' }) .where(eq(schema.memories.id, workingId)); } // Record consolidation event await tx.insert(schema.memoryChanges).values({ memoryId: consolidatedId, changeType: 'consolidation', newValue: { source_memories: workingMemoryIds } }); return consolidatedMemory; }); return result; } catch (error) { console.warn('Memory consolidation failed:', error.message); throw error; } }
- src/tools/memory-tools.js:271-292 (schema)Tool schema definition including input validation structure for the consolidate_working_memory tool.name: "consolidate_working_memory", description: "Consolidate multiple working memories into a single semantic memory", inputSchema: { type: "object", properties: { working_memory_ids: { type: "array", items: { type: "string" }, description: "Array of working memory UUIDs to consolidate" }, consolidated_content: { type: "string", description: "Content for the consolidated memory" }, consolidated_embedding: { type: "array", items: { type: "number" }, description: "Embedding for the consolidated memory" } }, required: ["working_memory_ids", "consolidated_content", "consolidated_embedding"] }
- mcp.js:626-632 (registration)MCP server tool call handler registration: switch case that dispatches the tool call to the memoryManager's consolidateWorkingMemory method and formats the response.case "consolidate_working_memory": const consolidatedMemory = await memoryManager.consolidateWorkingMemory( args.working_memory_ids, args.consolidated_content, args.consolidated_embedding ); return { content: [{ type: "text", text: JSON.stringify(consolidatedMemory, null, 2) }] };
- mcp.js:297-318 (schema)Tool schema provided in MCP server's listTools response for client validation.name: "consolidate_working_memory", description: "Consolidate multiple working memories into a single semantic memory", inputSchema: { type: "object", properties: { working_memory_ids: { type: "array", items: { type: "string" }, description: "Array of working memory UUIDs to consolidate" }, consolidated_content: { type: "string", description: "Content for the consolidated memory" }, consolidated_embedding: { type: "array", items: { type: "number" }, description: "Embedding for the consolidated memory" } }, required: ["working_memory_ids", "consolidated_content", "consolidated_embedding"] }