feat(agents): include full date with day of week in system prompt
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: <full date>' followed by 'Time zone: <timezone>'
This commit is contained in:
parent
6859e1e6a6
commit
fc24fef0d3
@ -6,6 +6,7 @@ Docs: https://docs.clawd.bot
|
|||||||
Status: unreleased.
|
Status: unreleased.
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
- Agents: include full date with day of week in system prompt. (#2108)
|
||||||
- Doctor: warn on gateway exposure without auth. (#2016) Thanks @Alex-Alaniz.
|
- Doctor: warn on gateway exposure without auth. (#2016) Thanks @Alex-Alaniz.
|
||||||
- Docs: add Vercel AI Gateway to providers sidebar. (#1901) Thanks @jerilynzheng.
|
- Docs: add Vercel AI Gateway to providers sidebar. (#1901) Thanks @jerilynzheng.
|
||||||
- Agents: expand cron tool description with full schema docs. (#1988) Thanks @tomascupr.
|
- Agents: expand cron tool description with full schema docs. (#1988) Thanks @tomascupr.
|
||||||
|
|||||||
@ -145,6 +145,7 @@ describe("buildAgentSystemPrompt", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(prompt).toContain("## Current Date & Time");
|
expect(prompt).toContain("## Current Date & Time");
|
||||||
|
expect(prompt).toContain("Current: Monday, January 5th, 2026 — 3:26 PM");
|
||||||
expect(prompt).toContain("Time zone: America/Chicago");
|
expect(prompt).toContain("Time zone: America/Chicago");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -157,6 +158,7 @@ describe("buildAgentSystemPrompt", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(prompt).toContain("## Current Date & Time");
|
expect(prompt).toContain("## Current Date & Time");
|
||||||
|
expect(prompt).toContain("Current: Monday, January 5th, 2026 — 15:26");
|
||||||
expect(prompt).toContain("Time zone: America/Chicago");
|
expect(prompt).toContain("Time zone: America/Chicago");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -49,9 +49,15 @@ 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 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) {
|
function buildReplyTagsSection(isMinimal: boolean) {
|
||||||
@ -297,6 +303,7 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
: undefined;
|
: undefined;
|
||||||
const reasoningLevel = params.reasoningLevel ?? "off";
|
const reasoningLevel = params.reasoningLevel ?? "off";
|
||||||
const userTimezone = params.userTimezone?.trim();
|
const userTimezone = params.userTimezone?.trim();
|
||||||
|
const userTime = params.userTime?.trim();
|
||||||
const skillsPrompt = params.skillsPrompt?.trim();
|
const skillsPrompt = params.skillsPrompt?.trim();
|
||||||
const heartbeatPrompt = params.heartbeatPrompt?.trim();
|
const heartbeatPrompt = params.heartbeatPrompt?.trim();
|
||||||
const heartbeatPromptLine = heartbeatPrompt
|
const heartbeatPromptLine = heartbeatPrompt
|
||||||
@ -459,6 +466,7 @@ export function buildAgentSystemPrompt(params: {
|
|||||||
...buildUserIdentitySection(ownerLine, isMinimal),
|
...buildUserIdentitySection(ownerLine, isMinimal),
|
||||||
...buildTimeSection({
|
...buildTimeSection({
|
||||||
userTimezone,
|
userTimezone,
|
||||||
|
userTime,
|
||||||
}),
|
}),
|
||||||
"## Workspace Files (injected)",
|
"## Workspace Files (injected)",
|
||||||
"These user-editable files are loaded by Clawdbot and included below in Project Context.",
|
"These user-editable files are loaded by Clawdbot and included below in Project Context.",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user