diff --git a/packages/tools/package.json b/packages/tools/package.json index 39cde98d8..5195c058c 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -14,6 +14,7 @@ "@ai-sdk/anthropic": "^2.0.25", "@ai-sdk/openai": "^2.0.23", "ai": "^5.0.29", + "lru-cache": "^11.2.6", "openai": "^4.104.0", "supermemory": "^3.0.0-alpha.26", "zod": "^4.1.5" diff --git a/packages/tools/src/shared/cache.ts b/packages/tools/src/shared/cache.ts index 9125b24ca..15ce16fe4 100644 --- a/packages/tools/src/shared/cache.ts +++ b/packages/tools/src/shared/cache.ts @@ -1,3 +1,4 @@ +import { LRUCache } from "lru-cache" import type { MemoryMode } from "./types" /** @@ -5,7 +6,7 @@ import type { MemoryMode } from "./types" * Used to cache memory retrieval results during tool-call loops within the same turn. */ export class MemoryCache { - private cache: Map = new Map() + private cache: LRUCache = new LRUCache({ max: 100 }) /** * Generates a cache key for the current turn based on context parameters.