Skip to content

fix: Display day of week in system prompt time section#7435

Closed
binim10 wants to merge 1 commit intoopenclaw:mainfrom
binim10:fix/show-day-of-week-in-prompt
Closed

fix: Display day of week in system prompt time section#7435
binim10 wants to merge 1 commit intoopenclaw:mainfrom
binim10:fix/show-day-of-week-in-prompt

Conversation

@binim10
Copy link
Copy Markdown

@binim10 binim10 commented Feb 2, 2026

Problem

The system prompt was generating userTime (including day of week) via formatUserTime() but not using it in buildTimeSection(). This caused the agent to not know which day of the week it is without explicitly running the date command or session_status tool.

Solution

  • Added userTime parameter to buildTimeSection() function signature
  • Pass params.userTime from buildAgentSystemPrompt() to buildTimeSection()
  • Display formatted time with day of week when userTime is available
  • Fallback to session_status tool prompt when userTime not provided
  • Filter out empty strings with .filter(Boolean)

Impact

  • Reduces unnecessary tool calls (agent no longer needs to run date repeatedly)
  • Improves agent context awareness from session start
  • Better user experience (agent knows if it's Monday/Tuesday/etc. immediately)

Testing

Tested locally - system prompt now shows:

## Current Date & Time
Time zone: Asia/Jerusalem
Current time: Monday, February 2nd, 2026 — 8:34 PM
Use the session_status tool for updated time.

Previously only showed timezone without the formatted time.

Greptile Overview

Greptile Summary

This change threads userTime into the system prompt “Current Date & Time” section so the prompt can show a preformatted local timestamp (including day-of-week) when available, while keeping the existing session_status guidance as a fallback. The update is localized to src/agents/system-prompt.ts, adjusting buildTimeSection’s signature and the call site in buildAgentSystemPrompt, and uses .filter(Boolean) to omit empty lines.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is small, localized to prompt-string construction, preserves the previous fallback behavior, and does not affect control flow beyond adding an optional line.
  • No files require special attention

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

The system prompt was generating userTime (with day of week) but not
using it in buildTimeSection. This caused the agent to not know which
day of the week it is without explicitly running date command.

Changes:
- Added userTime parameter to buildTimeSection function
- Display formatted time with day of week when available
- Fallback to session_status tool prompt when userTime not provided

This reduces unnecessary tool calls and improves agent context awareness.
@binim10
Copy link
Copy Markdown
Author

binim10 commented Feb 2, 2026

Closing this PR after discovering it conflicts with OpenClaw's intentional design for prompt cache stability.

The test does NOT include a date or time in the system prompt (cache stability) fails because including userTime in the system prompt would break Claude's prompt caching, causing:

  • Reduced performance
  • Increased API costs
  • System prompt reprocessing on every request

The preferred solution (per comments in the test) is gateway-level timestamp injection into messages, not the system prompt.

I'll explore the message-level timestamp approach instead. Thanks for the automated tests catching this! 🙏

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

Labels

agents Agent runtime and tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant