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:
parent
da71eaebd2
commit
44d019ec99
@ -145,7 +145,7 @@ describe("buildAgentSystemPrompt", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(prompt).toContain("## Current Date & Time");
|
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)", () => {
|
it("includes user timezone when provided (24-hour)", () => {
|
||||||
@ -157,7 +157,7 @@ describe("buildAgentSystemPrompt", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(prompt).toContain("## Current Date & Time");
|
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", () => {
|
it("shows timezone when only timezone is provided", () => {
|
||||||
|
|||||||
@ -49,9 +49,12 @@ function buildUserIdentitySection(ownerLine: string | undefined, isMinimal: bool
|
|||||||
return ["## User Identity", ownerLine, ""];
|
return ["## User Identity", ownerLine, ""];
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTimeSection(params: { userTimezone?: string }) {
|
function buildTimeSection(params: { userTimezone?: string; userTime?: string }) {
|
||||||
if (!params.userTimezone) return [];
|
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) {
|
function buildReplyTagsSection(isMinimal: boolean) {
|
||||||
@ -445,6 +448,7 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
...buildUserIdentitySection(ownerLine, isMinimal),
|
...buildUserIdentitySection(ownerLine, isMinimal),
|
||||||
...buildTimeSection({
|
...buildTimeSection({
|
||||||
userTimezone,
|
userTimezone,
|
||||||
|
userTime: params.userTime,
|
||||||
}),
|
}),
|
||||||
"## Workspace Files (injected)",
|
"## Workspace Files (injected)",
|
||||||
"These user-editable files are loaded by OpenClaw and included below in Project Context.",
|
"These user-editable files are loaded by OpenClaw and included below in Project Context.",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user