Tools Agent thinks that October 27, 2023 is the current date

I’ve been beating my head against the wall for the past month and can’t get this fixed.

I’m running cloud-based version [email protected]. This is my current workflow:

I’m using this JavaScript in Current Date/Time:

const now = new Date();
const boiseTZ = new Intl.DateTimeFormat('en-US', {
    timeZone: 'America/Boise',
    weekday: 'long',
    year: 'numeric',
    month: 'long',
    day: 'numeric',
    hour: 'numeric',
    minute: 'numeric',
    timeZoneName: 'short'
}).format(now);

items[0].json = {
    ...items[0].json,
    currentDateAndTime: boiseTZ
};
return items;

This is at the start of the System Message in the Tools Agent:

SYSTEM INSTRUCTION: The current date and time is {{ $json.currentDateAndTime }}. You MUST use this exact date and time for all responses. Never use any other date. If asked about the current date or time, you must respond with this exact date and time.

I’ve tried simply using {{ now }} in the system message, and it did not work.

I’ve tried it with just {{ now }} in the system message and no Current Date/Time code node with no success.

I have probably tried over 100 things at this point and cannot get the Tools agent to pass the current (dynamically set) date.

From what I understand, the issue is that OpenAI Chat Model only knows the last date it saw, which was October 27, 2023. It seems to me like current date is extremely important! How do we get the system to pass the current date?

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Welcome to the community @Bradly_Fackrell !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.

Make sure that you have removed any sensitive information from your workflow and include dummy or pinned data with it!


You do not need the Code node to tell the agent what the current date is. In the system prompt symply use {{ $now }} (you seem to have missed the dollar sign). Also make sure to switch to expression mode.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.