Skip to content

Commit bdb75bd

Browse files
fix(active-memory): skip payload-less memory_search toolResults in tr… (#68773)
Verified: - pnpm install --frozen-lockfile - pnpm test extensions/active-memory/index.test.ts - pnpm exec oxfmt --check --threads=1 extensions/active-memory/index.ts extensions/active-memory/index.test.ts CHANGELOG.md - git diff --check origin/main..HEAD - gh pr checks 68773 --repo openclaw/openclaw --required Co-authored-by: SimbaKingjoe <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
1 parent 189c91e commit bdb75bd

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Docs: https://docs.openclaw.ai
1414
- fix(agents): canonicalize provider aliases in byProvider tool policy lookup [AI]. (#72917) Thanks @pgondhi987.
1515
- fix(security): block npm_execpath injection from workspace .env [AI-assisted]. (#73262) Thanks @pgondhi987.
1616
- Tools/web_fetch: decode response bodies from raw bytes using declared HTTP, XML, or HTML meta charsets before extraction, so Shift_JIS and other legacy-charset pages no longer return mojibake. Fixes #72916. Thanks @amknight.
17+
- Active Memory: skip payload-less `memory_search` transcript tool results when building debug telemetry, so newer empty entries no longer hide the latest useful debug payload. (#68773) Thanks @SimbaKingjoe.
1718
- Channels/Discord: bound message read/search REST calls, route those actions through Gateway execution, and fall back to `CommandTargetSessionKey` for inbound hook session keys so Discord reads do not hang and hooks still fire when `SessionKey` is empty. Fixes #73431. (#73521) Thanks @amknight.
1819
- Plugins/media: auto-enable provider plugins referenced by `agents.defaults.imageGenerationModel`, `videoGenerationModel`, and `musicGenerationModel` primary/fallback refs, so configured Google and MiniMax media providers do not stay disabled behind a restrictive plugin allowlist. Thanks @vincentkoc.
1920
- Memory-core/dreaming: retry managed dreaming cron registration after startup when the cron service is not reachable yet, so the scheduled Memory Dreaming Promotion sweep recovers without waiting for heartbeat traffic. Fixes #72841. Thanks @amknight.

‎extensions/active-memory/index.test.ts‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,54 @@ describe("active-memory plugin", () => {
11011101
]);
11021102
});
11031103

1104+
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+
11041152
it("replaces stale structured active-memory lines on a later empty run", async () => {
11051153
const sessionKey = "agent:main:stale-active-memory-lines";
11061154
hoisted.sessionStore[sessionKey] = {

‎extensions/active-memory/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ async function readActiveMemorySearchDebug(
12341234
continue;
12351235
}
12361236
const details = asRecord(message.details);
1237-
const debug = asRecord(details?.debug) ?? {};
1237+
const debug = asRecord(details?.debug);
12381238
const warning = normalizeOptionalString(details?.warning);
12391239
const action = normalizeOptionalString(details?.action);
12401240
const error = normalizeOptionalString(details?.error);

0 commit comments

Comments
 (0)