From 7fd9c152d122c98c20dd511585486b80a10963dd Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Tue, 28 Apr 2026 01:58:14 -0700 Subject: [PATCH] fix(memory): keep pre-compaction flush prompt out of user transcript (#73380) --- CHANGELOG.md | 1 + src/auto-reply/reply/agent-runner-memory.test.ts | 4 ++++ src/auto-reply/reply/agent-runner-memory.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26e44ff4174..61afe7136f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Docs: https://docs.openclaw.ai - Channels/LINE: persist inbound image, video, audio, and file downloads in `~/.openclaw/media/inbound/` instead of temporary files so agents can still read LINE media after `/tmp` cleanup. Fixes #73370. Thanks @hijirii and @wenxu007. - CLI/plugins: keep bundled plugin installs out of `plugins.load.paths` while preserving install records, so install/inspect/doctor loops no longer warn about the current bundled plugin directory. Thanks @vincentkoc. - Cron/Telegram: add `--thread-id` to `openclaw cron add` and `openclaw cron edit`, preserving Telegram forum topic delivery targets across scheduled announcements. Carries forward #51581, #60373, and #60890. Thanks @ChunHao-dev. +- Memory/compaction: keep pre-compaction memory-flush prompts runtime-only so session transcripts and `chat.history` no longer expose them as normal user turns. Fixes #54408 and #58956; refs #43567. Thanks @markgong and @guoyuhang9. - Control UI/WebChat: keep large attachment payloads out of Lit state and optimistic chat messages, using object URL previews plus send-time payload serialization so PDF/image uploads no longer trigger `RangeError: Maximum call stack size exceeded`. Fixes #73360; refs #54378 and #63432. Thanks @hejunhui-73, @Ansub, and @christianhernandez3-afk. - Agents/Anthropic: cancel stalled Anthropic Messages SSE body reads when abort signals fire, so active-memory timeouts release transport resources instead of leaving hidden recall runs parked on `reader.read()`. Refs #72965 and #73120. Thanks @wdeveloper16. - Control UI/WebChat: keep pending run and typing state attached to the active client run, so unowned inject/announce/side-result finals no longer unlock unrelated active runs while completed owned runs still clear promptly. Fixes #57795; carries forward the narrow diagnosis from #57887. Thanks @haoyu-haoyu. diff --git a/src/auto-reply/reply/agent-runner-memory.test.ts b/src/auto-reply/reply/agent-runner-memory.test.ts index 86f0f9c5f57..223e03900a0 100644 --- a/src/auto-reply/reply/agent-runner-memory.test.ts +++ b/src/auto-reply/reply/agent-runner-memory.test.ts @@ -154,10 +154,12 @@ describe("runMemoryFlushIfNeeded", () => { expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1); const flushCall = runEmbeddedPiAgentMock.mock.calls[0]?.[0] as { prompt?: string; + transcriptPrompt?: string; memoryFlushWritePath?: string; silentExpected?: boolean; }; expect(flushCall.prompt).toContain("Pre-compaction memory flush."); + expect(flushCall.transcriptPrompt).toBe(""); expect(flushCall.memoryFlushWritePath).toMatch(/^memory\/\d{4}-\d{2}-\d{2}\.md$/); expect(flushCall.silentExpected).toBe(true); expect(refreshQueuedFollowupSessionMock).toHaveBeenCalledWith({ @@ -585,6 +587,7 @@ describe("runMemoryFlushIfNeeded", () => { const flushCall = runEmbeddedPiAgentMock.mock.calls[0]?.[0] as { prompt?: string; + transcriptPrompt?: string; extraSystemPrompt?: string; bootstrapPromptWarningSignaturesSeen?: string[]; bootstrapPromptWarningSignature?: string; @@ -594,6 +597,7 @@ describe("runMemoryFlushIfNeeded", () => { expect(flushCall.prompt).toContain("Write notes."); expect(flushCall.prompt).toContain("NO_REPLY"); expect(flushCall.prompt).toContain("MEMORY.md"); + expect(flushCall.transcriptPrompt).toBe(""); expect(flushCall.extraSystemPrompt).toContain("extra system"); expect(flushCall.extraSystemPrompt).toContain("Flush memory now."); expect(flushCall.memoryFlushWritePath).toBe("memory/2023-11-14.md"); diff --git a/src/auto-reply/reply/agent-runner-memory.ts b/src/auto-reply/reply/agent-runner-memory.ts index d0720b542d0..6b6f613236a 100644 --- a/src/auto-reply/reply/agent-runner-memory.ts +++ b/src/auto-reply/reply/agent-runner-memory.ts @@ -854,6 +854,7 @@ export async function runMemoryFlushIfNeeded(params: { trigger: "memory", memoryFlushWritePath, prompt: activeMemoryFlushPlan.prompt, + transcriptPrompt: "", extraSystemPrompt: flushSystemPrompt, bootstrapPromptWarningSignaturesSeen, bootstrapPromptWarningSignature: