Is there a way to get the exact session start time...
# ask-ai
m
Is there a way to get the exact session start time in an AgentSession?
t
Thanks for reaching out, Alexander. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether you can get the exact session start time from an
AgentSession
. Yes — there isn't a built‑in
start_time
property, but you can record the timestamp when the session actually starts and attach it to the session or JobContext. A simple approach: 1. Capture the time in your
entrypoint
right before/when you call
session.start()
. 2. Store it on the session (e.g.,
session.userdata["session_start_time"]
) or log it via
ctx
for later use. Example (Python):
Copy code
import datetime

@server.rtc_session()
async def entrypoint(ctx: JobContext):
    session_start_time = datetime.datetime.now(datetime.timezone.utc)
    session = AgentSession(...)
    session.userdata["session_start_time"] = session_start_time
    await session.start(agent=MyAgent(), room=ctx.room)
    await ctx.connect()
If you need higher precision or an event-based marker, emit a custom
start
event from the agent when the room connection completes or use your observability tooling to record the exact moment the connection is established. Sources: Agents (Node.js) | livekit/livekit_composite | DeepWiki