From c7235afcd5e62a601aa3dd2a52fc9bbb60e95d1e Mon Sep 17 00:00:00 2001 From: xiaoyi Date: Sun, 27 Sep 2026 08:30:28 +0800 Subject: [PATCH] =?UTF-8?q?perf(graph/notes):=20graph=5Fpaths=20=E6=88=AA?= =?UTF-8?q?=E6=96=AD=E5=88=B0=2050=20=E6=9D=A1=EF=BC=881.7MB=20=E2=86=92?= =?UTF-8?q?=205KB/=E6=AC=A1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调用方核对:hermes 插件 data.get("notes")、openclaw client.ts r.data.notes、 hermes-zhiyi 旧副本 —— 3 处全只读 notes,无一处读 graph/notes 的 graph_paths (读 paths 的是 /graph/navigate 那条线)。 实测 entity=织忆:响应 1775KB → 5.1KB,notes 仍 3 篇、score 不变; paths_count 由 19266 → 50。max_hops/max_notes 语义不变。 --- go/internal/api/server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/go/internal/api/server.go b/go/internal/api/server.go index 42c4674..26f3022 100644 --- a/go/internal/api/server.go +++ b/go/internal/api/server.go @@ -552,6 +552,10 @@ func NewServer() http.Handler { var paths []map[string]interface{} mode := "none" var usedEntities []string + // 响应体积上限:调用方(hermes 插件 / openclaw 客户端 / dashboard)都只读 notes, + // 不读 graph_paths(2026-09-27 全仓核对 3 处调用点)。而单实体 2 跳可爆到 1.9 万条 + // ≈1.7MB/次 → 截断,仅作可观测样本。 + const maxGraphPaths = 50 if entity != "" { norm := routes.NormalizeEntity(entity) p, err := graphStore.Navigate(norm, maxHops, "", nil) @@ -569,6 +573,10 @@ func NewServer() http.Handler { if obsidian != nil { noteResults = obsidian.SearchNotesByEntities(entities, maxNotes) } + // 笔记匹配已用完完整路径集 → 响应只留样本(见上方 maxGraphPaths 说明) + if len(paths) > maxGraphPaths { + paths = paths[:maxGraphPaths] + } } if len(noteResults) > 0 { mode = "direct"