feat: add memory embedding cache

This commit is contained in:
Peter Steinberger
2026-01-18 01:35:58 +00:00
parent 568b8ee96c
commit 0fb2777c6d
9 changed files with 372 additions and 27 deletions

View File

@@ -190,6 +190,8 @@ const FIELD_LABELS: Record<string, string> = {
"agents.defaults.memorySearch.sync.watchDebounceMs": "Memory Watch Debounce (ms)",
"agents.defaults.memorySearch.query.maxResults": "Memory Search Max Results",
"agents.defaults.memorySearch.query.minScore": "Memory Search Min Score",
"agents.defaults.memorySearch.cache.enabled": "Memory Search Embedding Cache",
"agents.defaults.memorySearch.cache.maxEntries": "Memory Search Embedding Cache Max Entries",
"auth.profiles": "Auth Profiles",
"auth.order": "Auth Profile Order",
"auth.cooldowns.billingBackoffHours": "Billing Backoff (hours)",
@@ -382,11 +384,15 @@ const FIELD_HELP: Record<string, string> = {
"agents.defaults.memorySearch.fallback":
'Fallback to OpenAI when local embeddings fail ("openai" or "none").',
"agents.defaults.memorySearch.store.path":
"SQLite index path (default: ~/.clawdbot/state/memory/{agentId}.sqlite).",
"SQLite index path (default: ~/.clawdbot/memory/{agentId}.sqlite).",
"agents.defaults.memorySearch.store.vector.enabled":
"Enable sqlite-vec extension for vector search (default: true).",
"agents.defaults.memorySearch.store.vector.extensionPath":
"Optional override path to sqlite-vec extension library (.dylib/.so/.dll).",
"agents.defaults.memorySearch.cache.enabled":
"Cache chunk embeddings in SQLite to speed up reindexing and frequent updates (default: true).",
"agents.defaults.memorySearch.cache.maxEntries":
"Optional cap on cached embeddings (best-effort).",
"agents.defaults.memorySearch.sync.onSearch":
"Lazy sync: reindex on first search after a change.",
"agents.defaults.memorySearch.sync.watch": "Watch memory files for changes (chokidar).",

View File

@@ -192,6 +192,12 @@ export type MemorySearchConfig = {
/** Optional override path to sqlite-vec extension (.dylib/.so/.dll). */
extensionPath?: string;
};
cache?: {
/** Enable embedding cache (default: true). */
enabled?: boolean;
/** Optional max cache entries per provider/model. */
maxEntries?: number;
};
};
/** Chunking configuration. */
chunking?: {
@@ -210,6 +216,23 @@ export type MemorySearchConfig = {
query?: {
maxResults?: number;
minScore?: number;
hybrid?: {
/** Enable hybrid BM25 + vector search (default: true). */
enabled?: boolean;
/** Weight for vector similarity when merging results (0-1). */
vectorWeight?: number;
/** Weight for BM25 text relevance when merging results (0-1). */
textWeight?: number;
/** Multiplier for candidate pool size (default: 4). */
candidateMultiplier?: number;
};
};
/** Index cache behavior. */
cache?: {
/** Cache chunk embeddings in SQLite (default: true). */
enabled?: boolean;
/** Optional cap on cached embeddings (best-effort). */
maxEntries?: number;
};
};

View File

@@ -258,6 +258,12 @@ export const MemorySearchSchema = z
minScore: z.number().min(0).max(1).optional(),
})
.optional(),
cache: z
.object({
enabled: z.boolean().optional(),
maxEntries: z.number().int().positive().optional(),
})
.optional(),
})
.optional();
export const AgentModelSchema = z.union([