Skip to content

fix(system-prompt): include actual date/time in system prompt#1

Open
wakqasahmed wants to merge 4 commits intomainfrom
fix/system-prompt-date
Open

fix(system-prompt): include actual date/time in system prompt#1
wakqasahmed wants to merge 4 commits intomainfrom
fix/system-prompt-date

Conversation

@wakqasahmed
Copy link
Copy Markdown
Owner

Summary

Fixes openclaw#28194 - System prompt now includes the full current date and timezone instead of just the timezone.

Problem

The ## Current Date & Time section in the system prompt only contained the timezone, not the actual date/time. This caused the model to guess wrong dates (e.g., guessing "2025-07-19" when the actual date was "2026-02-27").

Solution

Modified buildTimeSection() in src/agents/system-prompt.ts to include the actual date/time:

  • Now generates: Friday, February 27th, 2026 — 9:04 AM (Asia/Shanghai) instead of just Time zone: Asia/Shanghai
  • Uses userTime parameter if provided, otherwise generates current date/time using toLocaleString()

Testing

  • All 41 system-prompt tests pass
  • TypeScript compiles without errors in modified files

Changes

  • src/agents/system-prompt.ts: Updated buildTimeSection() to include actual date/time
  • src/agents/system-prompt.test.ts: Updated tests to match new behavior

AI-assisted (Claude Code)

Satoshi Nakamoto and others added 2 commits February 27, 2026 04:14
Fixes openclaw#28194 - System prompt now includes the full current date and
timezone instead of just the timezone. This prevents the model from
guessing wrong dates (e.g. guessing 2025-07-19 instead of 2026-02-27).

The change uses userTime if provided, otherwise generates the current
date/time using toLocaleString with the user's timezone.
@wakqasahmed wakqasahmed force-pushed the fix/system-prompt-date branch from 7849964 to 93e0fa9 Compare February 27, 2026 03:52
…itly provided

- Remove auto-generation of userTime in system-prompt-params.ts
- Only include actual date/time in system prompt when userTime is explicitly provided
- When not provided, show timezone-only to maintain cache stability
- Users can use session_status tool to get current date/time when needed
- Addresses PR feedback about cache stability
The system-prompt-params now generates userTime from current date,
which is then used by buildTimeSection to include actual date/time
in the system prompt. This fixes the original issue where the model
was guessing wrong dates.

Trade-off: accepts cache instability to prevent model from guessing
incorrect dates. Users can use session_status tool for current time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System prompt 'Current Date & Time' only injects timezone, not the actual date

1 participant