Skip to content

Commit 4a32ea0

Browse files
committed
Add weekday context to system time prompt section
1 parent d3111fb commit 4a32ea0

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/agents/system-prompt.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ describe("buildAgentSystemPrompt", () => {
387387
const prompt = buildAgentSystemPrompt(testCase.params);
388388
expect(prompt, testCase.name).toContain("## Current Date & Time");
389389
expect(prompt, testCase.name).toContain("Time zone: America/Chicago");
390+
if (testCase.name === "timezone-only") {
391+
expect(prompt, testCase.name).not.toContain("Day of week:");
392+
} else {
393+
expect(prompt, testCase.name).toContain("Day of week: Monday");
394+
}
390395
}
391396
});
392397

@@ -400,8 +405,8 @@ describe("buildAgentSystemPrompt", () => {
400405
expect(prompt).toContain("current date");
401406
});
402407

403-
// The system prompt intentionally does NOT include the current date/time.
404-
// Only the timezone is included, to keep the prompt stable for caching.
408+
// The system prompt intentionally does NOT include the full current date/time.
409+
// Timezone and weekday are included; full date/time is omitted for cache stability.
405410
// See: https://github.com/moltbot/moltbot/commit/66eec295b894bce8333886cfbca3b960c57c4946
406411
// Agents should use session_status or message timestamps to determine the date/time.
407412
// Related: https://github.com/moltbot/moltbot/issues/1897
@@ -420,6 +425,7 @@ describe("buildAgentSystemPrompt", () => {
420425
// https://github.com/moltbot/moltbot/issues/3658 for the preferred approach:
421426
// gateway-level timestamp injection into messages, not the system prompt.
422427
expect(prompt).toContain("Time zone: America/Chicago");
428+
expect(prompt).toContain("Day of week: Monday");
423429
expect(prompt).not.toContain("Monday, January 5th, 2026");
424430
expect(prompt).not.toContain("3:26 PM");
425431
expect(prompt).not.toContain("15:26");

src/agents/system-prompt.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,26 @@ function buildOwnerIdentityLine(
9494
return `Authorized senders: ${displayOwnerNumbers.join(", ")}. These senders are allowlisted; do not assume they are the owner.`;
9595
}
9696

97-
function buildTimeSection(params: { userTimezone?: string }) {
97+
function extractWeekdayFromUserTime(userTime?: string): string | undefined {
98+
const trimmed = userTime?.trim();
99+
if (!trimmed) {
100+
return undefined;
101+
}
102+
const match = /^([A-Za-z]+),/.exec(trimmed);
103+
return match?.[1];
104+
}
105+
106+
function buildTimeSection(params: { userTimezone?: string; userTime?: string }) {
98107
if (!params.userTimezone) {
99108
return [];
100109
}
101-
return ["## Current Date & Time", `Time zone: ${params.userTimezone}`, ""];
110+
const weekday = extractWeekdayFromUserTime(params.userTime);
111+
return [
112+
"## Current Date & Time",
113+
`Time zone: ${params.userTimezone}`,
114+
...(weekday ? [`Day of week: ${weekday}`] : []),
115+
"",
116+
];
102117
}
103118

104119
function buildReplyTagsSection(isMinimal: boolean) {
@@ -561,6 +576,7 @@ export function buildAgentSystemPrompt(params: {
561576
...buildUserIdentitySection(ownerLine, isMinimal),
562577
...buildTimeSection({
563578
userTimezone,
579+
userTime: params.userTime,
564580
}),
565581
"## Workspace Files (injected)",
566582
"These user-editable files are loaded by OpenClaw and included below in Project Context.",

0 commit comments

Comments
 (0)