mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-29 03:01:50 +03:00
Memory-lancedb: configurable capture limit (#16624) (thanks @ciberponk)
This commit is contained in:
committed by
Vignesh
parent
3e00460cdc
commit
8cb0373bc1
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user