Skip to content

System prompt: include weekday in Current Date & Time section#40199

Open
ishitadatta wants to merge 1 commit intoopenclaw:mainfrom
ishitadatta:improve-system-prompt-weekday-context
Open

System prompt: include weekday in Current Date & Time section#40199
ishitadatta wants to merge 1 commit intoopenclaw:mainfrom
ishitadatta:improve-system-prompt-weekday-context

Conversation

@ishitadatta
Copy link
Copy Markdown

Summary

Adds a weekday line to the runtime system prompt time section when userTime is available.

Before:

  • ## Current Date & Time
  • Time zone: America/New_York

After:

  • ## Current Date & Time
  • Time zone: America/New_York
  • Day of week: Monday

Why

This improves schedule/calendar reliability without reintroducing full date/time churn in the system prompt.

Scope

  • src/agents/system-prompt.ts
    • Parse weekday from userTime and inject Day of week: <weekday>.
    • Keep full date/time out of system prompt for cache stability.
  • src/agents/system-prompt.test.ts
    • Added/updated assertions for weekday behavior.
    • Preserved assertions that full date/time strings are not injected.

Validation

  • npx vitest run src/agents/system-prompt.test.ts (43 tests passed)

Relates to #9899.

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Mar 8, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 8, 2026

Greptile Summary

This PR adds a Day of week line to the system prompt's "Current Date & Time" section when userTime is available. The implementation is sound:

  • extractWeekdayFromUserTime uses a simple regex to parse the leading day name from userTime, correctly extracting the weekday from the expected input format.
  • buildTimeSection conditionally spreads the Day of week: <weekday> line using a clean, non-breaking pattern.
  • Tests cover 12-hour, 24-hour, and timezone-only cases and properly assert that the full date/time string is not injected, preserving the cache-stability invariant.
  • The tradeoff between cache stability and scheduling accuracy is well-documented in comments and the PR description.

Confidence Score: 5/5

  • Safe to merge. Changes are minimal, well-tested, and non-breaking.
  • The implementation is correct and complete. The new function cleanly parses weekday from the expected input format, the integration is non-breaking, and the test suite covers all relevant cases including the important cache-stability invariant. No files require special attention.
  • No files require special attention.

Last reviewed commit: 4a32ea0

Copy link
Copy Markdown

@sriram369 sriram369 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this — weekday context is genuinely useful for scheduling-aware agents.

Two concerns worth discussing before this lands:

1. This conflicts with the documented preferred approach

The existing test has a comment pointing to #3658 as the preferred direction:

gateway-level timestamp injection into messages, not the system prompt

This PR goes the other way. Has that issue been revisited and closed as won't-do? If message-level injection is still the plan, this adds complexity in the wrong layer.

2. The weekday still causes daily cache churn

The original date/time was removed because it changed on every request. A weekday changes once per day — much better, but still a guaranteed daily cache miss for every agent that has userTime set. For high-volume local-model setups (exactly the users most sensitive to caching, like the Qwen3/MLX crowd), that's a cold restart every 24 hours.

3. The test comment was softened

The original comment read:

"The system prompt intentionally does NOT include the current date/time. Only the timezone is included, to keep the prompt stable for caching."

This PR changes it to:

"The system prompt intentionally does NOT include the full current date/time. Timezone and weekday are included..."

That's a meaningful architectural position being quietly revised inside a test comment. If the project is intentionally relaxing the caching guarantee, it deserves an explicit decision rather than a comment edit.

Not blocking — just flagging these for maintainer awareness before merge.

@ishitadatta
Copy link
Copy Markdown
Author

Hi Sriram thanks, this is very fair feedback.

You’re right on all three points:

Layering / architecture:
I agree this should follow the documented direction from #3658 (message-level timestamp context) unless maintainers explicitly decide otherwise.

Cache behavior:
Also agreed that weekday still introduces predictable daily prompt churn. It’s much smaller than full datetime churn, but it still breaks strict prompt stability.

Comment change:
Good callout. That comment edit effectively changed architectural intent without explicit consensus.

Given this, I’m happy to rework the contribution in one of these ways (maintainer preference):

A) Close this PR and open a new one that adds/improves message-level weekday/timestamp injection, or
B) Keep system prompt unchanged by default and gate weekday behind an explicit opt-in config flag (default off), with clear docs.
I can update quickly once i receive confirmation on preferred direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants