feat(memory-lancedb): make auto-capture max length configurable

This commit is contained in:
fan
2026-02-15 07:38:29 +08:00
committed by Vignesh
parent 82c1d9d3ef
commit 3e00460cdc
4 changed files with 57 additions and 4 deletions
+6 -3
View File
@@ -194,8 +194,9 @@ const MEMORY_TRIGGERS = [
/always|never|important/i,
];
export function shouldCapture(text: string): boolean {
if (text.length < 10 || text.length > 500) {
export function shouldCapture(text: string, options?: { maxChars?: number }): boolean {
const maxChars = options?.maxChars ?? 1500;
if (text.length < 10 || text.length > maxChars) {
return false;
}
// Skip injected context from memory recall
@@ -570,7 +571,9 @@ const memoryPlugin = {
}
// Filter for capturable content
const toCapture = texts.filter((text) => text && shouldCapture(text));
const toCapture = texts.filter(
(text) => text && shouldCapture(text, { maxChars: cfg.captureMaxChars }),
);
if (toCapture.length === 0) {
return;
}