diff --git a/src/prompt.test.ts b/src/prompt.test.ts
index 00a5446..bc70db1 100644
--- a/src/prompt.test.ts
+++ b/src/prompt.test.ts
@@ -1,5 +1,7 @@
import { describe, expect, test } from "bun:test";
+import type { MemoryBlock } from "./memory";
+
import { renderMemoryBlocks } from "./prompt";
describe("renderMemoryBlocks", () => {
@@ -47,9 +49,8 @@ describe("renderMemoryBlocks", () => {
expect(xml).toContain("");
});
- test("includes memory metadata block with timestamps", () => {
- const testDate = new Date("2025-01-15T10:30:00Z");
- const xml = renderMemoryBlocks([
+ test("memory metadata is stable across calls (cache-friendly head)", () => {
+ const blocks: MemoryBlock[] = [
{
scope: "global",
label: "human",
@@ -58,14 +59,18 @@ describe("renderMemoryBlocks", () => {
readOnly: false,
value: "hi",
filePath: "/tmp/human.md",
- lastModified: testDate,
+ lastModified: new Date("2025-01-15T10:30:00Z"),
},
- ]);
+ ];
+
+ const first = renderMemoryBlocks(blocks);
+ // small delay simulates two distinct requests
+ const second = renderMemoryBlocks(blocks);
- expect(xml).toContain("");
- expect(xml).toContain("The current system date is:");
- expect(xml).toContain("Memory blocks were last modified:");
- expect(xml).toContain("");
+ expect(first).toContain("");
+ expect(first).not.toContain("The current system date is:");
+ expect(first).not.toContain("Memory blocks were last modified:");
+ expect(second).toBe(first);
});
test("handles empty value gracefully", () => {
diff --git a/src/prompt.ts b/src/prompt.ts
index 9568e52..324c9eb 100644
--- a/src/prompt.ts
+++ b/src/prompt.ts
@@ -5,16 +5,8 @@ const LINE_NUMBER_WARNING =
"# NOTE: Line numbers shown below (with arrows like '1→') are to help during editing. Do NOT include line number prefixes in your memory edit tool calls.";
function renderMemoryMetadata(blocks: MemoryBlock[]): string {
- const now = new Date();
-
- const lastModified = blocks.reduce(
- (latest, block) => (block.lastModified > latest ? block.lastModified : latest),
- new Date(0)
- );
-
return `
-- The current system date is: ${now.toISOString()}
-- Memory blocks were last modified: ${lastModified.toISOString()}
+- Memory blocks are editable via memory_set / memory_replace.
- Use memory tools to manage your memory blocks
`;
}