Skip to main content
Glama

prune_memories

Permanently delete old, low-importance, or rarely accessed memories from AI systems to manage storage and maintain relevant data using customizable criteria.

Instructions

Permanently delete memories based on criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
criteriaNo

Implementation Reference

  • The main implementation of pruneMemories method that permanently deletes memories based on criteria (maxAge, minImportance, maxAccessCount, status). Updates memory status to 'deleted' and records deletion events.
    async pruneMemories(criteria = {}) {
      try {
        const {
          maxAge = 1095, // 3 years
          minImportance = 0.1,
          maxAccessCount = 2,
          status = 'archived'
        } = criteria;
    
        const cutoffDate = new Date(Date.now() - maxAge * 24 * 60 * 60 * 1000);
    
        const prunedMemories = await this.db
          .update(schema.memories)
          .set({ status: 'deleted' })
          .where(
            and(
              eq(schema.memories.status, status),
              lt(schema.memories.createdAt, cutoffDate),
              lt(schema.memories.importance, minImportance),
              lte(schema.memories.accessCount, maxAccessCount)
            )
          )
          .returning({
            id: schema.memories.id,
            content: schema.memories.content,
            type: schema.memories.type
          });
    
        // Record deletion events
        for (const memory of prunedMemories) {
          await this.db.insert(schema.memoryChanges).values({
            memoryId: memory.id,
            changeType: 'deletion',
            newValue: { reason: 'Pruned based on criteria', criteria }
          });
        }
    
        return prunedMemories;
      } catch (error) {
        console.warn('Memory pruning failed:', error.message);
        return [];
      }
    }
  • mcp.js:641-643 (handler)
    The MCP request handler that routes prune_memories tool calls to memoryManager.pruneMemories with the provided criteria.
    case "prune_memories":
      const prunedMemories = await memoryManager.pruneMemories(args.criteria || {});
      return { content: [{ type: "text", text: JSON.stringify(prunedMemories, null, 2) }] };
  • Schema definition for prune_memories tool as part of the exported memoryTools array, defining input properties (max_age, min_importance, max_access_count, status).
    name: "prune_memories",
    description: "Permanently delete memories based on criteria",
    inputSchema: {
      type: "object",
      properties: {
        criteria: {
          type: "object",
          properties: {
            max_age: {
              type: "integer",
              description: "Maximum age in days",
              default: 1095
            },
            min_importance: {
              type: "number",
              description: "Minimum importance threshold",
              default: 0.1
            },
            max_access_count: {
              type: "integer",
              description: "Maximum access count",
              default: 2
            },
            status: {
              type: "string",
              description: "Memory status to prune",
              default: "archived"
            }
          }
        }
      }
    }
  • mcp.js:340-371 (registration)
    Tool registration in the MCP server's tools list, registering prune_memories with its description and input schema for tool discovery.
    name: "prune_memories",
    description: "Permanently delete memories based on criteria",
    inputSchema: {
      type: "object",
      properties: {
        criteria: {
          type: "object",
          properties: {
            max_age: {
              type: "integer",
              description: "Maximum age in days",
              default: 1095
            },
            min_importance: {
              type: "number",
              description: "Minimum importance threshold",
              default: 0.1
            },
            max_access_count: {
              type: "integer",
              description: "Maximum access count",
              default: 2
            },
            status: {
              type: "string",
              description: "Memory status to prune",
              default: "archived"
            }
          }
        }
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries full burden. It discloses the destructive nature ('permanently delete') but lacks critical behavioral details: what permissions are required, whether deletions are reversible, rate limits, or what happens to related data. The description is insufficient for a destructive 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 front-loads the key information ('permanently delete memories'). There's no wasted verbiage or redundant information.

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?

For a destructive tool with no annotations and no output schema, the description is inadequate. It doesn't explain what 'memories' are in this context, what happens after deletion, error conditions, or return values. The description leaves too many open questions for safe usage.

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?

The description mentions 'criteria' but doesn't explain what criteria are available or their semantics. With 0% schema description coverage (schema has no top-level description), the description adds minimal value. However, since there's only 1 parameter (a nested object), the baseline is 3 as the schema documents the nested properties well.

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 ('permanently delete') and resource ('memories'), making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'archive_old_memories' or 'cleanup_expired_working_memory', which likely have overlapping functionality.

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 like 'archive_old_memories' or 'cleanup_expired_working_memory'. It mentions criteria-based deletion but doesn't specify scenarios or prerequisites for usage.

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