Memory-lancedb: configurable capture limit (#16624) (thanks @ciberponk)

This commit is contained in:
Vignesh Natarajan
2026-02-14 15:54:01 -08:00
committed by Vignesh
parent 3e00460cdc
commit 8cb0373bc1
4 changed files with 28 additions and 8 deletions
+24 -5
View File
@@ -61,7 +61,7 @@ describe("memory plugin e2e", () => {
expect(config).toBeDefined();
expect(config?.embedding?.apiKey).toBe(OPENAI_API_KEY);
expect(config?.dbPath).toBe(dbPath);
expect(config?.captureMaxChars).toBe(1500);
expect(config?.captureMaxChars).toBe(500);
});
test("config schema resolves env vars", async () => {
@@ -105,6 +105,21 @@ describe("memory plugin e2e", () => {
}).toThrow("captureMaxChars must be between 100 and 10000");
});
test("config schema accepts captureMaxChars override", async () => {
const { default: memoryPlugin } = await import("./index.js");
const config = memoryPlugin.configSchema?.parse?.({
embedding: {
apiKey: OPENAI_API_KEY,
model: "text-embedding-3-small",
},
dbPath,
captureMaxChars: 1800,
});
expect(config?.captureMaxChars).toBe(1800);
});
test("shouldCapture applies real capture rules", async () => {
const { shouldCapture } = await import("./index.js");
@@ -117,10 +132,14 @@ describe("memory plugin e2e", () => {
expect(shouldCapture("<relevant-memories>injected</relevant-memories>")).toBe(false);
expect(shouldCapture("<system>status</system>")).toBe(false);
expect(shouldCapture("Here is a short **summary**\n- bullet")).toBe(false);
const longButAllowed = `I always prefer this style. ${"x".repeat(1200)}`;
const tooLong = `I always prefer this style. ${"x".repeat(1600)}`;
expect(shouldCapture(longButAllowed, { maxChars: 1500 })).toBe(true);
expect(shouldCapture(tooLong, { maxChars: 1500 })).toBe(false);
const defaultAllowed = `I always prefer this style. ${"x".repeat(400)}`;
const defaultTooLong = `I always prefer this style. ${"x".repeat(600)}`;
expect(shouldCapture(defaultAllowed)).toBe(true);
expect(shouldCapture(defaultTooLong)).toBe(false);
const customAllowed = `I always prefer this style. ${"x".repeat(1200)}`;
const customTooLong = `I always prefer this style. ${"x".repeat(1600)}`;
expect(shouldCapture(customAllowed, { maxChars: 1500 })).toBe(true);
expect(shouldCapture(customTooLong, { maxChars: 1500 })).toBe(false);
});
test("detectCategory classifies using production logic", async () => {