Fix processed history hash rebuild after recovery

This commit is contained in:
Youzini-afk
2026-04-11 01:45:26 +08:00
parent 298d615126
commit b2d8fcc7a1
5 changed files with 103 additions and 3 deletions

View File

@@ -415,6 +415,22 @@ export async function onRebuildController(runtime) {
reason: "用户手动触发全量重建",
}),
);
const recoveredLastProcessedFloor = Number.isFinite(
runtime.getCurrentGraph()?.historyState?.lastProcessedAssistantFloor,
)
? runtime.getCurrentGraph().historyState.lastProcessedAssistantFloor
: -1;
if (recoveredLastProcessedFloor >= 0) {
if (typeof runtime.updateProcessedHistorySnapshot === "function") {
runtime.updateProcessedHistorySnapshot(chat, recoveredLastProcessedFloor);
} else if (typeof runtime.applyProcessedHistorySnapshotToGraph === "function") {
runtime.applyProcessedHistorySnapshotToGraph(
runtime.getCurrentGraph(),
chat,
recoveredLastProcessedFloor,
);
}
}
runtime.saveGraphToChat({ reason: "manual-rebuild-complete" });
runtime.setLastExtractionStatus(
"图谱重建完成",