Skip to content

Add current date context to create/stream chat prompts#185

Open
vkarpov15 wants to merge 1 commit intomainfrom
codex/add-current-date-to-llm-prompts
Open

Add current date context to create/stream chat prompts#185
vkarpov15 wants to merge 1 commit intomainfrom
codex/add-current-date-to-llm-prompts

Conversation

@vkarpov15
Copy link
Member

Motivation

  • Provide the LLM with explicit temporal context by including the current date in system prompts for chat actions.
  • Ensure streaming and non-streaming chat flows receive the same date context so generated content can reference "today" reliably.
  • Keep existing optional options.context behavior while inserting the new date line cleanly.

Description

  • Added a currentDateContext line (Current date: YYYY-MM-DD) into the system prompt assembly for model-level chat actions in backend/actions/Model/createChatMessage.js and backend/actions/Model/streamChatMessage.js.
  • Added the same currentDateContext to thread-level chat actions in backend/actions/ChatThread/createChatMessage.js and backend/actions/ChatThread/streamChatMessage.js.
  • Switched prompt assembly to an array-based join ([systemPrompt, currentDateContext, ...].filter(Boolean).join('\n\n')) so options?.context remains optional and is appended cleanly.

Testing

  • Ran npm run lint, which completed successfully.
  • Ran npm test; the test run failed in this environment due to MongoDB not running (MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017).

Codex Task

Copilot AI review requested due to automatic review settings March 18, 2026 23:27
@vercel
Copy link

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio Ready Ready Preview, Comment Mar 18, 2026 11:27pm

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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)}`;

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-DD line 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 keep options?.context optional 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)}`;
Comment on lines +40 to +41
const currentDateContext = `Current date: ${new Date().toISOString().slice(0, 10)}`;
const system = [systemPrompt, currentDateContext, context, options?.context].filter(Boolean).join('\n\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants