Purge Knowledge Base
ctx_purgePermanently delete indexed session or project content from Context Mode; cannot be undone. Requires confirm:true and exactly one scope: sessionId for one session or scope:'project' for all.
Instructions
DESTRUCTIVE: permanently delete indexed content. Cannot be undone. Requires confirm:true and exactly one scope.
WHEN:
User explicitly asks to clear a specific session ('purge this session', 'wipe this conversation')
User explicitly asks to reset the whole project ('reset everything', 'wipe the knowledge base')
WHEN NOT:
User says 'reset', 'clear', or 'wipe' without naming a scope -> ask which scope before calling
User wants to free memory -> recommend ctx_stats first
SCOPES (pass exactly one):
Per-session: ctx_purge(confirm: true, sessionId: "") — deletes that session's events and chunks; siblings and stats preserved.
Per-project: ctx_purge(confirm: true, scope: "project") — wipes the FTS5 knowledge base, every session DB row, events markdown, and resets stats. Preview with ctx_stats first.
CONTRACT:
confirm:true is required; confirm:false returns 'purge cancelled'.
sessionId and scope:'project' together return 'ambiguous - pick one'.
scope:'session' without sessionId throws.
Bare {confirm:true} is deprecated: maps to scope:'project' with a warning; will hard-error later.
RETURNS: A summary of removed rows + the resolved scope.
EXAMPLE: ctx_purge(confirm: true, sessionId: "7c8a-1234-5678-9abc-def012345678")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scope | No | Explicit scope selector. 'session' REQUIRES sessionId. 'project' wipes the entire project (FTS5 + every session + stats). Omit only for the deprecated bare-{confirm:true} back-compat path. | |
| confirm | Yes | MUST be true. Destructive operation; false returns 'purge cancelled'. | |
| sessionId | No | UUID of a single session. Pairs with confirm:true to wipe only that session's events + per-session FTS5 chunks. Sibling sessions and the stats file are preserved. MUST NOT be combined with scope:'project'. |