fix(runtime): include day of week in system prompt date/time injection (#9899)#32586
fix(runtime): include day of week in system prompt date/time injection (#9899)#32586BlueBirdBack wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a long-standing issue where agents would guess the day of week incorrectly by threading the already-computed Key changes:
One issue found:
Confidence Score: 4/5
Last reviewed commit: ffb1807 |
Additional Comments (1)
After this PR, when This creates a contradiction: the prompt simultaneously supplies the date/time and instructs the model to make a tool call to retrieve it. At best this is confusing to the model; at worst it triggers unnecessary The condition should be narrowed so the hint only appears in the timezone-only fallback case (i.e. Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agents/system-prompt.ts
Line: 507-509
Comment:
**Stale `session_status` hint when `userTime` is already injected**
After this PR, when `userTime` is provided the system prompt now contains the formatted current date, time, and day of week directly. However, the guidance line at this location still unconditionally tells the agent _"If you need the current date, time, or day of week, run session_status"_ whenever `userTimezone` is set — even when the answer is already present in the prompt header.
This creates a contradiction: the prompt simultaneously supplies the date/time and instructs the model to make a tool call to retrieve it. At best this is confusing to the model; at worst it triggers unnecessary `session_status` calls.
The condition should be narrowed so the hint only appears in the **timezone-only fallback** case (i.e. `userTimezone` is set but `userTime` is not):
```suggestion
userTimezone && !userTime
? "If you need the current date, time, or day of week, run session_status (📊 session_status)."
: "",
```
How can I resolve this? If you propose a fix, please make it concise. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffb1807647
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const timeLine = formattedTime | ||
| ? `${formattedTime} (${params.userTimezone})` | ||
| : `Time zone: ${params.userTimezone}`; |
There was a problem hiding this comment.
Keep system prompt stable for provider prefix caching
Including userTime directly in the system prompt makes the prompt content change on every run (the value is generated from new Date() in src/agents/system-prompt-params.ts), which defeats prefix/system-prompt caching and increases latency/cost for cached providers (for example, src/agents/pi-embedded-runner/extra-params.ts explicitly adds cache_control to cache the system message). This regresses the existing cache-hit strategy and will impact all sessions that rebuild prompts frequently.
Useful? React with 👍 / 👎.
Summary
Fixes #9899 — The system prompt now includes the full formatted date/time with day of week when
userTimeis available, instead of just the timezone.Changes
src/agents/system-prompt.ts: UpdatedbuildTimeSection()to accept and renderuserTimeparameter. When available, outputsThursday, 2026-02-05 16:01 EST (America/New_York)instead of justTime zone: America/New_Yorksrc/agents/system-prompt.test.ts: Updated tests to verify both formats (with and withoutuserTime)Why
Agents frequently get the day of week wrong when doing calendar/schedule lookups. The
userTimewas already being computed bybuildSystemPromptParamsviaformatUserTimebut was not being threaded into the system prompt output.Minimal change — 2 files, 15 insertions, 20 deletions.