Skip to content

Commit dc41f6a

Browse files
authored
feat(openclaw): label "Current time" as UTC in injected memory context (#1804)
Append ` UTC` to the `Current time -` header injected above recalled memories. Without the label the LLM read the timestamp as local time and made wrong recency judgments. This is the same fix that landed for the Claude Code integration in #1568 — the OpenClaw integration was overlooked. Closes #1789
1 parent 5123e2a commit dc41f6a

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

hindsight-integrations/openclaw/src/index.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, it, expect } from "vitest";
22
import {
33
stripMemoryTags,
44
extractRecallQuery,
5+
formatCurrentTimeForRecall,
56
formatMemories,
67
prepareRetentionTranscript,
78
countUserTurns,
@@ -250,6 +251,22 @@ describe("formatMemories", () => {
250251
});
251252
});
252253

254+
// ---------------------------------------------------------------------------
255+
// formatCurrentTimeForRecall — UTC label (#1789, mirrors #1568)
256+
// ---------------------------------------------------------------------------
257+
258+
describe("formatCurrentTimeForRecall", () => {
259+
it("renders the UTC suffix so the LLM doesn't misread it as local time", () => {
260+
const fixed = new Date(Date.UTC(2026, 4, 27, 16, 25, 0)); // 2026-05-27 16:25 UTC
261+
expect(formatCurrentTimeForRecall(fixed)).toBe("2026-05-27 16:25 UTC");
262+
});
263+
264+
it("zero-pads month / day / hours / minutes", () => {
265+
const fixed = new Date(Date.UTC(2026, 0, 3, 4, 5, 0));
266+
expect(formatCurrentTimeForRecall(fixed)).toBe("2026-01-03 04:05 UTC");
267+
});
268+
});
269+
253270
// ---------------------------------------------------------------------------
254271
// retention helpers
255272
// ---------------------------------------------------------------------------

hindsight-integrations/openclaw/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,16 @@ async function flushRetainQueue(): Promise<void> {
316316
const DEFAULT_RECALL_PROMPT_PREAMBLE =
317317
"Relevant memories from past conversations (prioritize recent when conflicting). Only use memories that are directly useful to continue this conversation; ignore the rest:";
318318

319-
function formatCurrentTimeForRecall(date = new Date()): string {
319+
export function formatCurrentTimeForRecall(date = new Date()): string {
320320
const year = date.getUTCFullYear();
321321
const month = String(date.getUTCMonth() + 1).padStart(2, "0");
322322
const day = String(date.getUTCDate()).padStart(2, "0");
323323
const hours = String(date.getUTCHours()).padStart(2, "0");
324324
const minutes = String(date.getUTCMinutes()).padStart(2, "0");
325-
return `${year}-${month}-${day} ${hours}:${minutes}`;
325+
// Suffix with " UTC" so the LLM doesn't misread the timestamp as local
326+
// time and make wrong recency judgments. Mirrors the fix landed for the
327+
// Claude Code integration in #1568. (#1789)
328+
return `${year}-${month}-${day} ${hours}:${minutes} UTC`;
326329
}
327330

328331
/**

0 commit comments

Comments
 (0)