perf(graph/notes): graph_paths 截断到 50 条(1.7MB → 5KB/次)
调用方核对: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 语义不变。
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user