We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bc9120f commit 239fc12Copy full SHA for 239fc12
2 files changed
packages/tools/package.json
@@ -14,6 +14,7 @@
14
"@ai-sdk/anthropic": "^2.0.25",
15
"@ai-sdk/openai": "^2.0.23",
16
"ai": "^5.0.29",
17
+ "lru-cache": "^11.2.6",
18
"openai": "^4.104.0",
19
"supermemory": "^3.0.0-alpha.26",
20
"zod": "^4.1.5"
packages/tools/src/shared/cache.ts
@@ -1,11 +1,12 @@
1
+import { LRUCache } from "lru-cache"
2
import type { MemoryMode } from "./types"
3
4
/**
5
* Generic memory cache for storing per-turn memories to avoid redundant API calls.
6
* Used to cache memory retrieval results during tool-call loops within the same turn.
7
*/
8
export class MemoryCache<T = string> {
- private cache: Map<string, T> = new Map()
9
+ private cache: LRUCache<string, T> = new LRUCache({ max: 100 })
10
11
12
* Generates a cache key for the current turn based on context parameters.
0 commit comments