Assistant(API) doesn't know current DateTime

I created an assistant that acts as a scheduler. It schedules specific tasks on specific dates, but to schedule, it asks via chat which date the user would like to check for available times. When calling the availability-check tool, the assistant receives either a list of free times for that date or an error response if the date is unavailable.

The function the assistant uses receives the date to be checked as an argument, and if the user said something like: “I want to schedule for Friday.” The assistant is going to ‘suppose’ the date based on the current system date he has and my instructions.

The assistant tries to figure out the current date. Since the assistant needs to know the current date before every run, I add this information at every run, before execution:

.additionalInstructions("FORGET THE CURRENT DATE REGISTERED IN YOUR SYSTEM " +
                        "AND CONSIDER ONLY THE FOLLOWING DATE. THIS DATE WILL BE UPDATED EACH TIME " +
                        "A NEW RUN IS EXECUTED ON THE THREAD:\n" +
                        "THE CURRENT DATE AND TIME IS: " + formattedDate +
                        "The user's contact name saved in the system is: " + dto.getContextHistory().getUserName())

Thus, my assistant has knowledge of the current date. Knowing that today is Friday (01/24/2025), it should check for today or for the next Friday (01/31/2025). However, it checks for 01/26/2025. Considering that the assistant’s system was created in 2023, it might mistakenly consider January 2024, when 01/26 was indeed a Friday.

In the function that verifies this date, I reinforce the verification using the current date, but it seems to be ignored:

outputs.add(new SubmitToolOutputRequestItem(toolCall.getId(),
    "The establishment is closed on the selected date. " +
    "When preparing your response, remember the current date to avoid errors related to the days: " +
    formattedDate + "\nAfter receiving this return, confirm if the verified date is correct, " +
    "using the current date as a reference (count the days from the current date to the desired date " +
    "or use the current date to verify if the desired date was really checked correctly). " +
    "If an error occurred during the verification, call the function again."));

Has anyone experienced this before and can help me with ANY tip?

Only solution I think about is: Only allow the user to say the date in mm/dd/aaaa format, not accepting the ‘natural language’ it was suppose to undestand.

The model has been trained to expect data and time in the system prompt, so that’s where it needs to live.

I was doing something very similar this week and my guess is that this is a timezone problem. You need to make sure that timezone is added to your instructions AND make sure that every function call / interaction you have with the system uses the same time (zone)
.
In my case, I live in US ET (-5 UTC). So Anything I do in the evening past 7pm is ‘the next day’ in UTC.

2 Likes

great point, Plus stick it in the system prompt :smiley:

My ‘formattedDate’ I put in the additionalPropperties and the in the output is like:

Today is Friday, 24 of January, 2025. 04:25:30 PM

So, im using the date like this and it usually mess the response of the run

Thinking this way, I would have to update my assistant every new message from every user, every time.

If I run a scheduled script to, everyday at 00:01 update the new DATE in the system prompt, will it work like u said?

Like: Today is …

No this could be simply added to as a developer message?

During the conversation flow, it may be necessary to perform actions with dates.
Always use the #currentDateAndTimeCheck tool before checking a client’s availability. This way, you will know the exact current date and time.

I also have the code above in my system instructions, a tool to find the currentDateTime, and I’ll work now on a daily update to set the current date in the instructions like:
The current date is: %s