cleanup_expired_working_memory
Remove expired working memories to optimize storage and maintain efficient memory management in AI systems, ensuring continuity and relevance in conversations.
Instructions
Clean up expired working memories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/memory-manager.js:486-503 (handler)The core handler function that executes the tool logic: deletes expired working memories from the database (where expiry is not null and <= now) using Drizzle ORM and returns the deleted records.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; } }
- src/tools/memory-tools.js:424-431 (schema)The tool schema definition including name, description, and empty input schema (no parameters required). Identical schema also appears in mcp.js.{ name: "cleanup_expired_working_memory", description: "Clean up expired working memories", inputSchema: { type: "object", properties: {} } },
- mcp.js:670-672 (registration)Registration and dispatching of the tool in the MCP server's CallToolRequestHandler switch statement, invoking the handler and formatting response.case "cleanup_expired_working_memory": const cleanedMemories = await memoryManager.cleanupExpiredWorkingMemory(); return { content: [{ type: "text", text: JSON.stringify(cleanedMemories, null, 2) }] };
- mcp.js:450-457 (registration)Tool registration in the MCP server's ListToolsRequestHandler, listing the tool with its schema for client discovery.{ name: "cleanup_expired_working_memory", description: "Clean up expired working memories", inputSchema: { type: "object", properties: {} } },