Add current date context to create/stream chat prompts#185
Add current date context to create/stream chat prompts#185
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f657675305
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 'Current draft document:\n' + (documentData || '') | ||
| ].join('\n\n'); | ||
| const system = systemPrompt + '\n\n' + context + (options?.context ? '\n\n' + options.context : ''); | ||
| const currentDateContext = `Current date: ${new Date().toISOString().slice(0, 10)}`; |
There was a problem hiding this comment.
Use the user's timezone for
Current date
new Date().toISOString().slice(0, 10) always emits the UTC calendar day, but the prompt label says Current date with no timezone. For users outside UTC—especially US timezones during late afternoon/evening—the model will be told that “today” is already tomorrow, which defeats the purpose of this change for prompts that ask about today/tomorrow. This same UTC-based string is added in the other three chat actions as well, so the regression affects both streaming and non-streaming flows.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Adds explicit “current date” context into the system prompts used by backend chat actions, aiming to make both streaming and non-streaming LLM flows consistently aware of “today”.
Changes:
- Injects a
Current date: YYYY-MM-DDline into system prompt assembly for Model-level chat actions. - Injects the same date line into ChatThread-level chat actions.
- Refactors system prompt assembly to an array-based
filter(Boolean).join('\n\n')approach to keepoptions?.contextoptional and appended cleanly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| backend/actions/Model/createChatMessage.js | Adds currentDateContext and switches system prompt assembly to array join. |
| backend/actions/Model/streamChatMessage.js | Mirrors the non-streaming Model change for streaming. |
| backend/actions/ChatThread/createChatMessage.js | Adds currentDateContext and array-based system assembly for thread chat. |
| backend/actions/ChatThread/streamChatMessage.js | Mirrors the non-streaming ChatThread change for streaming. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'Current draft document:\n' + (documentData || '') | ||
| ].join('\n\n'); | ||
| const system = systemPrompt + '\n\n' + context + (options?.context ? '\n\n' + options.context : ''); | ||
| const currentDateContext = `Current date: ${new Date().toISOString().slice(0, 10)}`; |
| 'Current draft document:\n' + (documentData || '') | ||
| ].join('\n\n'); | ||
| const system = systemPrompt + '\n\n' + context + (options?.context ? '\n\n' + options.context : ''); | ||
| const currentDateContext = `Current date: ${new Date().toISOString().slice(0, 10)}`; |
| const modelDescriptions = getModelDescriptions(db); | ||
| const system = systemPrompt + '\n\n' + modelDescriptions + (options?.context ? '\n\n' + options.context : ''); | ||
| const currentDateContext = `Current date: ${new Date().toISOString().slice(0, 10)}`; | ||
| const system = [systemPrompt, currentDateContext, modelDescriptions, options?.context].filter(Boolean).join('\n\n'); |
| const modelDescriptions = getModelDescriptions(db); | ||
| const system = systemPrompt + '\n\n' + modelDescriptions + (options?.context ? '\n\n' + options.context : ''); | ||
| const currentDateContext = `Current date: ${new Date().toISOString().slice(0, 10)}`; | ||
| const system = [systemPrompt, currentDateContext, modelDescriptions, options?.context].filter(Boolean).join('\n\n'); |
|
|
||
| const modelDescriptions = getModelDescriptions(db); | ||
| const system = systemPrompt + '\n\n' + modelDescriptions + (options?.context ? '\n\n' + options.context : ''); | ||
| const currentDateContext = `Current date: ${new Date().toISOString().slice(0, 10)}`; |
|
|
||
| const modelDescriptions = getModelDescriptions(db); | ||
| const system = systemPrompt + '\n\n' + modelDescriptions + (options?.context ? '\n\n' + options.context : ''); | ||
| const currentDateContext = `Current date: ${new Date().toISOString().slice(0, 10)}`; |
| const currentDateContext = `Current date: ${new Date().toISOString().slice(0, 10)}`; | ||
| const system = [systemPrompt, currentDateContext, context, options?.context].filter(Boolean).join('\n\n'); |
Motivation
options.contextbehavior while inserting the new date line cleanly.Description
currentDateContextline (Current date: YYYY-MM-DD) into the system prompt assembly for model-level chat actions inbackend/actions/Model/createChatMessage.jsandbackend/actions/Model/streamChatMessage.js.currentDateContextto thread-level chat actions inbackend/actions/ChatThread/createChatMessage.jsandbackend/actions/ChatThread/streamChatMessage.js.[systemPrompt, currentDateContext, ...].filter(Boolean).join('\n\n')) sooptions?.contextremains optional and is appended cleanly.Testing
npm run lint, which completed successfully.npm test; the test run failed in this environment due to MongoDB not running (MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017).Codex Task