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"
            }
          }
        }
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action is 'permanently delete', which implies a destructive operation, but doesn't mention permissions required, whether deletions are reversible, rate limits, or what happens to related data. The description is minimal and lacks critical behavioral context for a destructive tool.

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 with no wasted words. It's front-loaded with the core action and resource, making it easy to scan and understand 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?

For a destructive tool with no annotations, no output schema, and a nested parameter object, the description is inadequate. It lacks details on behavioral traits, usage context, parameter meanings, and expected outcomes. Given the complexity and potential impact, more completeness is needed to guide safe and effective use.

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 'based on criteria', which aligns with the input schema's single nested object parameter named 'criteria'. However, with 0% schema description coverage (the schema has no top-level description), the description doesn't add meaningful details about what criteria are available or how they work. It provides minimal value beyond what's implied by the parameter name.

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'), and specifies the operation is based on criteria. However, it doesn't distinguish this tool from sibling tools like 'archive_old_memories' or 'cleanup_expired_working_memory', which might 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, prerequisites, or exclusions for usage.

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