Skip to main content
Glama

consolidate_working_memory

Combine multiple working memories into a single semantic memory to maintain long-term continuity for AI systems.

Instructions

Consolidate multiple working memories into a single semantic memory

Input Schema

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

Implementation Reference

  • mcp.js:626-632 (handler)
    MCP tool handler that receives tool requests and calls memoryManager.consolidateWorkingMemory() with the provided arguments (working_memory_ids, consolidated_content, consolidated_embedding)
    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) }] };
  • Core implementation of consolidateWorkingMemory that creates a new semantic memory, establishes consolidation relationships to source working memories, marks them as consolidated, and records 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;
      }
    }
  • Tool schema definition that defines the input parameters: working_memory_ids (array of UUIDs), consolidated_content (string), and consolidated_embedding (number array)
      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"]
      }
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool consolidates memories but doesn't explain what happens to the original working memories (e.g., are they deleted, archived, or retained?), the permissions required, or any side effects like rate limits. This leaves critical behavioral traits unspecified for a mutation operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and wastes no space, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., effects on original memories), usage context, and return values, leaving significant gaps for an agent to understand how to invoke and interpret results effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the three required parameters. The description doesn't add any meaning beyond the schema, such as explaining how 'consolidated_content' should relate to the input IDs or what format 'consolidated_embedding' expects. With high schema coverage, a baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('consolidate') and resources ('multiple working memories into a single semantic memory'), making the purpose understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'create_memory' or 'create_memory_cluster', which might also involve memory creation or aggregation, leaving some ambiguity about its unique role.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing existing working memories, or compare it to siblings like 'create_memory' or 'prune_memories', leaving the agent without context for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/randyandrade/agi-mcp-server'

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