steep-balloon-41261
03/23/2026, 12:03 PMtall-airline-16756
03/23/2026, 12:03 PMtall-airline-16756
03/23/2026, 12:03 PMget_date_info(iso_date) function tool:
◦ Use it to validate dates the LLM intends to speak aloud (call it automatically in your response-generation pipeline if you control that flow).
◦ Or prompt the LLM to call it before committing to any spoken scheduled date.
Example (conceptual)
1. on_user_turn_completed computes:
◦ "Current date/time: Saturday, February 14, 2026, 03:45 PM PST."
1. Add message to ChatContext:
◦ role: assistant
◦ content: "Current date/time: ... Use this for scheduling calculations."
1. Let the LLM generate a reply; if the reply contains a concrete date, optionally invoke get_date_info to confirm before the bot speaks.
If you want, I can:
• Provide a short code snippet for using on_user_turn_completed to insert the date/time with correct formatting and timezone.
• Sketch a minimal get_date_info function-tool implementation and show how to call it for verification.
Which would you prefer?
Sources: Building an Automated IVR Menu Caller | LiveKit Documentation | Amazon Nova Sonic integration guide | LiveKit Documentation | Function tool definition | LiveKit Documentation | Pipeline nodes and hooks | LiveKit Documentation | External data and RAG | LiveKit Documentation, with interactive elementsbetter-sandwich-65834
03/23/2026, 12:04 PMtall-airline-16756
03/23/2026, 12:05 PMon_user_turn_completed is unsupported in your realtime setup, here are practical alternatives you can use to ensure the LLM gets an accurate, Python-computed current date/time for scheduling and avoid day-of-week hallucinations.
Short recommendation
• Use a combined approach: (A) keep an authoritative current datetime in the system instructions updated on a short interval, and (B) provide a small function tool (e.g., get_current_datetime / get_date_info) that the model is strongly encouraged — or forced by your server logic — to call for any concrete date the bot intends to speak. This balances freshness with reliability in realtime models.
Why this combination works
• Realtime models don’t expose the post-turn hook, so you need server-side mechanisms to push dynamic context into the LLM’s inputs. Periodically updating the system instructions gives the model a recent baseline; the function tool gives a deterministic verification step that returns the exact day-of-week for any ISO date.
• The function tool covers the failure mode where the model confidently (but incorrectly) converts relative dates — the bot or the model can verify before speaking.
Implementation options and tradeoffs
1) System instructions updated periodically (recommended baseline)
• What to do:
◦ Run a background task that updates the agent’s system instructions with a single authoritative timestamp (include timezone).
◦ Update frequency depends on your needs: every minute for high precision, every 5–15 minutes for most scheduling use cases.
• Pros:
◦ Simple and guaranteed to be present in each request.
• Cons:
◦ Slightly stale between updates; frequent updates add overhead.
• Tip: Keep the content minimal and prescriptive, e.g.:
◦ "Current date/time (UTC): 2026-03-23T154500Z. Use this to resolve relative dates like 'next Friday'."
2) Function tool for deterministic verification (highly recommended)
• What to do:
◦ Implement a get_current_datetime() and/or get_date_info(iso_date) function tool in Python that returns exact date and day-of-week in a clear format.
◦ Encourage the LLM to call it for scheduling language, or have your server automatically call it when the LLM proposes a concrete date.
• Pros:
◦ Deterministic, authoritative, and prevents the model from speaking incorrect days.
◦ Small and inexpensive to run.
• Cons:
◦ If left purely to LLM discretion, model might not call it; mitigate by prompting policies or server-side verification.
• Tip: If you control the response pipeline, run the tool automatically on any candidate date the LLM outputs and replace/confirm the date before TTS.
3) Initial context injection at session start (only for low-dynamism cases)
• What to do:
◦ Add the session start time to the system or chat context when the session begins.
• Pros:
◦ Easy to implement.
• Cons:
◦ Only accurate for the session start; not good for long sessions where date may change.
4) Server-side parsing / verification step (defensive)
• What to do:
◦ After the LLM generates a reply but before TTS, parse any proposed calendar dates and verify them with your Python date functions. If mismatch, either correct it or prompt the model to re-confirm.
• Pros:
◦ Last-line defense that catches hallucinations even if model ignores tools.
• Cons:
◦ Adds a verification step and latency.
Concrete workflow I recommend
1. Periodically update system instructions with a concise, authoritative timestamp (e.g., every 1–5 minutes).
2. Expose a get_date_info(iso_date) function tool that returns day-of-week and formatted date.
3. In your response pipeline:
◦ If the LLM outputs a concrete calendar date, automatically call get_date_info to confirm the day-of-week before sending to TTS.
◦ If mismatch, correct the text or re-run the LLM with the verified date injected in the prompt.
1. Make the system instruction explicit: "Always use the current date/time in the system instruction for schedule math. Before speaking any specific date, verify it using the get_date_info tool."
Example verification pseudocode (conceptual)
• LLM generates candidate reply -> parse candidate for dates -> for each date call get_date_info(iso) -> if result differs from reply, replace or re-run LLM with verified date in prompt -> send to TTS.
If you want, I can:
• Provide a short Python snippet for a minimal get_date_info function tool and an example of how to auto-verify LLM output before TTS.
• Help pick an update cadence for system instructions based on your typical call length and latency constraints.
Which would you like next — the code snippet for the function tool, or the server-side verification example?
Sources: Pipeline nodes and hooks | LiveKit Documentation | Build a salary negotiation coach with a LemonSlice avatar | LiveKit | Function tool definition | LiveKit Documentation | External data and RAG | LiveKit Documentation | Realtime models overview | LiveKit Documentation, with interactive elements