-
-
Notifications
You must be signed in to change notification settings - Fork 69.1k
buildTimeSection should include resolved date/time, not just timezone #28958
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Problem
The buildTimeSection function in the system prompt only outputs:
## Current Date & Time
Time zone: America/New_York
This means agents don't have a reliable date anchor in their system context. They have to run date or parse the inbound message metadata timestamp to know what day it is. This leads to date hallucination bugs — for example, confidently mapping March 1 as Saturday when it's actually Sunday, and shifting an entire calendar view by one day.
Proposed Fix
buildTimeSection should resolve the current date/time using the user's timezone and include it:
## Current Date & Time
Friday, February 27, 2026 11:43 AM EST
Time zone: America/New_York
This is a one-line change:
function buildTimeSection(params) {
if (!params.userTimezone) return [];
const now = new Date().toLocaleString('en-US', {
timeZone: params.userTimezone,
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: '2-digit',
timeZoneName: 'short'
});
return [
'## Current Date & Time',
now,
`Time zone: ${params.userTimezone}`,
''
];
}Why It Matters
- Agents currently have to run
dateas a tool call just to know what day it is - Calendar/scheduling tasks are error-prone without a date anchor
- The inbound message metadata has a timestamp, but it's buried in untrusted context blocks
- Having it in the system prompt makes it authoritative and impossible to miss
Workaround
Using the timestamp field from inbound message metadata (server-generated, authoritative) as a date anchor. But this is fragile and requires the agent to know to look for it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Give feedbackNo fields configured for issues without a type.