Skip to main content
Glama

consolidate_working_memory

Combine multiple working memories into a unified semantic memory for enhanced AI context continuity. Input working memory UUIDs, consolidated content, and embedding for integration.

Instructions

Consolidate multiple working memories into a single semantic memory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
consolidated_contentYesContent for the consolidated memory
consolidated_embeddingYesEmbedding for the consolidated memory
working_memory_idsYesArray of working memory UUIDs to consolidate

Implementation Reference

  • Core handler function implementing the tool logic: creates a new semantic memory from consolidated content and embedding, establishes consolidation relationships from working memories, marks source memories as consolidated, and logs the event.
    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; } }
  • mcp.js:626-632 (handler)
    MCP server dispatch handler for the tool, extracting arguments and calling the MemoryManager's consolidateWorkingMemory method, returning JSON 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) }] };
  • Tool schema definition including name, description, and inputSchema used in MCP listTools response.
    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"] }
  • Input schema and tool metadata definition in the memoryTools export array (duplicated in mcp.js).
    { 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"] }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/QuixiAI/agi-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server