From 48fc103fe18c9e615bd9997cb256d0f9f9a31e49 Mon Sep 17 00:00:00 2001 From: jared03 Date: Sun, 30 Nov 2025 20:37:36 -0600 Subject: [PATCH] fix(memory): strip type field from entities/relations in loadGraph The JSONL file stores entities with a 'type' field to distinguish them from relations. However, the output schema for read operations doesn't include this field, causing schema validation errors (-32602). This fix uses destructuring to remove the 'type' field before pushing entities and relations to the result arrays. Fixes #3074 --- src/memory/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/memory/index.ts b/src/memory/index.ts index c7d781d2c4..2e6aa42e02 100644 --- a/src/memory/index.ts +++ b/src/memory/index.ts @@ -74,8 +74,14 @@ export class KnowledgeGraphManager { const lines = data.split("\n").filter(line => line.trim() !== ""); return lines.reduce((graph: KnowledgeGraph, line) => { const item = JSON.parse(line); - if (item.type === "entity") graph.entities.push(item as Entity); - if (item.type === "relation") graph.relations.push(item as Relation); + if (item.type === "entity") { + const { type, ...entity } = item; + graph.entities.push(entity as Entity); + } + if (item.type === "relation") { + const { type, ...relation } = item; + graph.relations.push(relation as Relation); + } return graph; }, { entities: [], relations: [] }); } catch (error) {