We all know llms are super bad at dates and time. My ai receptionist needs to book appointmetns and schedule.
I used to have the date and time in system prompt, but it would still hallucainate.
I then created a date and time tool before every schedule call and still isnt good enough.
Any ideas or unique implemetations would be great
Don’t let the model touch the arithmetic. Inject a fresh timestamp in on_user_turn_completed it’s per-turn, so it never goes stale the way a system-prompt anchor does then have the booking tool take the caller’s words verbatim and resolve them in Python:
@function_tool
async def book_appointment(self, ctx: RunContext, when: str) -> str:
"""when: the caller's own words "next Tuesday at 3". Do NOT convert to a date."""
slot = dateparser.parse(when, settings={
"RELATIVE_BASE": datetime.now(TZ).replace(tzinfo=None),
"PREFER_DATES_FROM": "future",
})
The model forwards a string, your code owns the calendar. PREFER_DATES_FROM: “future” kills the classic “Tuesday” → last Tuesday bug. Set TZ to the clinic’s zone, not the container’s a UTC server is a third silent source of wrong evening times.