```{"message": "The room connection was not establ...
# ask-ai
f
Copy code
{
  "message": "The room connection was not established within 10 seconds after calling job_entry. This may indicate that job_ctx.connect() was not called. ",
  "level": "WARNING",
  "name": "livekit.agents",
  "pid": 1087,
  "job_id": "AJ_SyFoXcLKGbHn",
  "timestamp": "2025-07-24T18:47:57.225006+00:00"
}
i confirm that my entrypoint contain job_ctx.connect()
t
Thanks for reaching out, jitendra. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The warning indicates that the room connection was not established within 10 seconds after calling the job entrypoint. Here are the steps to troubleshoot and resolve this issue: 1. Verify
ctx.connect()
is Called:
Ensure your entrypoint function calls
ctx.connect()
early in its execution. For example:
Copy code
async def entrypoint(ctx: JobContext):
    # Set up room listeners before connecting
    @ctx.room.on("track_subscribed")
    def on_track_subscribed(track: rtc.Track, *_):
        # Handle track subscription
        pass

    # Connect to room - this should be called early
    await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
1. Check for Blocking Operations: Avoid long-running synchronous operations before calling
ctx.connect()
. The connection should be established as early as possible in your entrypoint function. 2. Handle Exceptions Properly: Ensure that exceptions in your entrypoint don’t prevent
ctx.connect()
from being called. Wrap potentially failing code in try-catch blocks after establishing the connection. 3. For High Reliability Deployments: If this warning occurs intermittently in production: ◦ Run multiple servers for each
agent_name
to ensure availability. ◦ Ensure you’re not running other applications on the same server as your agent. ◦ Follow production deployment guidance for load balancing, auto-scaling, and worker availability. 1. Alternative: Explicit Shutdown: If your agent logic determines it should not connect to the room, call
ctx.shutdown()
instead to properly terminate the job without triggering the warning. Ensure that within 10 seconds of your entrypoint function starting, you either establish a room connection with
ctx.connect()
or explicitly shut down the job with
ctx.shutdown()
. Sources: livekit-agents/livekit/agents/voice/agent_session.py | Job lifecycle | LiveKit Docs | JobContext | LiveKit Agents | How to Get Help from LiveKit
f
is it necessary to give agent_name while dispatching on participant connection using accesstoken
t
Hey there! Let me break down why
agent_name
is super important when you're connecting participants using an access token in LiveKit. Think of it like introducing a specific friend to help you out in a room. 1. Explicit Dispatch Mechanism: When you dispatch agents via an access token, you're basically saying, "Hey, I want this specific helper to join me." 2. Agent Identification: The
agent_name
is like giving your helper a name tag. It tells LiveKit exactly which agent worker should jump into the room. Just make sure this name matches what's set up in the agent's
WorkerOptions
. 3. Protocol Requirement: The
RoomAgentDispatch
protocol needs the
agent_name
to know who's being called in - it's like the guest list for your room! Here's a friendly example to show you how to set this up:
Copy code
from livekit.api import (
    AccessToken,
    RoomAgentDispatch,
    RoomConfiguration,
    VideoGrants,
)

def create_token_with_agent_dispatch() -> str:
    token = (
        AccessToken()
        .with_identity("my_participant")
        .with_grants(VideoGrants(room_join=True, room=room_name))
        .with_room_config(
            RoomConfiguration(
                agents=[
                    RoomAgentDispatch(agent_name="test-agent", metadata="my_metadata")
                ],
            ),
        )
        .to_jwt()
    )
    return token
Pro tip: If you skip adding the
agent_name
, LiveKit will be totally confused about which agent worker to bring into the room. It's like sending an invitation without saying who's invited! Sources: Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | livekit/livekit_agent_dispatch.pb.go
f
and this agent_name will be unique if i have only 1 agentaSession
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!