@Keynar, The issue is that creating a ChatContext() locally and adding a message doesn’t seed the session. The context has to be passed to the Agent constructor
[ Chat context | LiveKit Documentation ], otherwise the session never sees it.
For a static daily date, the cleanest fix is putting it directly in the Agent’s instructions:
from datetime import datetime
from zoneinfo import ZoneInfo
from livekit.agents import Agent
current_date = datetime.now(ZoneInfo("America/Toronto")).strftime("%A %d %B %Y")
class GarageAgent(Agent):
def __init__(self):
super().__init__(
instructions=f"""You are a helpful assistant.
La date d'aujourd'hui est : {current_date}.""",
)
For long sessions (across midnight, or where you need fresh time-of-day), a function_tool is more robust because the model fetches the date only when
needed and never serves a stale value:
from livekit.agents import function_tool
class GarageAgent(Agent):
@function_tool()
async def get_current_date(self) -> str:
"""Returns today's date in Toronto local time."""
return datetime.now(ZoneInfo("America/Toronto")).strftime("%A %d %B %Y")
The model will call this whenever the user asks about the date. Function Tools