From fb3d2bc86bb22627cb90e18ea3d763537e67ad77 Mon Sep 17 00:00:00 2001 From: Episkey Date: Mon, 26 Jan 2026 17:17:13 +0800 Subject: [PATCH] feat(agents): include full date with day of week in system prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #2108 The system prompt now displays the full current date and time when userTime is available, including day of week (e.g., 'Monday, January 26th, 2026 — 15:30'). This eliminates day-of-week guessing errors where the agent would confidently state the wrong day based on timestamp inference. Changes: - Modified buildTimeSection to accept and display userTime parameter - Updated tests to verify userTime appears in system prompt - Format: 'Current: ' followed by 'Time zone: ' --- CHANGELOG.md | 1 + src/agents/system-prompt.test.ts | 2 ++ src/agents/system-prompt.ts | 12 ++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37ae5fdf2..6535b99aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Status: beta. - macOS: finish Moltbot app rename for macOS sources, bundle identifiers, and shared kit paths. (#2844) Thanks @fal3. - Branding: update launchd labels, mobile bundle IDs, and logging subsystems to bot.molt (legacy com.clawdbot migrations). Thanks @thewilloftheshadow. - Tools: add per-sender group tool policies and fix precedence. (#1757) Thanks @adam91holt. +- Agents: include full date with day of week in system prompt. (#2108) - Agents: summarize dropped messages during compaction safeguard pruning. (#2509) Thanks @jogi47. - Skills: add multi-image input support to Nano Banana Pro skill. (#1958) Thanks @tyler6204. - Agents: honor tools.exec.safeBins in exec allowlist checks. (#2281) diff --git a/src/agents/system-prompt.test.ts b/src/agents/system-prompt.test.ts index d915792af..af5ef9bb5 100644 --- a/src/agents/system-prompt.test.ts +++ b/src/agents/system-prompt.test.ts @@ -145,6 +145,7 @@ describe("buildAgentSystemPrompt", () => { }); expect(prompt).toContain("## Current Date & Time"); + expect(prompt).toContain("Current: Monday, January 5th, 2026 — 3:26 PM"); expect(prompt).toContain("Time zone: America/Chicago"); }); @@ -157,6 +158,7 @@ describe("buildAgentSystemPrompt", () => { }); expect(prompt).toContain("## Current Date & Time"); + expect(prompt).toContain("Current: Monday, January 5th, 2026 — 15:26"); expect(prompt).toContain("Time zone: America/Chicago"); }); diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index ed97fd539..513cbec58 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -49,9 +49,15 @@ 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 lines = ["## Current Date & Time"]; + if (params.userTime) { + lines.push(`Current: ${params.userTime}`); + } + lines.push(`Time zone: ${params.userTimezone}`); + lines.push(""); + return lines; } function buildReplyTagsSection(isMinimal: boolean) { @@ -294,6 +300,7 @@ export function buildAgentSystemPrompt(params: { : undefined; const reasoningLevel = params.reasoningLevel ?? "off"; const userTimezone = params.userTimezone?.trim(); + const userTime = params.userTime?.trim(); const skillsPrompt = params.skillsPrompt?.trim(); const heartbeatPrompt = params.heartbeatPrompt?.trim(); const heartbeatPromptLine = heartbeatPrompt @@ -445,6 +452,7 @@ export function buildAgentSystemPrompt(params: { ...buildUserIdentitySection(ownerLine, isMinimal), ...buildTimeSection({ userTimezone, + userTime, }), "## Workspace Files (injected)", "These user-editable files are loaded by Moltbot and included below in Project Context.",