


























@@ -1101,6 +1101,54 @@ describe("active-memory plugin", () => {
11011101]);
11021102});
110311031104+it("skips newest memory_search toolResult entries that carry no debug payload", async () => {
1105+const sessionKey = "agent:main:transcript-debug";
1106+hoisted.sessionStore[sessionKey] = { sessionId: "s-main", updatedAt: 0 };
1107+1108+runEmbeddedPiAgent.mockImplementationOnce(async (params: { sessionFile: string }) => {
1109+const lines = [
1110+JSON.stringify({
1111+message: {
1112+role: "toolResult",
1113+toolName: "memory_search",
1114+details: { debug: { backend: "qmd", hits: 3 } },
1115+},
1116+}),
1117+JSON.stringify({
1118+message: {
1119+role: "toolResult",
1120+toolName: "memory_search",
1121+details: {},
1122+},
1123+}),
1124+];
1125+await fs.writeFile(params.sessionFile, `${lines.join("\n")}\n`, "utf8");
1126+return { payloads: [{ text: "wings are fine." }] };
1127+});
1128+1129+await hooks.before_prompt_build(
1130+{ prompt: "debug transcript bug", messages: [] },
1131+{ agentId: "main", trigger: "user", sessionKey, messageProvider: "webchat" },
1132+);
1133+1134+const updater = hoisted.updateSessionStore.mock.calls.at(-1)?.[1] as
1135+| ((store: Record<string, Record<string, unknown>>) => void)
1136+| undefined;
1137+const store = {
1138+[sessionKey]: { sessionId: "s-main", updatedAt: 0 },
1139+} as Record<string, Record<string, unknown>>;
1140+updater?.(store);
1141+const entries = store[sessionKey]?.pluginDebugEntries as
1142+| { pluginId: string; lines: string[] }[]
1143+| undefined;
1144+const debugLine = entries?.[0]?.lines.find((line) =>
1145+line.startsWith("🔎 Active Memory Debug:"),
1146+);
1147+expect(debugLine).toBeDefined();
1148+expect(debugLine).toContain("backend=qmd");
1149+expect(debugLine).toContain("hits=3");
1150+});
1151+11041152it("replaces stale structured active-memory lines on a later empty run", async () => {
11051153const sessionKey = "agent:main:stale-active-memory-lines";
11061154hoisted.sessionStore[sessionKey] = {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。