Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(memory): handle exactOptionalPropertyTypes for optional fields

Jiang Bohan22536fd24c19
diff --git a/src/agent/tools/memory/storage.test.ts b/src/agent/tools/memory/storage.test.ts
index 5710439901..c67592aa96 100644
--- a/src/agent/tools/memory/storage.test.ts
+++ b/src/agent/tools/memory/storage.test.ts
@@ -199,7 +199,7 @@ describe("memory storage", () => {
const result = memoryList(undefined, undefined, options);
// project.config should be first as it was updated most recently
- expect(result.keys[0].key).toBe("project.config");
+ expect(result.keys[0]?.key).toBe("project.config");
});
it("should return empty array for non-existent directory", () => {
diff --git a/src/agent/tools/memory/storage.ts b/src/agent/tools/memory/storage.ts
index b4c2f41ec9..e7c2975895 100644
--- a/src/agent/tools/memory/storage.ts
+++ b/src/agent/tools/memory/storage.ts
@@ -135,9 +135,10 @@ export function memorySet(
const now = Date.now();
const existing = memoryGet(trimmedKey, options);
+ const trimmedDescription = description?.trim();
const entry: MemoryEntry = {
value,
- description: description?.trim() || undefined,
+ ...(trimmedDescription ? { description: trimmedDescription } : {}),
createdAt: existing.found ? existing.entry.createdAt : now,
updatedAt: now,
};
@@ -217,7 +218,7 @@ export function memoryList(
const entry = JSON.parse(content) as MemoryEntry;
entries.push({
key,
- description: entry.description,
+ ...(entry.description ? { description: entry.description } : {}),
updatedAt: entry.updatedAt,
});
} catch {