mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:01:35 +00:00
fix(memory-flush): ban timestamped variant files in default flush prompt (#34951)
Merged via squash.
Prepared head SHA: efadda4988
Co-authored-by: zerone0x <39543393+zerone0x@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { resolveMemoryFlushPromptForRun } from "./memory-flush.js";
|
||||
import { DEFAULT_MEMORY_FLUSH_PROMPT, resolveMemoryFlushPromptForRun } from "./memory-flush.js";
|
||||
|
||||
describe("resolveMemoryFlushPromptForRun", () => {
|
||||
const cfg = {
|
||||
@@ -36,3 +36,16 @@ describe("resolveMemoryFlushPromptForRun", () => {
|
||||
expect((prompt.match(/Current time:/g) ?? []).length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("DEFAULT_MEMORY_FLUSH_PROMPT", () => {
|
||||
it("includes append-only instruction to prevent overwrites (#6877)", () => {
|
||||
expect(DEFAULT_MEMORY_FLUSH_PROMPT).toMatch(/APPEND/i);
|
||||
expect(DEFAULT_MEMORY_FLUSH_PROMPT).toContain("do not overwrite");
|
||||
});
|
||||
|
||||
it("includes anti-fragmentation instruction to prevent timestamped variant files (#34919)", () => {
|
||||
// Agents must not create YYYY-MM-DD-HHMM.md variants alongside the canonical file
|
||||
expect(DEFAULT_MEMORY_FLUSH_PROMPT).toContain("timestamped variant");
|
||||
expect(DEFAULT_MEMORY_FLUSH_PROMPT).toContain("YYYY-MM-DD.md");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,7 +13,8 @@ export const DEFAULT_MEMORY_FLUSH_FORCE_TRANSCRIPT_BYTES = 2 * 1024 * 1024;
|
||||
export const DEFAULT_MEMORY_FLUSH_PROMPT = [
|
||||
"Pre-compaction memory flush.",
|
||||
"Store durable memories now (use memory/YYYY-MM-DD.md; create memory/ if needed).",
|
||||
"IMPORTANT: If the file already exists, APPEND new content only and do not overwrite existing entries.",
|
||||
"IMPORTANT: If the file already exists, APPEND new content only — do not overwrite existing entries.",
|
||||
"Do NOT create timestamped variant files (e.g., YYYY-MM-DD-HHMM.md); always use the canonical YYYY-MM-DD.md filename.",
|
||||
`If nothing to store, reply with ${SILENT_REPLY_TOKEN}.`,
|
||||
].join(" ");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user