rag_cache_clear
Clears the LAZY-RAG cache to reset the system, enabling a fresh start for processing new queries.
Instructions
Clear the LAZY-RAG cache to start fresh
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers/tools.ts:1307-1331 (handler)The handler function that executes the rag_cache_clear tool logic. It calls getRAGIntegrator().clearCache() and returns the result showing how many cached entries were cleared.
private async handleRagCacheClear(_args: any): Promise<CallToolResult> { try { const rag = getRAGIntegrator(); const result = rag.clearCache(); return { content: [{ type: 'text', text: `๐งน LAZY-RAG Cache Cleared โ Cleared ${result.previousSize} cached entries ๐ก Next queries will call the API and repopulate the cache` }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return { content: [{ type: 'text', text: `โ Failed to clear cache: ${errorMessage}` }], isError: true }; } } - src/handlers/tools.ts:241-248 (schema)The tool definition/schema for rag_cache_clear. It has no input parameters (empty properties object) and a description 'Clear the LAZY-RAG cache to start fresh'.
{ name: 'rag_cache_clear', description: 'Clear the LAZY-RAG cache to start fresh', inputSchema: { type: 'object', properties: {} } } - src/handlers/tools.ts:299-300 (registration)The case branch in the callTool switch statement that routes 'rag_cache_clear' to handleRagCacheClear().
case 'rag_cache_clear': return await this.handleRagCacheClear(args); - src/rag/index.ts:97-104 (helper)The clearCache() method on RAGIntegrator that delegates to LazyRAGCache.clear(), returning the previous size before clearing.
/** * Clear cache */ clearCache(): { cleared: boolean; previousSize: number } { const previousSize = this.cache.stats().size; this.cache.clear(); return { cleared: true, previousSize }; } - src/rag/cache.ts:73-78 (helper)The LazyRAGCache.clear() method that actually clears the in-memory cache map and resets the hit/miss counters to zero.
*/ clear(): void { this.cache.clear(); this.hits = 0; this.misses = 0; }