-
-
Notifications
You must be signed in to change notification settings - Fork 69.1k
buildTimeSection should inject current date/time, not just timezone #34422
Copy link
Copy link
Open
Description
Problem
buildTimeSection() in the system prompt builder only injects the timezone:
## Current Date & Time
Time zone: UTC
The actual current date and time are not included. This means agents have no reliable way to know the current date without calling a tool first, leading to off-by-one-day errors when reasoning about time-sensitive content (scheduling, email triage, etc.).
Suggested Fix
Use Intl.DateTimeFormat to render the current datetime in the user's timezone:
function buildTimeSection(params) {
if (!params.userTimezone) return [];
const now = new Date();
const formatter = new Intl.DateTimeFormat('en-US', {
timeZone: params.userTimezone,
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true
});
const dateStr = formatter.format(now);
return [
'## Current Date & Time',
`Current date and time: ${dateStr}`,
`Time zone: ${params.userTimezone}`,
''
];
}This affects reply-*.js, subagent-registry-*.js, pi-embedded-*.js, and plugin-sdk/reply-*.js.
Workaround
We've patched this locally on our instance and confirmed it works. Happy to submit a PR if helpful.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.