feat(agents): include current date and day-of-week in system prompt#43304
feat(agents): include current date and day-of-week in system prompt#43304chengjialu8888 wants to merge 3 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR attempts to inject the current date (with weekday) into the agent system prompt to fix incorrect day-of-week responses during scheduling tasks. The approach — computing a date string via Key issues found:
Confidence Score: 2/5
|
| ...buildUserIdentitySection(ownerLine, isMinimal), | ||
| ...buildTimeSection({ | ||
| userTimezone, | ||
| currentDate: params.currentDate, | ||
| }), |
There was a problem hiding this comment.
currentDate never forwarded — feature is silently broken
buildAgentSystemPrompt's parameter type (lines 195–242) does not declare a currentDate field. Accessing params.currentDate here will always yield undefined (or a TypeScript compile error in strict mode), so buildTimeSection will never receive the date string and the output will be identical to the pre-PR behavior.
The param type needs to be extended:
| ...buildUserIdentitySection(ownerLine, isMinimal), | |
| ...buildTimeSection({ | |
| userTimezone, | |
| currentDate: params.currentDate, | |
| }), | |
| ...buildTimeSection({ | |
| userTimezone, | |
| currentDate: params.currentDate, | |
| }), |
And the function signature must also include the new field, for example:
export function buildAgentSystemPrompt(params: {
// ... existing fields ...
currentDate?: string;
// ...
}) {Without this, the entire feature is a no-op.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/system-prompt.ts
Line: 570-574
Comment:
**`currentDate` never forwarded — feature is silently broken**
`buildAgentSystemPrompt`'s parameter type (lines 195–242) does not declare a `currentDate` field. Accessing `params.currentDate` here will always yield `undefined` (or a TypeScript compile error in strict mode), so `buildTimeSection` will never receive the date string and the output will be identical to the pre-PR behavior.
The param type needs to be extended:
```suggestion
...buildTimeSection({
userTimezone,
currentDate: params.currentDate,
}),
```
And the function signature must also include the new field, for example:
```ts
export function buildAgentSystemPrompt(params: {
// ... existing fields ...
currentDate?: string;
// ...
}) {
```
Without this, the entire feature is a no-op.
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: 1a0ca55afe
ℹ️ 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".
| userTimezone, | ||
| userTime, | ||
| userTimeFormat, | ||
| currentDate, |
There was a problem hiding this comment.
Thread currentDate through system prompt builders
currentDate is computed and returned here, but it is never propagated in the main prompt construction paths, so the new date/day-of-week line never appears at runtime. In all buildSystemPromptParams consumers, the destructuring still omits this field (src/auto-reply/reply/commands-system-prompt.ts:85, src/agents/cli-runner/helpers.ts:60, src/agents/pi-embedded-runner/run/attempt.ts:975), which leaves params.currentDate undefined when buildTimeSection renders the prompt. This makes the fix effectively a no-op for users relying on scheduling/date context.
Useful? React with 👍 / 👎.
Fixes #9899
Summary
currentDatefield (e.g., "Wednesday, March 12, 2026") to the system prompt, computed viaIntl.DateTimeFormatin the user's timezone.Cache Stability
Previous PRs (#32586, #40199) were rejected because injecting time into the system prompt breaks prefix caching. This PR only injects the date (no time component), which changes once per calendar day — preserving ~24h cache windows while solving the day-of-week problem.
Changes
src/agents/system-prompt-params.ts— AddedcurrentDatefield usingIntl.DateTimeFormatwith weekday+date (no time)src/agents/system-prompt.ts— UpdatedbuildTimeSection()to rendercurrentDateabove the timezone lineOutput
Testing
currentDateis optional; omitting it produces identical output to beforeIntl.DateTimeFormatis stable across Node.js versionsChangelog
Updated.