knowledge_forget
Remove outdated, incorrect, or irrelevant knowledge entries from the Prism MCP server to maintain a clean and relevant knowledge base. Delete entries by project, category, age, or perform a full reset.
Instructions
Selectively forget (delete) accumulated knowledge entries. Like a brain pruning bad memories — remove outdated, incorrect, or irrelevant session entries to keep the knowledge base clean and relevant.
Forget modes:
By project: Clear all knowledge for a specific project
By category: Remove entries matching a category (e.g. 'debugging')
By age: Forget entries older than N days
Full reset: Wipe everything (requires confirm_all=true)
⚠️ This permanently deletes ledger entries. Handoff state is preserved unless explicitly cleared.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | No | Project to forget entries for. Required unless using confirm_all. | |
| category | No | Optional: only forget entries in this category (e.g. 'debugging', 'resume'). | |
| older_than_days | No | Optional: only forget entries older than this many days. | |
| clear_handoff | No | Also clear the handoff (live state) for this project. Default: false. | |
| confirm_all | No | Set to true to confirm wiping ALL entries for the project (safety flag). | |
| dry_run | No | If true, only count what would be deleted without actually deleting. Default: false. |
Implementation Reference
- Handler for the 'knowledge_forget' tool, which prunes ledger entries and optionally clears project handoff data.
export async function knowledgeForgetHandler(args: unknown) { if (!isKnowledgeForgetArgs(args)) { throw new Error("Invalid arguments for knowledge_forget"); } const { project, category, older_than_days, clear_handoff = false, confirm_all = false, dry_run = false, } = args; if (!project && !confirm_all) { return { content: [{ type: "text", text: `⚠️ Safety check: You must specify a 'project' to forget, ` + `or set 'confirm_all: true' to wipe all entries.\n` + `This prevents accidental deletion of all knowledge.`, }], isError: true, }; } console.error(`[knowledge_forget] ${dry_run ? "DRY RUN: " : ""}Forgetting: ` + `project=${project || "ALL"}, category=${category || "any"}, ` + `older_than=${older_than_days || "any"}d, clear_handoff=${clear_handoff}`); const storage = await getStorage(); const ledgerParams: Record<string, string> = {}; ledgerParams.user_id = `eq.${PRISM_USER_ID}`; if (project) { ledgerParams.project = `eq.${project}`; } if (category) { ledgerParams.keywords = `cs.{cat:${category}}`; } if (older_than_days) { const cutoffDate = new Date(); cutoffDate.setDate(cutoffDate.getDate() - older_than_days); ledgerParams.created_at = `lt.${cutoffDate.toISOString()}`; } let ledgerCount = 0; let handoffCleared = false; if (dry_run) { const selectParams = { ...ledgerParams, select: "id" }; const entries = await storage.getLedgerEntries(selectParams); ledgerCount = entries.length; } else { const result = await storage.deleteLedger(ledgerParams); ledgerCount = result.length; if (clear_handoff && project) { await storage.deleteHandoff(project, PRISM_USER_ID); handoffCleared = true; } } const action = dry_run ? "would be forgotten" : "forgotten"; const emoji = dry_run ? "🔍" : "🧹"; return { content: [{ type: "text", text: `${emoji} ${ledgerCount} ledger entries ${action}` + (project ? ` for project "${project}"` : "") + (category ? ` in category "${category}"` : "") + (older_than_days ? ` older than ${older_than_days} days` : "") + `.\n` + (handoffCleared ? `🗑️ Handoff state also cleared for "${project}".\n` : "") + (dry_run ? `\n💡 This was a dry run — nothing was actually deleted. Remove dry_run to execute.` : "") + (!dry_run && ledgerCount > 0 ? `\n✅ Knowledge base pruned. Fresh start!` : ""), }], isError: false, }; }