fix: include day of week in date/time context injection (#4629)

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.
This commit is contained in:
krishnpalchouhan 2026-01-30 18:25:32 +05:30 committed by krishnpalchouhan
parent da71eaebd2
commit 44d019ec99
2 changed files with 8 additions and 4 deletions

View File

@ -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", () => {

View File

@ -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.",