How to get sid from agent.py? I tried like this `...
# ask-ai
b
How to get sid from agent.py? I tried like this
Copy code
async def entrypoint(ctx: JobContext):
    # Logging setup
    # Add any other context you want in all log entries here
    print(ctx.job.agent_name)
    print(ctx.room.name)
    print(await ctx.room.sid)
    ctx.log_context_fields = {
        "room": ctx.room.name,
However, voice_assistant_room_7651 2025-10-20 174325,130 - WARNING livekit.agents - The room connection was not established within 10 seconds after calling job_entry. This may indicate that job_ctx.connect() was not called. {"pid": 64424, "job_id": "AJ_HJMoJiPqPwPz"} 2025-10-20 174332,527 - WARNING livekit.agents - The room connection was not established within 10 seconds after calling job_entry. This may indicate that job_ctx.connect() was not called. {"pid": 64795, "job_id": "AJ_uACovkPFcTKe"}
t
Thanks for reaching out, 최윤지. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you retrieve the SID in your
agent.py
, it's important to make sure the room connection is fully established before you try to access the SID. Here's a little example that might make things clearer:
Copy code
async def entrypoint(ctx: JobContext):
    # Retrieve the room SID
    room_sid = await ctx.room.sid
    print(f"Room SID: {room_sid}")

    # Start your agent session
    session = AgentSession(...)
    await session.start(agent=MyAgent(), room=ctx.room)
The warning you saw usually means the room connection didn’t get established in time. This can happen if there’s a delay or if the room isn’t set up quite right. Double-checking your agent setup and room initialization might help smooth things out. If you run into any more questions or want to share your specific setup, I’m here to help—just let me know! Sources: livekit-rtc/livekit/rtc/_proto/room_pb2.pyi | Rooms, participants, and tracks | LiveKit Docs | livekit-agents/livekit/agents/voice/transcription/_utils.py | Universal Egress