From 44d019ec99b67624e2adb62e721ee38d2d38df2f Mon Sep 17 00:00:00 2001 From: krishnpalchouhan Date: Fri, 30 Jan 2026 18:25:32 +0530 Subject: [PATCH] fix: include day of week in date/time context injection (#4629) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The system prompt now displays the full formatted time including the day of week (e.g., "Current time: Monday, January 5th, 2026 — 3:26 PM (America/Chicago)") instead of just showing the timezone. --- src/agents/system-prompt.test.ts | 4 ++-- src/agents/system-prompt.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/agents/system-prompt.test.ts b/src/agents/system-prompt.test.ts index 5df63a3b4..4a9a0e9ee 100644 --- a/src/agents/system-prompt.test.ts +++ b/src/agents/system-prompt.test.ts @@ -145,7 +145,7 @@ describe("buildAgentSystemPrompt", () => { }); expect(prompt).toContain("## Current Date & Time"); - expect(prompt).toContain("Time zone: America/Chicago"); + expect(prompt).toContain("Current time: Monday, January 5th, 2026 — 3:26 PM (America/Chicago)"); }); it("includes user timezone when provided (24-hour)", () => { @@ -157,7 +157,7 @@ describe("buildAgentSystemPrompt", () => { }); expect(prompt).toContain("## Current Date & Time"); - expect(prompt).toContain("Time zone: America/Chicago"); + expect(prompt).toContain("Current time: Monday, January 5th, 2026 — 15:26 (America/Chicago)"); }); it("shows timezone when only timezone is provided", () => { diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index 7e6150676..d850d7b95 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -49,9 +49,12 @@ function buildUserIdentitySection(ownerLine: string | undefined, isMinimal: bool return ["## User Identity", ownerLine, ""]; } -function buildTimeSection(params: { userTimezone?: string }) { +function buildTimeSection(params: { userTimezone?: string; userTime?: string }) { if (!params.userTimezone) return []; - return ["## Current Date & Time", `Time zone: ${params.userTimezone}`, ""]; + const timeLine = params.userTime + ? `Current time: ${params.userTime} (${params.userTimezone})` + : `Time zone: ${params.userTimezone}`; + return ["## Current Date & Time", timeLine, ""]; } function buildReplyTagsSection(isMinimal: boolean) { @@ -445,6 +448,7 @@ export function buildAgentSystemPrompt(params: { ...buildUserIdentitySection(ownerLine, isMinimal), ...buildTimeSection({ userTimezone, + userTime: params.userTime, }), "## Workspace Files (injected)", "These user-editable files are loaded by OpenClaw and included below in Project Context.",