archive_old_memories
Archive AI memories by age and importance to manage long-term data storage, enabling efficient memory organization and continuity.
Instructions
Archive old memories based on age and importance criteria
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days_old | No | Minimum age in days for archival | |
| importance_threshold | No | Maximum importance for archival |
Implementation Reference
- src/memory-manager.js:776-811 (handler)The main implementation of archiveOldMemories method that archives old memories based on age, importance, and access count criteria. Updates memory status to 'archived' and records archival events in the memoryChanges table.
async archiveOldMemories(daysOld = 365, importanceThreshold = 0.3) { try { const cutoffDate = new Date(Date.now() - daysOld * 24 * 60 * 60 * 1000); const archivedMemories = await this.db .update(schema.memories) .set({ status: 'archived' }) .where( and( eq(schema.memories.status, 'active'), lt(schema.memories.createdAt, cutoffDate), lt(schema.memories.importance, importanceThreshold), lt(schema.memories.accessCount, 5) ) ) .returning({ id: schema.memories.id, content: schema.memories.content, type: schema.memories.type }); // Record archival events for (const memory of archivedMemories) { await this.db.insert(schema.memoryChanges).values({ memoryId: memory.id, changeType: 'archival', newValue: { reason: 'Archived due to age and low importance' } }); } return archivedMemories; } catch (error) { console.warn('Memory archival failed:', error.message); return []; } } - mcp.js:634-639 (registration)MCP tool handler registration that maps the 'archive_old_memories' tool name to the MemoryManager.archiveOldMemories method, extracting days_old and importance_threshold parameters from args.
case "archive_old_memories": const archivedMemories = await memoryManager.archiveOldMemories( args.days_old || 365, args.importance_threshold || 0.3 ); return { content: [{ type: "text", text: JSON.stringify(archivedMemories, null, 2) }] }; - mcp.js:320-332 (schema)Input schema definition for the archive_old_memories tool, specifying days_old (integer, default 365) and importance_threshold (number, default 0.3) parameters with descriptions.
{ name: "archive_old_memories", description: "Archive old memories based on age and importance criteria", inputSchema: { type: "object", properties: { days_old: { type: "integer", description: "Minimum age in days for archival", default: 365 }, importance_threshold: { type: "number", - src/tools/memory-tools.js:294-311 (schema)Duplicate schema definition for archive_old_memories tool with the same parameter structure as in mcp.js, defining the input validation schema for the tool.
{ name: "archive_old_memories", description: "Archive old memories based on age and importance criteria", inputSchema: { type: "object", properties: { days_old: { type: "integer", description: "Minimum age in days for archival", default: 365 }, importance_threshold: { type: "number", description: "Maximum importance for archival", default: 0.3 } } }