Skip to content

Commit bd3ddf4

Browse files
committed
feat(openclaw): label "Current time" as UTC in injected memory context
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 78c3525 commit bd3ddf4

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,
@@ -249,6 +250,22 @@ describe("formatMemories", () => {
249250
});
250251
});
251252

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

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)