Skip to main content
Glama

cleanup_expired_working_memory

Removes expired working memories from the AGI MCP Server's persistent storage system to maintain efficient memory management and free up resources.

Instructions

Clean up expired working memories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual implementation that deletes expired working memory records from the database. It queries the working_memory table for records where expiry is not null and less than or equal to current timestamp, then deletes and returns them.
    async cleanupExpiredWorkingMemory() {
      try {
        const expired = await this.db
          .delete(schema.workingMemory)
          .where(
            and(
              isNotNull(schema.workingMemory.expiry),
              lte(schema.workingMemory.expiry, new Date())
            )
          )
          .returning();
    
        return expired;
      } catch (error) {
        console.error('Error cleaning up expired working memory:', error);
        throw error;
      }
    }
  • Database schema definition for the working_memory table that includes the expiry timestamp field used to identify expired records.
    export const workingMemory = pgTable("working_memory", {
    	id: uuid().defaultRandom().primaryKey().notNull(),
    	createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
    	content: text().notNull(),
    	embedding: vector({ dimensions: 1536 }).notNull(),
    	expiry: timestamp({ withTimezone: true, mode: 'string' }),
    });
  • Tool schema definition in the memory-tools module that defines the input/output structure for cleanup_expired_working_memory tool.
    {
      name: "cleanup_expired_working_memory",
      description: "Clean up expired working memories",
      inputSchema: {
        type: "object",
        properties: {}
      }
    },
  • mcp.js:450-457 (registration)
    MCP tool registration that exposes cleanup_expired_working_memory as an available tool to MCP clients.
    {
      name: "cleanup_expired_working_memory",
      description: "Clean up expired working memories",
      inputSchema: {
        type: "object",
        properties: {}
      }
    },
  • mcp.js:670-672 (handler)
    MCP request handler that routes cleanup_expired_working_memory tool calls to the MemoryManager's cleanupExpiredWorkingMemory method and returns the cleaned memories as JSON.
    case "cleanup_expired_working_memory":
      const cleanedMemories = await memoryManager.cleanupExpiredWorkingMemory();
      return { content: [{ type: "text", text: JSON.stringify(cleanedMemories, null, 2) }] };
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Clean up' suggests a destructive operation that removes or archives expired working memories, but it doesn't specify whether this is reversible, what permissions are required, or how it affects system state (e.g., whether it triggers notifications or updates indices). For a potentially destructive tool with zero annotation coverage, this leaves critical behavioral traits undocumented.

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 extremely concise—a single four-word phrase—with zero wasted words. It's front-loaded with the core action ('Clean up') and target ('expired working memories'), making it easy to parse. For a simple, parameterless tool, this brevity is appropriate and efficient.

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 tool's potential complexity (it likely performs destructive cleanup of memory data) and the absence of both annotations and an output schema, the description is insufficiently complete. It doesn't explain what 'clean up' entails operationally, what constitutes 'expired', what the tool returns (if anything), or how it differs from sibling tools. For a tool that could significantly impact system state, more context is needed.

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

Parameters4/5

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

The tool has zero parameters, and schema description coverage is 100%, so there are no parameters to document. The description doesn't need to compensate for any parameter gaps. A baseline score of 4 is appropriate since the absence of parameters means the description's lack of parameter information isn't a deficiency—it simply describes a parameterless operation.

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

Purpose2/5

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

The description 'Clean up expired working memories' is a tautology that essentially restates the tool name 'cleanup_expired_working_memory'. While it clarifies the verb ('clean up') and target resource ('expired working memories'), it doesn't distinguish this tool from potential sibling operations like 'prune_memories' or 'archive_old_memories' that might handle similar cleanup tasks. The purpose is somewhat clear but lacks specificity about what 'clean up' entails compared to alternatives.

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 'prune_memories' or 'archive_old_memories'. It doesn't specify triggers (e.g., automated vs. manual cleanup), prerequisites, or context for invoking it. While the name implies it targets 'expired' items, the description doesn't elaborate on what qualifies as 'expired' or when this operation is appropriate versus other memory management tools.

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